Package io.jans.as.server.model.common
Class AbstractToken
- java.lang.Object
-
- io.jans.as.server.model.common.AbstractToken
-
- All Implemented Interfaces:
io.jans.orm.model.base.Deletable,Serializable
- Direct Known Subclasses:
AccessToken,AuthorizationCode,IdToken,RefreshToken,TxToken,UmaPCT,UmaRPT
public abstract class AbstractToken extends Object implements Serializable, io.jans.orm.model.base.Deletable
Base 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:
- September 30, 2021
- Author:
- Javier Rojas Blum
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractToken(int lifeTime)Creates and initializes the values of an abstract token.protectedAbstractToken(String code, Date creationDate, 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(Date now)Checks whether the token has expired and if true, marks itself as expired.StringgetCode()Returns the token code.DategetCreationDate()Returns the creation date of the token.StringgetDpop()DategetExpirationDate()Returns the expiration date of the token.intgetExpiresIn()Returns the lifetime in seconds of the token.static StringgetHash(String input, io.jans.as.model.crypto.signature.SignatureAlgorithm signatureAlgorithm)StringgetReferenceId()Gets reference idStringgetSessionDn()IntegergetStatusListIndex()Gets status list indexintgetTtl()StringgetX5ts256()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()voidsetCode(String code)Sets the token code.voidsetCreationDate(Date creationDate)Sets the creation date of the token.voidsetDeletable(boolean deletable)voidsetDpop(String dpop)voidsetExpirationDate(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.voidsetReferenceId(String referenceId)Sets reference idvoidsetRevoked(boolean revoked)Sets the value of the revoked flag to indicate whether the token has been revoked.voidsetSessionDn(String sessionDn)voidsetStatusListIndex(Integer statusListIndex)Sets status list indexvoidsetX5ts256(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(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 String getCode()
Returns the token code.- Returns:
- The Code of the token.
-
setCode
public void setCode(String code)
Sets the token code.- Parameters:
code- The code of the token.
-
getCreationDate
public Date getCreationDate()
Returns the creation date of the token.- Returns:
- The creation date.
-
setCreationDate
public void setCreationDate(Date creationDate)
Sets the creation date of the token.- Parameters:
creationDate- The creation date.
-
getExpirationDate
public Date getExpirationDate()
Returns the expiration date of the token.- Returns:
- The expiration date.
-
setExpirationDate
public void setExpirationDate(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.
-
getReferenceId
public String getReferenceId()
Gets reference id- Returns:
- reference id
-
setReferenceId
public void setReferenceId(String referenceId)
Sets reference id- Parameters:
referenceId- reference id
-
getStatusListIndex
public Integer getStatusListIndex()
Gets status list index- Returns:
- status list index
-
setStatusListIndex
public void setStatusListIndex(Integer statusListIndex)
Sets status list index- Parameters:
statusListIndex- status list index
-
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.
-
getX5ts256
public String getX5ts256()
-
setX5ts256
public void setX5ts256(String x5ts256)
-
getDpop
public String getDpop()
-
setDpop
public void setDpop(String dpop)
-
getSessionDn
public String getSessionDn()
-
setSessionDn
public void setSessionDn(String sessionDn)
-
isDeletable
public Boolean isDeletable()
- Specified by:
isDeletablein interfaceio.jans.orm.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.
-
-