public class TokenBasedAuthentication extends Object implements Authentication
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_COMPAT
Deprecated.
This system parameter allows to enable backwards compatible
behavior of the
TokenBasedAuthentication . Note that as of OAK 1.0
this flag will no be supported. |
static String |
TOKEN_ATTRIBUTE
The name of the login token attribute.
|
static long |
TOKEN_EXPIRATION
Default expiration time for login tokens is 2 hours.
|
Constructor and Description |
---|
TokenBasedAuthentication(String token,
long tokenExpiration,
Session session) |
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(Credentials credentials)
True if the Credentials identify the
User related to this
Authentication. |
boolean |
canHandle(Credentials credentials)
An Authentication may only be able to handle certain types of
Credentials as the authentication process is tightly coupled
to the semantics of the Credentials . |
static Credentials |
createToken(User user,
SimpleCredentials credentials,
long tokenExpiration,
Session session)
Create a new token node for the specified user.
|
static boolean |
doCreateToken(Credentials credentials)
Returns
true if the specified credentials
should be used to create a new login token. |
static Node |
getTokenNode(TokenCredentials credentials,
Session session) |
static String |
getUserId(TokenCredentials tokenCredentials,
Session session) |
static boolean |
isMandatoryAttribute(String attributeName)
|
static boolean |
isTokenBasedLogin(Credentials credentials)
Returns
true if the given credentials object
is an instance of TokenCredentials . |
public static final long TOKEN_EXPIRATION
public static final String TOKEN_ATTRIBUTE
public static final String PARAM_COMPAT
TokenBasedAuthentication
. Note that as of OAK 1.0
this flag will no be supported.public TokenBasedAuthentication(String token, long tokenExpiration, Session session) throws RepositoryException
RepositoryException
public boolean canHandle(Credentials credentials)
Authentication
Credentials
as the authentication process is tightly coupled
to the semantics of the Credentials
.
E.g.: A ticket based Authentication
is dependant on a
Credentials implementation which allows access to this ticket.canHandle
in interface Authentication
credentials
- in questionstrue
if the current Authentication handles the given CredentialsAuthentication.canHandle(javax.jcr.Credentials)
public boolean authenticate(Credentials credentials) throws RepositoryException
Authentication
User
related to this
Authentication.authenticate
in interface Authentication
credentials
- to verifytrue
if Credentials
identify the
User
.RepositoryException
- If an error occurs.Authentication.authenticate(javax.jcr.Credentials)
public static boolean isTokenBasedLogin(Credentials credentials)
true
if the given credentials
object
is an instance of TokenCredentials
.credentials
- true
if the given credentials
object
is an instance of TokenCredentials
; false
otherwise.public static boolean isMandatoryAttribute(String attributeName)
attributeName
- true
if the specified attributeName
starts with or equals TOKEN_ATTRIBUTE
.public static boolean doCreateToken(Credentials credentials)
true
if the specified credentials
should be used to create a new login token.credentials
- true
if upon successful authentication a new
login token should be created; false
otherwise.public static Credentials createToken(User user, SimpleCredentials credentials, long tokenExpiration, Session session) throws RepositoryException
user
- credentials
- tokenExpiration
- session
- TokenCredentials
to be used for
further login actions against this Authentication implementation.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.public static Node getTokenNode(TokenCredentials credentials, Session session) throws RepositoryException
RepositoryException
public static String getUserId(TokenCredentials tokenCredentials, Session session) throws RepositoryException
RepositoryException
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.