Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 4 of 6
The last element here, credential, is not a class or an interface, but can be any object. Credentials can include any authentication
artifact, such as a ticket, key, or password, that specific security systems might require. The Subject class maintains unique Sets of private and public credentials, which can be retrieved with methods such as getPrivateCredentials() and getPublicCrendentials(). These methods are more often used by security subsystems than at the application layer.
Your application layer uses LoginContext as its primary class for authenticating Subjects. LoginContext also represents where JAAS's dynamic pluggability comes into play, because when you construct a LoginContext, you specify a named configuration to load. The LoginContext typically loads the configuration information from a text file, which in turn tells the LoginContext which LoginModules to use during login.
The three commonly used methods in LoginContext are:
login() |
Performs login, a relatively complex step that invokes all LoginModules specified for this configuration. If it succeeds, it creates an authenticated Subject. If it fails, it throws a LoginException.
|
getSubject()
|
Returns the authenticated Subject.
|
logout() |
Logs out the authenticated Subject and removes its Principals and credentials.
|
We will show how to use these methods later.
LoginModule is the interface to specific authentication mechanisms. J2SE 1.4 ships with a set of ready-to-use LoginModules, including:
JndiLoginModule |
Verifies against a directory service configured under JNDI (Java Naming and Directory Interface) |
Krb5LoginModule
|
Authenticates using Kerberos protocols |
NTLoginModule |
Uses the current user's NT security information to authenticate |
UnixLoginModule |
Uses the current user's Unix security information to authenticate |
Along with these modules comes a set of corresponding concrete Principal implementations in the com.sun.security.auth package, such as NTDomainPrincipal and UnixPrincipal.
The LoginModule interface has five methods:
initialize() |
Called after the LoginModule is constructed.
|
|
Performs the authentication. |
commit() |
Called by the LoginContext after it has accepted the results from all LoginModules defined for this application. We assign Principals and credentials to the Subject here.
|
abort() |
Called when any LoginModule for this application fails (even though earlier ones in sequence may have succeeded—thus akin to a 2PC model). No Principals or credentials are assigned to the Subject.
|
logout() |
Removes the Principals and credentials associated with the Subject.
|
The application layer calls none of these methods directly—the LoginContext invokes them as needed. Our example below will elaborate on these methods' implementations.
CallbackHandlers and Callbacks let a LoginModule gather necessary authentication information from a user or system, while remaining independent of the actual interaction
mechanism. We'll leverage that capability in our design—our RdbmsLoginModule does not depend on how the user credentials (username/password) are obtained and can thus be used in the different application
environments we will illustrate (either from the command line or from a JSP).