Class TokenBasedAuthentication
- java.lang.Object
- 
- org.apache.jackrabbit.core.security.authentication.token.TokenBasedAuthentication
 
- 
- All Implemented Interfaces:
- Authentication
 
 public class TokenBasedAuthentication extends Object implements Authentication Authentication implementation that compares the tokens stored with a given user node to the token present in the SimpleCredentials attributes. Authentication succeeds if the login token refers to a non-expired token node and if all other credential attributes are equal to the corresponding properties.
- 
- 
Field SummaryFields Modifier and Type Field Description static StringPARAM_COMPATDeprecated.This system parameter allows to enable backwards compatible behavior of theTokenBasedAuthentication.static StringTOKEN_ATTRIBUTEThe name of the login token attribute.static longTOKEN_EXPIRATIONDefault expiration time for login tokens is 2 hours.
 - 
Constructor SummaryConstructors Constructor Description TokenBasedAuthentication(String token, long tokenExpiration, Session session)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanauthenticate(Credentials credentials)True if the Credentials identify theUserrelated to this Authentication.booleancanHandle(Credentials credentials)An Authentication may only be able to handle certain types ofCredentialsas the authentication process is tightly coupled to the semantics of theCredentials.static CredentialscreateToken(User user, SimpleCredentials credentials, long tokenExpiration, Session session)Create a new token node for the specified user.static booleandoCreateToken(Credentials credentials)Returnstrueif the specifiedcredentialsshould be used to create a new login token.static NodegetTokenNode(TokenCredentials credentials, Session session)static StringgetUserId(TokenCredentials tokenCredentials, Session session)static booleanisMandatoryAttribute(String attributeName)static booleanisTokenBasedLogin(Credentials credentials)Returnstrueif the givencredentialsobject is an instance ofTokenCredentials.
 
- 
- 
- 
Field Detail- 
TOKEN_EXPIRATIONpublic static final long TOKEN_EXPIRATION Default expiration time for login tokens is 2 hours.- See Also:
- Constant Field Values
 
 - 
TOKEN_ATTRIBUTEpublic static final String TOKEN_ATTRIBUTE The name of the login token attribute.- See Also:
- Constant Field Values
 
 - 
PARAM_COMPAT@Deprecated public static final String PARAM_COMPAT Deprecated.This system parameter allows to enable backwards compatible behavior of theTokenBasedAuthentication. Note that as of OAK 1.0 this flag will no be supported.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
TokenBasedAuthenticationpublic TokenBasedAuthentication(String token, long tokenExpiration, Session session) throws RepositoryException - Throws:
- RepositoryException
 
 
- 
 - 
Method Detail- 
canHandlepublic boolean canHandle(Credentials credentials) Description copied from interface:AuthenticationAn Authentication may only be able to handle certain types ofCredentialsas the authentication process is tightly coupled to the semantics of theCredentials. E.g.: A ticket basedAuthenticationis dependant on a Credentials implementation which allows access to this ticket.- Specified by:
- canHandlein interface- Authentication
- Parameters:
- credentials- in questions
- Returns:
- trueif the current Authentication handles the given Credentials
- See Also:
- Authentication.canHandle(javax.jcr.Credentials)
 
 - 
authenticatepublic boolean authenticate(Credentials credentials) throws RepositoryException Description copied from interface:AuthenticationTrue if the Credentials identify theUserrelated to this Authentication.- Specified by:
- authenticatein interface- Authentication
- Parameters:
- credentials- to verify
- Returns:
- trueif- Credentialsidentify the- User.
- Throws:
- RepositoryException- If an error occurs.
- See Also:
- Authentication.authenticate(javax.jcr.Credentials)
 
 - 
isTokenBasedLoginpublic static boolean isTokenBasedLogin(Credentials credentials) Returnstrueif the givencredentialsobject is an instance ofTokenCredentials.- Parameters:
- credentials-
- Returns:
- trueif the given- credentialsobject is an instance of- TokenCredentials;- falseotherwise.
 
 - 
isMandatoryAttributepublic static boolean isMandatoryAttribute(String attributeName) - Parameters:
- attributeName-
- Returns:
- trueif the specified- attributeNamestarts with or equals- TOKEN_ATTRIBUTE.
 
 - 
doCreateTokenpublic static boolean doCreateToken(Credentials credentials) Returnstrueif the specifiedcredentialsshould be used to create a new login token.- Parameters:
- credentials-
- Returns:
- trueif upon successful authentication a new login token should be created;- falseotherwise.
 
 - 
createTokenpublic static Credentials createToken(User user, SimpleCredentials credentials, long tokenExpiration, Session session) throws RepositoryException Create a new token node for the specified user.- Parameters:
- user-
- credentials-
- tokenExpiration-
- session-
- Returns:
- A new instance of TokenCredentialsto be used for further login actions against this Authentication implementation.
- Throws:
- RepositoryException- If there is no node corresponding to the specified user in the current workspace or if an error occurs while creating the token node.
 
 - 
getTokenNodepublic static Node getTokenNode(TokenCredentials credentials, Session session) throws RepositoryException - Throws:
- RepositoryException
 
 - 
getUserIdpublic static String getUserId(TokenCredentials tokenCredentials, Session session) throws RepositoryException - Throws:
- RepositoryException
 
 
- 
 
-