Securing AS 7 applications using the ApplicationRealm

JBoss AS 7 and the EAP 6 provide out of the box a Security Domain which can be used for securing your applications. Let's see how to use it in a few simple steps.

When applications are deployed to the application server they are associated with a security domain within the security subsystem. The "other" security domain is provided to work with the ApplicationRealm, this domain is defined with a pair of login modules named respectively: "Remoting" and "RealmDirect" ("RealmUsersRoles" for AS7 ).

jboss as 7 security

  • The Remoting login module is used to check if the request currently being authenticated is a request received over a Remoting connection, if so the identity that was created during the authentication process is used and associated with the current request.
  • The RealmDirect when the request did not arrive over a Remoting connection, the application server makes use of this login module and then use the realm to load the users roles.

The advantage of this approach is that all of the backing store configuration can be left within the realm with the security domain just delegating to the realm.

Differences between JBoss AS 7.1.1 and EAP 6.1

 The main difference between AS7 and the EAP 6 is that JBoss AS 7 uses the RealmUsersRoles as basic mechanism for the Application/Management realm and contains the user/roles file definitions as options:

<security-domain name="other" cache-type="default">

   . . . . .
    <login-module code="RealmUsersRoles" flag="required">
       <module-option name="usersProperties" value="${jboss.server.config.dir}/"/>
       <module-option name="rolesProperties" value="${jboss.server.config.dir}/"/>
       <module-option name="unauthenticatedIdentity" value="guest"/>
       <module-option name="password-stacking" value="useFirstPass"/>


On the other hand, the EAP 6 uses the RealmDirect which delegates the file definitions to the ApplicationRealm:

<security-domain name="other" cache-type="default">

   . . . . . 
   <login-module code="RealmDirect" flag="required">
       <module-option name="password-stacking" value="useFirstPass"/>


That being said, let's see how to secure a simple Web application using the ApplicationRealm. Start by creating an user using the add-user script:

What type of user do you wish to add?
 a) Management User (
 b) Application User (
(a): b
Enter the details of the new user to add.
Realm (ApplicationRealm) :
Username : admin1234
Password :
Re-enter Password :
What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: Manager
About to add user 'admin1234' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'admin1234' to file 'C:\jboss\jboss-eap-6.1\standalone\configuration\'
Added user 'admin1234' with roles Manager to file 'C:\jboss\jboss-eap-6.1\standalone\configuration\'

 As you can see, we have added an user named admin1234 as part of the Manager group. This information has been stored into the files and

Let's configure a web application to use this security domain. Let's start with web.xml:

            <description>application security constraints


And here's the jboss-web.xml section, which binds the application to the Security domain named "other":


As it is, the Web application will issue a BASIC authentication window once you try to access your Web application.           

Follow us on Twitter