Class SimpleLogin
java.lang.Object
org.dlese.dpc.schemedit.security.login.BasicLogin
org.dlese.dpc.schemedit.security.login.SimpleLogin
- All Implemented Interfaces:
LoginModule
Base class for a variety of simple login modules that simply authenticate a
user against some database of user credentials.
Based on Tagish JAAS Login Modules package .
- Author:
- Jonathan Ostwald
-
Field Summary
FieldsFields inherited from class org.dlese.dpc.schemedit.security.login.BasicLogin
callbackHandler, options, sharedState, subject -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanabort()This method is called if the LoginContext's overall authentication failed.booleancommit()This method is called if the LoginContext's overall authentication succeeded (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules succeeded).Debuggin utility so login modules can print their namebooleanlogin()Authenticate the user.booleanlogout()Logout the user.protected voidputPrincipal(Set s, Principal p) Place the specifiedPrinciplein the subject and also record it in our principlesVectorso we can remove them all later.protected voidDebugging utility to show the contents of the sharedState mapprotected abstract VectorvalidateUser(String username, char[] password) Validate a user's credentials and either throw a LoginException (if validation fails) or return a Vector of Principals if validation succeeds.Methods inherited from class org.dlese.dpc.schemedit.security.login.BasicLogin
getOption, getOption, getOption, initialize
-
Field Details
-
principals
-
pending
-
commitSucceeded
protected boolean commitSucceeded
-
-
Constructor Details
-
SimpleLogin
public SimpleLogin()
-
-
Method Details
-
validateUser
Validate a user's credentials and either throw a LoginException (if validation fails) or return a Vector of Principals if validation succeeds.- Parameters:
username- The usernamepassword- The password- Returns:
- a Vector of Principals that apply for this user.
- Throws:
LoginException- if the login fails.
-
login
Authenticate the user.- Returns:
- true in all cases since this
LoginModuleshould not be ignored. - Throws:
LoginException- if thisLoginModuleis unable to perform the authentication.
-
putPrincipal
Place the specifiedPrinciplein the subject and also record it in our principlesVectorso we can remove them all later.- Parameters:
s- TheSetto add the Principle top- Principle to add
-
commit
This method is called if the LoginContext's overall authentication succeeded (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules succeeded).If this LoginModule's own authentication attempt succeeded (checked by retrieving the private state saved by the
loginmethod), then this method associates a number ofNTPrincipals with theSubjectlocated in theLoginModule. If this LoginModule's own authentication attempted failed, then this method removes any state that was originally saved.- Returns:
- true if this LoginModule's own login and commit attempts succeeded, or false otherwise.
- Throws:
LoginException- if the commit fails.
-
abort
This method is called if the LoginContext's overall authentication failed. (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed).If this LoginModule's own authentication attempt succeeded (checked by retrieving the private state saved by the
loginandcommitmethods), then this method cleans up any state that was originally saved.- Returns:
- false if this LoginModule's own login and/or commit attempts failed, and true otherwise.
- Throws:
LoginException- if the abort fails.
-
logout
Logout the user.This method removes the
Principals that were added by thecommitmethod.- Returns:
- true in all cases since this
LoginModuleshould not be ignored. - Throws:
LoginException- if the logout fails.
-
getLoginModuleName
Debuggin utility so login modules can print their name- Returns:
- loginModule name
-