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: UsernamePasswordLoginModule [javadoc | source]
java.lang.Object
   org.jboss.security.auth.spi.AbstractServerLoginModule
      org.jboss.security.auth.spi.UsernamePasswordLoginModule

All Implemented Interfaces:
    LoginModule

Direct Known Subclasses:
    LdapLoginModule, TestLoginModule, DynamicLoginModule, HttpServletRequestLoginModule, HashTestLoginModule, SimpleServerLoginModule, UsersRolesLoginModule, TestLoginModule, HashTestLoginModule, DatabaseServerLoginModule, AnonLoginModule

An abstract subclass of AbstractServerLoginModule that imposes an identity == String username, credentials == String password view on the login process.

Subclasses override the getUsersPassword() and getRoleSets() methods to return the expected password and roles for the user.

Fields inherited from org.jboss.security.auth.spi.AbstractServerLoginModule:
subject,  callbackHandler,  sharedState,  options,  log,  useFirstPass,  loginOk
Method from org.jboss.security.auth.spi.UsernamePasswordLoginModule Summary:
createPasswordHash,   getCredentials,   getIdentity,   getUnauthenticatedIdentity,   getUsername,   getUsernameAndPassword,   getUsersPassword,   initialize,   login,   validatePassword
Methods from org.jboss.security.auth.spi.AbstractServerLoginModule:
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.UsernamePasswordLoginModule Detail:
 protected String createPasswordHash(String username,
    String password) 
    If hashing is enabled, this method is called from login() prior to password validation.

    Subclasses may override it to provide customized password hashing, for example by adding user-specific information or salting.

    The default version calculates the hash based on the following options:

    • hashAlgorithm: The digest algorithm to use.
    • hashEncoding: The format used to store the hashes (base64 or hex)
    • hashCharset: The encoding used to convert the password to bytes for hashing.
    It will return null if the hash fails for any reason, which will in turn cause validatePassword() to fail.
 protected Object getCredentials() 
 protected Principal getIdentity() 
 protected Principal getUnauthenticatedIdentity() 
 protected String getUsername() 
 protected String[] getUsernameAndPassword() throws LoginException 
    Called by login() to acquire the username and password strings for authentication. This method does no validation of either.
 abstract protected String getUsersPassword() throws LoginException
    Get the expected password for the current username available via the getUsername() method. This is called from within the login() method after the CallbackHandler has returned the username and candidate password.
 public  void initialize(Subject subject,
    CallbackHandler callbackHandler,
    Map sharedState,
    Map options) 
    Override the superclass method to look for a unauthenticatedIdentity property. This method first invokes the super version.
 public boolean login() throws LoginException 
    Perform the authentication of the username and password.
 protected boolean validatePassword(String inputPassword,
    String expectedPassword) 
    A hook that allows subclasses to change the validation of the input password against the expected password. This version checks that neither inputPassword or expectedPassword are null that that inputPassword.equals(expectedPassword) is true;