Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » security » auth » spi » [javadoc | source]
org.jboss.security.auth.spi
abstract public class: AbstractServerLoginModule [javadoc | source]
java.lang.Object
   org.jboss.security.auth.spi.AbstractServerLoginModule

All Implemented Interfaces:
    LoginModule

Direct Known Subclasses:
    IdentityLoginModule, LdapLoginModule, TestLoginModule, DynamicLoginModule, AbstractPasswordCredentialLoginModule, HttpServletRequestLoginModule, ConfiguredIdentityLoginModule, UsernamePasswordLoginModule, HashTestLoginModule, SimpleServerLoginModule, CallerIdentityLoginModule, UsersRolesLoginModule, TestLoginModule, HashTestLoginModule, TomcatLoginModule, DatabaseServerLoginModule, AnonLoginModule

This class implements the common functionality required for a JAAS server side LoginModule and implements the JBossSX standard Subject usage pattern of storing identities and roles. Subclass this module to create your own custom LoginModule and override the login(), getRoleSets() and getIdentity() methods.

You may also wish to override

public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
In which case the first line of your initialize() method should be:
super.initialize(subject, callbackHandler, sharedState, options);

You may also wish to override

public boolean login() throws LoginException
In which case the last line of your login() method should be
return super.login();
Field Summary
protected  Subject subject     
protected  CallbackHandler callbackHandler     
protected  Map sharedState     
protected  Map options     
protected  Logger log     
protected  boolean useFirstPass    Flag indicating if the shared credential should be used 
protected  boolean loginOk    Flag indicating if the login phase succeeded. Subclasses that override the login method must set this to true on successful completion of login 
Method from org.jboss.security.auth.spi.AbstractServerLoginModule Summary:
abort,   commit,   createGroup,   getIdentity,   getRoleSets,   getUseFirstPass,   initialize,   login,   logout
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.security.auth.spi.AbstractServerLoginModule Detail:
 public boolean abort() throws LoginException 
    Method to abort the authentication process (phase 2).
 public boolean commit() throws LoginException 
    Method to commit the authentication process (phase 2). If the login method completed successfully as indicated by loginOk == true, this method adds the getIdentity() value to the subject getPrincipals() Set. It also adds the members of each Group returned by getRoleSets() to the subject getPrincipals() Set.
 protected Group createGroup(String name,
    Set principals) 
    Find or create a Group with the given name. Subclasses should use this method to locate the 'Roles' group or create additional types of groups.
 abstract protected Principal getIdentity()
    Overriden by subclasses to return the Principal that corresponds to the user primary identity.
 abstract protected Group[] getRoleSets() throws LoginException
    Overriden by subclasses to return the Groups that correspond to the to the role sets assigned to the user. Subclasses should create at least a Group named "Roles" that contains the roles assigned to the user. A second common group is "CallerPrincipal" that provides the application identity of the user rather than the security domain identity.
 protected boolean getUseFirstPass() 
 public  void initialize(Subject subject,
    CallbackHandler callbackHandler,
    Map sharedState,
    Map options) 
    Initialize the login module. This stores the subject, callbackHandler and sharedState and options for the login session. Subclasses should override if they need to process their own options. A call to super.initialize(...) must be made in the case of an override.

    The options are checked for the password-stacking parameter. If this is set to "useFirstPass", the login identity will be taken from the javax.security.auth.login.name value of the sharedState map, and the proof of identity from the javax.security.auth.login.password value of the sharedState map.

 public boolean login() throws LoginException 
    Looks for javax.security.auth.login.name and javax.security.auth.login.password values in the sharedState map if the useFirstPass option was true and returns true if they exist. If they do not or are null this method returns false. Note that subclasses that override the login method must set the loginOk ivar to true if the login succeeds in order for the commit phase to populate the Subject. This implementation sets loginOk to true if the login() method returns true, otherwise, it sets loginOk to false.
 public boolean logout() throws LoginException 
    Remove the user identity and roles added to the Subject during commit.