Package org.gluu.oxauth.model.common
Class AbstractToken
- java.lang.Object
-
- org.gluu.oxauth.model.common.AbstractToken
-
- All Implemented Interfaces:
java.io.Serializable,org.gluu.persist.model.base.Deletable
- Direct Known Subclasses:
AccessToken,AuthorizationCode,IdToken,RefreshToken,UmaPCT,UmaRPT
public abstract class AbstractToken extends java.lang.Object implements java.io.Serializable, org.gluu.persist.model.base.DeletableBase class for the access token, refresh token and authorization code.
When created, a token is valid for a given lifetime, and after this period of time, it will be marked as expired automatically by a background process.
When required, the token can be marked as revoked.
- Version:
- March 14, 2019
- Author:
- Javier Rojas Blum
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description AbstractToken(int lifeTime)Creates and initializes the values of an abstract token.protectedAbstractToken(java.lang.String code, java.util.Date creationDate, java.util.Date expirationDate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckExpired()Checks whether the token has expired and if true, marks itself as expired.voidcheckExpired(java.util.Date now)Checks whether the token has expired and if true, marks itself as expired.java.lang.StringgetAuthMode()Returns the authentication mode.java.lang.StringgetCode()Returns the token code.java.util.DategetCreationDate()Returns the creation date of the token.java.util.DategetExpirationDate()Returns the expiration date of the token.intgetExpiresIn()Returns the lifetime in seconds of the token.static java.lang.StringgetHash(java.lang.String input, SignatureAlgorithm signatureAlgorithm)java.lang.StringgetSessionDn()intgetTtl()java.lang.StringgetX5ts256()java.lang.BooleanisDeletable()booleanisExpired()Returntrueif the token has expired.booleanisRevoked()Returnstrueif the token has been revoked.booleanisValid()Checks whether a token is valid, it is valid if it is not revoked and not expired.voidresetTtlFromExpirationDate()voidsetAuthMode(java.lang.String authMode)Sets the authentication mode.voidsetCode(java.lang.String code)Sets the token code.voidsetCreationDate(java.util.Date creationDate)Sets the creation date of the token.voidsetDeletable(boolean deletable)voidsetExpirationDate(java.util.Date expirationDate)Sets the expiration date of the token.voidsetExpired(boolean expired)Sets the value of the expired flag to indicate whether the token has expired.voidsetRevoked(boolean revoked)Sets the value of the revoked flag to indicate whether the token has been revoked.voidsetSessionDn(java.lang.String sessionDn)voidsetX5ts256(java.lang.String x5ts256)
-
-
-
Method Detail
-
getTtl
public int getTtl()
-
resetTtlFromExpirationDate
public void resetTtlFromExpirationDate()
-
checkExpired
public void checkExpired()
Checks whether the token has expired and if true, marks itself as expired.
-
checkExpired
public void checkExpired(java.util.Date now)
Checks whether the token has expired and if true, marks itself as expired.
-
isValid
public boolean isValid()
Checks whether a token is valid, it is valid if it is not revoked and not expired.- Returns:
- Returns
trueif the token is valid.
-
getCode
public java.lang.String getCode()
Returns the token code.- Returns:
- The Code of the token.
-
setCode
public void setCode(java.lang.String code)
Sets the token code.- Parameters:
code- The code of the token.
-
getCreationDate
public java.util.Date getCreationDate()
Returns the creation date of the token.- Returns:
- The creation date.
-
setCreationDate
public void setCreationDate(java.util.Date creationDate)
Sets the creation date of the token.- Parameters:
creationDate- The creation date.
-
getExpirationDate
public java.util.Date getExpirationDate()
Returns the expiration date of the token.- Returns:
- The expiration date.
-
setExpirationDate
public void setExpirationDate(java.util.Date expirationDate)
Sets the expiration date of the token.- Parameters:
expirationDate- The expiration date.
-
isRevoked
public boolean isRevoked()
Returnstrueif the token has been revoked.- Returns:
trueif the token has been revoked.
-
setRevoked
public void setRevoked(boolean revoked)
Sets the value of the revoked flag to indicate whether the token has been revoked.- Parameters:
revoked- Revoke or not.
-
isExpired
public boolean isExpired()
Returntrueif the token has expired.- Returns:
trueif the token has expired.
-
setExpired
public void setExpired(boolean expired)
Sets the value of the expired flag to indicate whether the token has expired.- Parameters:
expired- Expire or not.
-
getAuthMode
public java.lang.String getAuthMode()
Returns the authentication mode.- Returns:
- The authentication mode.
-
setAuthMode
public void setAuthMode(java.lang.String authMode)
Sets the authentication mode.- Parameters:
authMode- The authentication mode.
-
getX5ts256
public java.lang.String getX5ts256()
-
setX5ts256
public void setX5ts256(java.lang.String x5ts256)
-
getSessionDn
public java.lang.String getSessionDn()
-
setSessionDn
public void setSessionDn(java.lang.String sessionDn)
-
isDeletable
public java.lang.Boolean isDeletable()
- Specified by:
isDeletablein interfaceorg.gluu.persist.model.base.Deletable
-
setDeletable
public void setDeletable(boolean deletable)
-
getExpiresIn
public int getExpiresIn()
Returns the lifetime in seconds of the token.- Returns:
- The lifetime in seconds of the token.
-
getHash
public static java.lang.String getHash(java.lang.String input, SignatureAlgorithm signatureAlgorithm)
-
-