Package com.spotfire.server.jaas
Class NamePasswordLoginModule
java.lang.Object
com.spotfire.server.jaas.NamePasswordLoginModule
- All Implemented Interfaces:
LoginModule
An abstract base class for
LoginModule implementations designed for username-password
authentication.
A typical subclass implements only the init(),
authenticate(UsernameCredential, PasswordCredential)
and getPrincipals() methods. Advanced LoginModule classes also implements the
getPublicCredentials() and getPrivateCredentials()
methods.
- Since:
- 3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanabort()This is an implementation of theabortmethod inLoginModuleinterface.abstract booleanauthenticate(UsernameCredential username, PasswordCredential password) This abstractauthenticatemethod is responsible for validating username-password combinations and must be implemented by all concrete subclasses.final booleancommit()This is an implementation of thecommitmethod inLoginModuleinterface.final StringReturns the value of the named option from the JAAS application configuration.protected final booleanThegetOptionmethod returns thebooleanvalue of the option with the given name.final StringReturns the value of the named option from the JAAS application configuration.final PasswordCredentialReturns thePasswordCredentialextracted from the input from thePasswordCallback.abstract CollectionThegetPrincipalsmethod must be implemented by all concrete subclasses and should return a list of allPrincipalobjects that should be associated with the logged inSubject.ThegetPrivateCredentialsmethod should return a list of all privateCredentialobjects associated with the logged inSubject.ThegetPublicCredentialsmethod should return a list of all publicCredentialobjects associated with the logged inSubject.final UsernameCredentialReturns theUsernameCredentialextracted from the input from theNameCallback.abstract voidinit()An abstract initialization method, called by theinitialize(Subject, CallbackHandler, Map, Map)method.final voidinitialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) This is an implementation of theinitializemethod inLoginModuleinterface.final booleanlogin()This is an implementation of theloginmethod inLoginModuleinterface.final booleanlogout()This is an implementation of thelogoutmethod inLoginModuleinterface.
-
Constructor Details
-
NamePasswordLoginModule
public NamePasswordLoginModule()Creates a new instance.- Since:
- 3.0
-
-
Method Details
-
init
public abstract void init()An abstract initialization method, called by theinitialize(Subject, CallbackHandler, Map, Map)method. ThegetOption(String)andgetOption(String, String)methods can be used to retrieve the login module's configuration parameters.- Since:
- 3.0
-
getUsernameCredential
Returns theUsernameCredentialextracted from the input from theNameCallback. The method can be used by a subclass when it is populating theCollectioninstances returned by thegetPrincipals,getPublicCredentialsandgetPrivateCredentialsmethods.- Returns:
- the
UsernameCredential - Since:
- 3.0
-
getPasswordCredential
Returns thePasswordCredentialextracted from the input from thePasswordCallback. The method can be used by a subclass when it is populating theCollectioninstances returned by thegetPrincipals,getPublicCredentialsandgetPrivateCredentialsmethods.- Returns:
- the
UsernameCredential - Since:
- 3.0
-
authenticate
public abstract boolean authenticate(UsernameCredential username, PasswordCredential password) throws FailedLoginException This abstractauthenticatemethod is responsible for validating username-password combinations and must be implemented by all concrete subclasses. The method should returntrueif the authentication succeeds for the given credentials. If theLoginModuleshould be ignored (e.g., when inappropriately requested to authenticate the root user), the method should returnfalse. If the authentication fails, aFailedLoginExceptionshould be thrown.- Parameters:
username- theUsernameCredentialpassword- thePasswordCredential- Returns:
- authentication status code which is
trueif authentication succeeds, orfalseif the module should be ignored. - Throws:
FailedLoginException- if the authentication fails- Since:
- 3.0
-
getPrincipals
ThegetPrincipalsmethod must be implemented by all concrete subclasses and should return a list of allPrincipalobjects that should be associated with the logged inSubject. If the method is called multiple times, it should always return the samePrincipalinstances. TheCollectioninstance holding thePrincipalobjects need not be the same, however.- Returns:
- a
Collectioncontaining allPrincipalobjects associated with the logged inSubject - Since:
- 3.0
-
getPublicCredentials
ThegetPublicCredentialsmethod should return a list of all publicCredentialobjects associated with the logged inSubject. If the method is called multiple times, it should always return the sameCredentialinstances. TheCollectionneed not be the same, however.- Returns:
- a
Collectioncontaining all publicCredentialobjects associated with the logged inSubject - Since:
- 3.0
-
getPrivateCredentials
ThegetPrivateCredentialsmethod should return a list of all privateCredentialobjects associated with the logged inSubject. If the method is called multiple times, it should always return the sameCredentialinstances. TheCollectionneed not be the same, however.- Returns:
- a
Collectioncontaining all privateCredentialobjects associated with the logged inSubject - Since:
- 3.0
-
getOption
Returns the value of the named option from the JAAS application configuration. If no such option exists, the method returnsnull.- Parameters:
name- the option name- Returns:
- the option value
- Since:
- 3.0
-
getOption
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.- Parameters:
name- the option namedefaultValue- a default option value- Returns:
- the option value
- Since:
- 3.0
-
initialize
public final void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) This is an implementation of theinitializemethod inLoginModuleinterface.- Specified by:
initializein interfaceLoginModule- Parameters:
subject- theSubjectto be authenticatedcallbackHandler- aCallbackHandlerfor communicating with the client applicationsharedState- aMapcontaining the shared state for all configuredLoginModuleinstances.options- aMapcontaining the configuration options for thisLoginModule- See Also:
-
login
This is an implementation of theloginmethod inLoginModuleinterface.- Specified by:
loginin interfaceLoginModule- Returns:
trueif the authentication succeeded, orfalseif thisLoginModuleshould be ignored.- Throws:
LoginException- if the authentication fails- See Also:
-
logout
This is an implementation of thelogoutmethod inLoginModuleinterface.Note: the logout method may not necessarily be called when the user actually logs out - it may even be called already right after the authentication has been completed to support features such as HTTP session clustering.
- Specified by:
logoutin interfaceLoginModule- Returns:
trueif the method succeeded, orfalseif thisLoginModuleshould be ignored.- Throws:
LoginException- if the logout fails- See Also:
-
commit
This is an implementation of thecommitmethod inLoginModuleinterface.- Specified by:
commitin interfaceLoginModule- Returns:
trueif the method succeeded, orfalseif thisLoginModuleshould be ignored.- Throws:
LoginException- if the commit fails- See Also:
-
abort
This is an implementation of theabortmethod inLoginModuleinterface.- Specified by:
abortin interfaceLoginModule- Returns:
trueif the method succeeded, orfalseif thisLoginModuleshould be ignored.- Throws:
LoginException- if the abort fails- See Also:
-
getOption
ThegetOptionmethod returns thebooleanvalue of the option with the given name. If no such option exists, the method returnsdefaultValue.- Parameters:
name- the name of an optiondefaultValue- the value to return if no option with the given name exists- Returns:
- the boolean value of the option -
trueif the string value wastrue,onoryesandfalseotherwise
-