aspose file tools*
The moose likes Servlets and the fly likes Help in Adding two security  constraint in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help in Adding two security  constraint in web.xml" Watch "Help in Adding two security  constraint in web.xml" New topic
Author

Help in Adding two security constraint in web.xml

Hemant Kumar Kawadlar
Greenhorn

Joined: Jul 05, 2009
Posts: 6
Hi,

I need help in adding multiple security constraints in web.xml.
I want to add two security constraints in web.xml. I did but while deployment it is giving error in web.xml.
I have added in following manner, sample from web.xml :

<web-app>
<servlet>
</servlet>

<security-constraint>
<display-name>abcConstraint</display-name>

<web-resource-collection>
<web-resource-name>abcCollection</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>HEAD</http-method>
<http-method>TRACE</http-method>
<http-method>POST</http-method>
<http-method>DELETE</http-method>
<http-method>OPTIONS</http-method>
</web-resource-collection>

<auth-constraint>
<role-name>abc</role-name>
</auth-constraint>

</security-constraint>


<security-constraint>
<display-name>Access To App</display-name>

<web-resource-collection>
<web-resource-name>App Resource</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>POST</http-method>
</web-resource-collection>

<auth-constraint>
<role-name>def</role-name>
</auth-constraint>

</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>My App</realm-name>
</login-config>

<security-role>
<role-name>abc</role-name>
</security-role>
</security-role>
<role-name>def</role-name>
<security-role>

</web-app>
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
The web.xml XML schema will tell you how to formulate a valid web.xml deployment descriptor.
A copy can be found here: http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
To try your web.xml deployment descriptor out, you can validate it against the schema prior to deployment.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Hemant Kumar Kawadlar
Greenhorn

Joined: Jul 05, 2009
Posts: 6
@Ivan : Thanks Ivan.. I will check the reference given and validate may web.xml.

@Bear : Surely, I will keep that in mind from next time onwards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help in Adding two security constraint in web.xml
 
Similar Threads
Get Error messages/Exceptions from Active Directory Server(ADS) with Weblogic 9.2
what is realm-name of login-config in DD
About the security and role in web.xml
Tomcat authentication and RACF
Adding users and roles