For the system administrator, JAAS consists of two kinds of configuration file:
For example, an application may have this login.conf file indicating how different authentication mechanisms are to be run to authenticate the user:
For the application developer, JAAS is a standard library that provides:
For the security system integrator, JAAS provides interfaces:
Login modules are primarily concerned with authentication rather than authorization and form a widely used component of JAAS. A login module is required to implement the javax.security.auth.spi.LoginModule interface, which specifies the following methods:
Note: A Subject is the user that is attempting to log in.
Login modules can provide single sign on (SSO) via a particular SSO protocol/framework (e.g. SAML, OpenID, and SPNEGO), can check for the presence of hardware security tokens (e.g. USB token), etc. In an n-tier application, LoginModules can be present on both the client side and server side.
Login modules are written by implementing this interface; they contain the actual code for authentication. It can use various mechanisms to authenticate user credentials. The code could retrieve a password from a database and compare it to the password supplied to the module.
The login context is the core of the JAAS framework which kicks off the authentication process by creating a Subject. As the authentication process proceeds, the subject is populated with various principals and credentials for further processing.
A subject represents a single user, entity or system –in other words, a client– requesting authentication.
A principal represents the face of a subject. It encapsulates features or properties of a subject. A subject can contain multiple principals.
Credentials are nothing but pieces of information regarding the subject in consideration. They might be account numbers, passwords, certificates etc. As the credential represents some important information, the further interfaces might be useful for creating a proper and secure credential – javax.security.auth.Destroyable and javax.security.auth.Refreshable. Suppose that after the successful authentication of the user you populate the subject with a secret ID (in the form of a credential) with which the subject can execute some critical services, but the credential should be removed after a specific time. In that case, one might want to implement the Destroyable interface. Refreshable might be useful if a credential has only a limited timespan in which it is valid.
Theodore J. Shrader; Bruce A. Rich; Anthony J. Nadalin (2000). Java and internet security. iUniverse. p. 152. ISBN 9780595135004. 9780595135004 ↩
"Java Authentication and Authorization Service (JAAS) Reference Guide". oracle.com. Oracle Corporation. Archived from the original on 6 June 2012. Retrieved 22 May 2012. https://web.archive.org/web/20120606055808/http://docs.oracle.com/javase/6/docs/technotes/guides/security/jaas/JAASRefGuide.html ↩