Enterprise Java Development@TOPIC@

Chapter 111. EJB Security

111.1. EJB Access Control (Declarative)
111.2. Programmatic Security
111.3. Authentication/Authorization JBoss Setup
111.4. Summary

  • javax.annotation.security annotations define access requirements to EJB methods


  • Access restrictions can also be defined in the ejb-jar.xml deployment descriptor


  • Permits more fine-grain access control down to the object level

  • role can be literal or a logical mapping (see below)


  • Permits role-name within Java code to be mapped to security role


  • Assigns one or more EJBs to a security-domain defined on server

  • Security is ignored until this is place

  • JBoss default security-domain is "other"

Wildfly Security Realms Wiki

  • Realm

  • User Credentials (username and password)


  • Watches over interactions

  • Defines policy on what can take place


  • Defines authentication and authorization sources

  • Optionally defines a default user for anonymous

$local default user bypasses authentication

JBoss can operate in a mode to trust a user connecting from the same machine and running under the same operating system identity that launched the server. This allows for development scenarios to bypass login credentials and Command Line Interface (CLI) to operate without credential prompts.


<local default-user="$local" allowed-users="*" skip-group-loading="true"/>

JBoss Ships with Sample Authentication and Authorization Impl

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