com.spotfire.server.jaas
Class NamePasswordLoginModule

java.lang.Object
  extended by com.spotfire.server.jaas.AbstractLoginModule
      extended by com.spotfire.server.jaas.NamePasswordLoginModule

public abstract class NamePasswordLoginModule
extends AbstractLoginModule

An abstract base class for javax.security.auth.spi.LoginModule implementations designed for username-password authentication.

A typical subclass implements only the NamePasswordLoginModule.init(), NamePasswordLoginModule.authenticate(com.spotfire.server.jaas.Credential[]) and NamePasswordLoginModule.getPrincipals() methods. Advanced LoginModule classes also implements the NamePasswordLoginModule.getPublicCredentials() and NamePasswordLoginModule.getPrivateCredentials() methods.

Since:
DSS 7.3

Field Summary
 
Fields inherited from class com.spotfire.server.jaas.AbstractLoginModule
ASSERT_OPTION, STATE_LOG_OPTION
 
Constructor Summary
NamePasswordLoginModule()
           
 
Method Summary
protected  boolean authenticate(Credential[] credentials)
          An implementation of the authenticate method in the AbstractLoginModule class that delegates the actual authentication work to the abstract authenticate method that takes one UsernameCredential and one PasswordCredential argument.
abstract  boolean authenticate(UsernameCredential username, PasswordCredential password)
          This abstract authenticate method is responsible for validating username-password combinations and must be implemented by all concrete subclasses.
protected  void configureSubClassStateLogger(boolean enabled)
           
protected  Callback[] createCallbacks()
          Creates the Callback items common for all NamePasswordLoginModule implementation.
protected  Credential[] extractCredentials(Callback[] callbacks)
          Extracts the username and password from the given Callback array and then creates the UsernameCredential and PasswordCredential objects.
 String getOption(String name)
          Returns the value of the named option from the JAAS application configuration.
 String getOption(String name, String defaultValue)
          Returns the value of the named option from the JAAS application configuration.
 PasswordCredential getPasswordCredential()
          Returns the PasswordCredential extracted from the input from the PasswordCallback.
abstract  Collection getPrincipals()
          The getPrincipals method must be implemented by all concrete subclasses and should return a list of all Principal objects that should be associated with the logged in Subject.
 Collection getPrivateCredentials()
          The getPrivateCredentials method must be implemented by all concrete subclasses and should return a list of all private Credential objects that should be associated with the logged in Subject.
 Collection getPublicCredentials()
          The getPublicCredentials method must be implemented by all concrete subclasses and should return a list of all public Credential objects that should be associated with the logged in Subject.
 UsernameCredential getUsernameCredential()
          Returns the UsernameCredential extracted from the input from the NameCallback.
abstract  void init()
          An abstract initialization method.
 
Methods inherited from class com.spotfire.server.jaas.AbstractLoginModule
abort, commit, configureStateLogger, getCredentials, getOption, getOptions, getSharedState, getState, getSubject, initialize, isAuthenticated, isCommitted, login, logout, setSubject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamePasswordLoginModule

public NamePasswordLoginModule()
Method Detail

configureSubClassStateLogger

protected void configureSubClassStateLogger(boolean enabled)
Specified by:
configureSubClassStateLogger in class AbstractLoginModule

init

public abstract void init()
An abstract initialization method. The NamePasswordLoginModule.getOption(String) and NamePasswordLoginModule.getOption(String, String) methods can be used to retrieve the login module's configuration parameters.

Specified by:
init in class AbstractLoginModule

createCallbacks

protected Callback[] createCallbacks()
Creates the Callback items common for all NamePasswordLoginModule implementation.

Specified by:
createCallbacks in class AbstractLoginModule
Returns:
a Callback array containing, in order, one NameCallback and one PasswordCallback

extractCredentials

protected Credential[] extractCredentials(Callback[] callbacks)
Extracts the username and password from the given Callback array and then creates the UsernameCredential and PasswordCredential objects. The credential are returned in an array in mentioned order.

Specified by:
extractCredentials in class AbstractLoginModule
Parameters:
callbacks - an array containing the client-processed Callback items
Returns:
an array containing the extracted Credential objects

getUsernameCredential

public UsernameCredential getUsernameCredential()
Returns the UsernameCredential extracted from the input from the NameCallback. The method can be used by a subclass when it is populating the Collection instances returned by the getPrincipals, getPublicCredentials and getPrivateCredentials methods.

Returns:
the UsernameCredential

getPasswordCredential

public PasswordCredential getPasswordCredential()
Returns the PasswordCredential extracted from the input from the PasswordCallback. The method can be used by a subclass when it is populating the Collection instances returned by the getPrincipals, getPublicCredentials and getPrivateCredentials methods.

Returns:
the UsernameCredential

authenticate

protected boolean authenticate(Credential[] credentials)
An implementation of the authenticate method in the AbstractLoginModule class that delegates the actual authentication work to the abstract authenticate method that takes one UsernameCredential and one PasswordCredential argument.

Specified by:
authenticate in class AbstractLoginModule
Parameters:
credentials - a Credential[] value
Returns:
a boolean value
Throws:
FailedLoginException - if the authentication fails
See Also:
AbstractLoginModule.login()

authenticate

public abstract boolean authenticate(UsernameCredential username,
                                     PasswordCredential password)
This abstract authenticate method is responsible for validating username-password combinations and must be implemented by all concrete subclasses. The method should return true if the authentication succeeds for the given credentials. If the LoginModule should be ignored (e.g., when inappropriately requested to authenticate the root user), the method should return false. If the authentication fails, a FailedLoginException should be thrown.

Parameters:
username - the UsernameCredential
password - the PasswordCredential
Returns:
authentication status code which is true if authentication succeeds, or false if the module should be ignored.
Throws:
FailedLoginException - if the authentication fails

getPrincipals

public abstract Collection getPrincipals()
The getPrincipals method must be implemented by all concrete subclasses and should return a list of all Principal objects that should be associated with the logged in Subject. If the method is called multiple times, it should always return the same Principal instances. The Collection instance holding the Principal objects need not be the same, however.

Specified by:
getPrincipals in class AbstractLoginModule
Returns:
a Collection containing all Principal objects associated with the logged in Subject

getPublicCredentials

public Collection getPublicCredentials()
The getPublicCredentials method must be implemented by all concrete subclasses and should return a list of all public Credential objects that should be associated with the logged in Subject. If the method is called multiple times, it should always return the same Credential instances. The Collection instance holding the Credential objects need not be the same, however.

Specified by:
getPublicCredentials in class AbstractLoginModule
Returns:
a Collection containing all public Credential objects associated with the logged in Subject

getPrivateCredentials

public Collection getPrivateCredentials()
The getPrivateCredentials method must be implemented by all concrete subclasses and should return a list of all private Credential objects that should be associated with the logged in Subject. If the method is called multiple times, it should always return the same Credential instances. The Collection instance holding the Credential objects need not be the same, however.

Specified by:
getPrivateCredentials in class AbstractLoginModule
Returns:
a Collection containing all private Credential objects associated with the logged in Subject

getOption

public String getOption(String name)
Returns the value of the named option from the JAAS application configuration.

Overrides:
getOption in class AbstractLoginModule
Parameters:
name - the option name
Returns:
the option value

getOption

public String getOption(String name,
                        String defaultValue)
Returns the value of the named option from the JAAS application configuration. If the option isn't present in the configuration, the method returns the specified default value.

Overrides:
getOption in class AbstractLoginModule
Parameters:
name - the option name
defaultValue - a default option value
Returns:
the option value


Copyright © 2000-2009 TIBCO Software Inc. All Rights Reserved.