Enterprise Java Development@TOPIC@

Chapter 113. JBoss/Wildfly Security

113.1. Security Realm
113.2. Security Realm References
113.3. Security Domain
113.3.1. "other" Security Domain
113.4. Wildfly Built-in Authentication and Authorization
113.5. Summary

# standalone.xml
<server xmlns="urn:jboss:domain:7.0">
  <management>
      <security-realms>
          <security-realm name="ApplicationRealm">
              <server-identities>
                  <ssl>
                      <keystore path="application.keystore" 
                                relative-to="jboss.server.config.dir" 
                                keystore-password="password" 
                                alias="server" 
                                key-password="password" 
                                generate-self-signed-certificate-host="localhost"/>
                  </ssl>
              </server-identities>
              <authentication>
                  <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
                  <properties path="application-users.properties" 
                              relative-to="jboss.server.config.dir"/>
              </authentication>
              <authorization>
                  <properties path="application-roles.properties" 
                              relative-to="jboss.server.config.dir"/>
              </authorization>
          </security-realm>
      </security-realms>

<subsystem xmlns="urn:jboss:domain:remoting:4.0">
    <http-connector name="http-remoting-connector" 
                    connector-ref="default" 
                    security-realm="ApplicationRealm"/>
</subsystem>

<subsystem xmlns="urn:jboss:domain:undertow:6.0" default-server="default-server" 
                                                 default-virtual-host="default-host" 
                                                 default-servlet-container="default" 
                                                 default-security-domain="other" 
                                                 statistics-enabled="true">
    <server name="default-server">
         ...
        <https-listener name="https" socket-binding="https" 
                                     security-realm="ApplicationRealm" 
                                     enable-http2="true"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <http-invoker security-realm="ApplicationRealm"/>
        </host>

<subsystem xmlns="urn:jboss:domain:security:2.0">
    <security-domains>
        <security-domain name="other" cache-type="default">
            <authentication>
                <login-module code="Remoting" flag="optional">
                    <module-option name="password-stacking" value="useFirstPass"/>
                </login-module>
                <login-module code="RealmDirect" flag="required">
                    <module-option name="password-stacking" value="useFirstPass"/>
                </login-module>
            </authentication>
        </security-domain>

<subsystem xmlns="urn:jboss:domain:ejb3:5.0">
    ...
    <default-security-domain value="other"/>
    ...
</subsystem>

<subsystem xmlns="urn:jboss:domain:undertow:6.0" default-server="default-server" 
                                                 default-virtual-host="default-host" 
                                                 default-servlet-container="default" 
                                                 default-security-domain="other" 
                                                 statistics-enabled="true">
  ...
</subsystem>

JBoss installs with a set of static files to implement user authentication and authorization. This can be augmented or replaced by more dynamic sources such as a database or LDAP.


  • Authenticates identity of user

  • Username and hashed password stored in static file


  • Assigns roles to authenticated user

  • Username and roles stored in static file