Class DefaultLoginModule
- java.lang.Object
 - 
- org.apache.jackrabbit.core.security.authentication.AbstractLoginModule
 - 
- org.apache.jackrabbit.core.security.authentication.DefaultLoginModule
 
 
 
- 
- All Implemented Interfaces:
 LoginModule
public class DefaultLoginModule extends AbstractLoginModule
TheDefaultLoginModuleauthenticates Credentials related to aUserof the Repository
In any other case it is marked to be ignored.This Module can deal with the following credentials
SimpleCredentials-> handled bySimpleCredentialsAuthentication.TokenCredentials-> handled byTokenBasedAuthentication.
Correspondingly impersonation is delegated to the
User'sImpersonationobject.- See Also:
 AbstractLoginModule
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected UseruserThe user object retrieved during the authentication process.- 
Fields inherited from class org.apache.jackrabbit.core.security.authentication.AbstractLoginModule
adminId, anonymousId, callbackHandler, credentials, principal, principalProvider, sharedState, subject 
 - 
 
- 
Constructor Summary
Constructors Constructor Description DefaultLoginModule() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancommit()Method to commit the authentication process (phase 2).protected voiddoInit(CallbackHandler callbackHandler, Session session, Map options)Retrieves the user manager from the specified session.protected AuthenticationgetAuthentication(Principal principal, Credentials creds)Retrieve theAuthentication.protected PrincipalgetPrincipal(Credentials credentials)Resolves the userID from the given credentials and obtains the principal from the User object associated with the given userID.longgetTokenExpiration()protected StringgetUserID(Credentials credentials)Method supports tries to acquire a UserID in the following order: If passed credentials areGuestCredentialsthe anonymous user id is returned. Try to access it from theCredentialsviaSimpleCredentials.getUserID()Ask CallbackHandler for User-ID with use ofNameCallback. Test if the 'sharedState' contains a login name. Fallback: return the anonymous UserID.protected booleanimpersonate(Principal principal, Credentials credentials)Handles the impersonation of given Credentials.booleanisDisableTokenAuth()Return a flag indicating if token based authentication is disabled.voidsetDisableTokenAuth(boolean disableTokenAuth)Set a flag indicating if token based authentication is disabled.voidsetTokenExpiration(long tokenExpiration)protected booleansupportsCredentials(Credentials creds)Return a flag indicating whether the credentials are supported by this login module.- 
Methods inherited from class org.apache.jackrabbit.core.security.authentication.AbstractLoginModule
abort, authenticate, getAdminId, getAnonymousId, getCredentials, getImpersonatorSubject, getPreAuthAttributeName, getPrincipalProvider, getPrincipals, initialize, isAnonymous, isImpersonation, isInitialized, isPreAuthenticated, login, logout, setAdminId, setAnonymousId, setPrincipalProvider 
 - 
 
 - 
 
- 
- 
Field Detail
- 
user
protected User user
The user object retrieved during the authentication process. 
 - 
 
