JBoss container managed basic authentication

These days I am working on an ACS (Automatic Configuration System) which runs on a JBoss app server. So, yesterday I configured the server for cotnainer-managed authentication. Here is a straight forward tutorial to demonstrate how to secure your applications which hosted in JBoss by BASIC authentication methods. Container-managed authentication methods control how a user’s credentials are verified when a web app’s protected resource is accessed. This is a straight forward tutorial that shows how to configure JBoss application server to protect resources by a role based simple mechanism. By receiving any request to the protected resources JBoss asks web browser for a username and password. With this authentication method, all passwords are sent across the network in base64-encoded text. This could be fine to review the commented parts of JBoss configurations to find some more facilities If you need.

First step, web.xml modifications
Find the web.xml in the WEB-INF folder of your deployed ear application. This could be find in somewhere like this depends on the OS you use. Add below lines at the bottom of web.xml just before tag.


<realm-name>OSS Security</realm-name>

<description>ossmanager is the role required to access under oss</description>

<description>cpeowner is the role required to access under cpeowner</description>

Second step, joss-web.xml modifications
Right besides web.xml in the WEB-INF folder you can find jboss-web.xml to add below lines in. Note, datak-oss is the context of the application and acs-security-policy is the optional name that you call your security policy using it.


Third step, login-config.xml modifications
Find login-config.xml in server/default/conf folder and add below lines at the proper place.

<application-policy name =”acs-security-policy” >
<login-module code=”org.jboss.security.auth.spi.UsersRolesLoginModule” flag=”required”>
<module-option name=”usersProperties”>acs-users.properties</module-option>
<module-option name=”rolesProperties”>

Create acs-users.properties and acs-roles.properties text files into the WEB-INF/classes/ the same as below:




Exclude a URL by adding a blank security-constraint
I added this part two days later. Because the project manager asked me to exclude a certain URL (/cpe) from the secured zone. I have performed it just adding a new without role constraint. Below code added an excluded path to the secured zone, which every anonymous user can access it. Add below security-constraint to the web.xml the same as security-constraint that you added before.


This entry was posted in Java, Linux, Software Engineering. Bookmark the permalink.

Leave a Reply