Sunday, April 18, 2010

JBoss Basic Authentication

1) In web.xml, enable basic authentication
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>default</realm-name>
</login-config>

2) In jboss-web.xml, set security domain
<jboss-web>
<security-domain>java:/jaas/Sample</security-domain>
<context-root>testProject</context-root>
</jboss-web>

3) In login-config.xml file, add entry for "securoty domain" id mentioned in step2.

<application-policy name = "Sample">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required"/>
</authentication>
</application>

4) In users.properties file, add username & password entries.
Users entered in this file only can access the resources.

******************************************************************************

Miscellaneous :-
1) For enabling directory listing, don't put any entry for "welcome file list" in web.xml. Also don't put any html file in ROOT directory of war file.

In jboss4.2.3, in server >> default >> deploy >> jboss-web.deployer >> conf >> web.xml, make listing "true" for DefaultServlet InitParameter.

No comments:

Post a Comment