public class DefaultLoginModule extends AbstractLoginModule
DefaultLoginModule authenticates Credentials related to
 a User of the RepositoryThis Module can deal with the following credentials
SimpleCredentials -> handled by SimpleCredentialsAuthentication.TokenCredentials -> handled by TokenBasedAuthentication.
 Correspondingly impersonation is delegated to the User's
 Impersonation object.
AbstractLoginModule| Modifier and Type | Field and Description | 
|---|---|
| protected org.apache.jackrabbit.api.security.user.User | userThe user object retrieved during the authentication process. | 
adminId, anonymousId, callbackHandler, credentials, principal, principalProvider, sharedState, subject| Constructor and Description | 
|---|
| DefaultLoginModule() | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | commit()Method to commit the authentication process (phase 2). | 
| protected void | doInit(CallbackHandler callbackHandler,
      Session session,
      Map options)Retrieves the user manager from the specified session. | 
| protected Authentication | getAuthentication(Principal principal,
                 Credentials creds)Retrieve the  Authentication. | 
| 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. | 
| long | getTokenExpiration() | 
| protected String | getUserID(Credentials credentials)Method 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 theCredentialsviaSimpleCredentials.getUserID()Ask CallbackHandler for User-ID with use ofNameCallback.
 Test if the 'sharedState' contains a login name.
 Fallback: return the anonymous UserID. | 
| protected boolean | impersonate(Principal principal,
           Credentials credentials)Handles the impersonation of given Credentials. | 
| boolean | isDisableTokenAuth()Return a flag indicating if token based authentication is disabled. | 
| void | setDisableTokenAuth(boolean disableTokenAuth)Set a flag indicating if token based authentication is disabled. | 
| void | setTokenExpiration(long tokenExpiration) | 
| protected boolean | supportsCredentials(Credentials creds)Return a flag indicating whether the credentials are supported by
 this login module. | 
abort, authenticate, getAdminId, getAnonymousId, getCredentials, getImpersonatorSubject, getPreAuthAttributeName, getPrincipalProvider, getPrincipals, initialize, isAnonymous, isImpersonation, isInitialized, isPreAuthenticated, login, logout, setAdminId, setAnonymousId, setPrincipalProviderprotected org.apache.jackrabbit.api.security.user.User user
public boolean commit()
               throws LoginException
AbstractLoginModuleThis 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 login method),
 then this method associates relevant Principals and Credentials with the
 Subject located in the LoginModule.  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.
commit in interface LoginModulecommit in class AbstractLoginModuleLoginModule should be ignored.LoginException - if the commit failsLoginModule.commit()protected void doInit(CallbackHandler callbackHandler, Session session, Map options) throws LoginException
doInit in class AbstractLoginModulecallbackHandler - as passed by LoginContextsession - to security-workspace of Jackrabbitoptions - options from LoginModule configLoginException - in case initialization fails.AbstractLoginModule.doInit(CallbackHandler, Session, Map)protected Principal getPrincipal(Credentials credentials)
null is returned.getPrincipal in class AbstractLoginModulecredentials - Credentials to retrieve the principal for.null.AbstractLoginModule.getPrincipal(Credentials)protected boolean supportsCredentials(Credentials creds)
AbstractLoginModuleSimpleCredentials and GuestCredentials.supportsCredentials in class AbstractLoginModulecreds - credentialstrue if the credentials are supported;
         false otherwiseAbstractLoginModule.supportsCredentials(javax.jcr.Credentials)protected String getUserID(Credentials credentials)
AbstractLoginModuleGuestCredentials the anonymous user id
 is returned.Credentials via SimpleCredentials.getUserID()NameCallback.getUserID in class AbstractLoginModulecredentials - which, may contain a User-IDAbstractLoginModule.getUserID(javax.jcr.Credentials)protected Authentication getAuthentication(Principal principal, Credentials creds) throws RepositoryException
AbstractLoginModuleAuthentication.getAuthentication in class AbstractLoginModuleprincipal - A principal.creds - The Credentials used for the login.RepositoryException - If an error occurs.AbstractLoginModule.getAuthentication(Principal, Credentials)protected boolean impersonate(Principal principal, Credentials credentials) throws RepositoryException, FailedLoginException
 Current implementation takes User for the given Principal and
 delegates the check to
 Impersonation.allows(javax.security.auth.Subject)
impersonate in class AbstractLoginModuleprincipal - Principal to impersonate.credentials - Credentials used to create the impersonation subject.RepositoryExceptionFailedLoginException - if credentials don't allow to impersonate to principalAbstractLoginModule.impersonate(Principal, Credentials)public boolean isDisableTokenAuth()
true if token based authentication is disabled;
 false otherwise.public void setDisableTokenAuth(boolean disableTokenAuth)
disableTokenAuth - true to disable token based
 authentication; false otherwisepublic long getTokenExpiration()
public void setTokenExpiration(long tokenExpiration)
tokenExpiration - Sets the configured expiration time (in milliseconds)
 of login tokens.Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.