- 
Method Detail
- 
commit
public boolean commit() throws LoginExceptionDescription copied from class:AbstractLoginModuleMethod to commit the authentication process (phase 2).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 relevant Principals and Credentials with theSubjectlocated in theLoginModule. If this LoginModule's own authentication attempted failed, then this method removes/destroys any state that was originally saved.The login is considered as succeeded if there is a principal set.
The implementation stores the principal associated to the UserID and all the Groups it is member of with the Subject and in addition adds an instance of (#link SimpleCredentials} to the Subject's public credentials.
- Specified by:
 commitin interfaceLoginModule- Overrides:
 commitin classAbstractLoginModule- Returns:
 - true if this method succeeded, or false if this
         
LoginModuleshould be ignored. - Throws:
 LoginException- if the commit fails- See Also:
 LoginModule.commit()
 
- 
doInit
protected void doInit(CallbackHandler callbackHandler, Session session, Map options) throws LoginException
Retrieves the user manager from the specified session. If this fails this login modules initialization must fail.- Specified by:
 doInitin classAbstractLoginModule- Parameters:
 callbackHandler- as passed byLoginContextsession- to security-workspace of Jackrabbitoptions- options from LoginModule config- Throws:
 LoginException- in case initialization fails.- See Also:
 AbstractLoginModule.doInit(CallbackHandler, Session, Map)
 
- 
getPrincipal
protected Principal getPrincipal(Credentials credentials)
Resolves the userID from the given credentials and obtains the principal from the User object associated with the given userID. If the the userID cannot be resolved to a User or if obtaining the principal fail,nullis returned.- Specified by:
 getPrincipalin classAbstractLoginModule- Parameters:
 credentials- Credentials to retrieve the principal for.- Returns:
 - a user principal or 
null. - See Also:
 AbstractLoginModule.getPrincipal(Credentials)
 
- 
supportsCredentials
protected boolean supportsCredentials(Credentials creds)
Description copied from class:AbstractLoginModuleReturn a flag indicating whether the credentials are supported by this login module. Default implementation supportsSimpleCredentialsandGuestCredentials.- Overrides:
 supportsCredentialsin classAbstractLoginModule- Parameters:
 creds- credentials- Returns:
 trueif the credentials are supported;falseotherwise- See Also:
 AbstractLoginModule.supportsCredentials(javax.jcr.Credentials)
 
- 
getUserID
protected String getUserID(Credentials credentials)
Description copied from class:AbstractLoginModuleMethod supports tries to acquire a UserID in the following order:- If passed credentials are 
GuestCredentialsthe anonymous user id is returned. - Try to access it from the 
CredentialsviaSimpleCredentials.getUserID() - Ask CallbackHandler for User-ID with use of 
NameCallback. - Test if the 'sharedState' contains a login name.
 - Fallback: return the anonymous UserID.
 
- Overrides:
 getUserIDin classAbstractLoginModule- Parameters:
 credentials- which, may contain a User-ID- Returns:
 - The userId retrieved from the credentials or by any other means described above.
 - See Also:
 AbstractLoginModule.getUserID(javax.jcr.Credentials)
 - If passed credentials are 
 
- 
getAuthentication
protected Authentication getAuthentication(Principal principal, Credentials creds) throws RepositoryException
Description copied from class:AbstractLoginModuleRetrieve theAuthentication.- Specified by:
 getAuthenticationin classAbstractLoginModule- Parameters:
 principal- A principal.creds- The Credentials used for the login.- Returns:
 - Authentication object for the given principal / credentials.
 - Throws:
 RepositoryException- If an error occurs.- See Also:
 AbstractLoginModule.getAuthentication(Principal, Credentials)
 
- 
impersonate
protected boolean impersonate(Principal principal, Credentials credentials) throws RepositoryException, FailedLoginException
Handles the impersonation of given Credentials.Current implementation takes
Userfor the given Principal and delegates the check toImpersonation.allows(javax.security.auth.Subject)- Specified by:
 impersonatein classAbstractLoginModule- Parameters:
 principal- Principal to impersonate.credentials- Credentials used to create the impersonation subject.- Returns:
 - false, if there is no User to impersonate, true if impersonation is allowed
 - Throws:
 RepositoryExceptionFailedLoginException- if credentials don't allow to impersonate to principal- See Also:
 AbstractLoginModule.impersonate(Principal, Credentials)
 
- 
isDisableTokenAuth
public boolean isDisableTokenAuth()
Return a flag indicating if token based authentication is disabled.- Returns:
 trueif token based authentication is disabled;falseotherwise.
 
- 
setDisableTokenAuth
public void setDisableTokenAuth(boolean disableTokenAuth)
Set a flag indicating if token based authentication is disabled.- Parameters:
 disableTokenAuth-trueto disable token based authentication;falseotherwise
 
- 
getTokenExpiration
public long getTokenExpiration()
- Returns:
 - The configured expiration time for login tokens in milliseconds.
 
 
- 
setTokenExpiration
public void setTokenExpiration(long tokenExpiration)
- Parameters:
 tokenExpiration- Sets the configured expiration time (in milliseconds) of login tokens.
 
 - 
 
 -