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
,LogoutStatusJwt
,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:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractToken
(int lifeTime) Creates and initializes the values of an abstract token.protected
AbstractToken
(String code, Date creationDate, Date expirationDate) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks whether the token has expired and if true, marks itself as expired.void
checkExpired
(Date now) Checks whether the token has expired and if true, marks itself as expired.getCode()
Returns the token code.Returns the creation date of the token.getDpop()
Returns the expiration date of the token.int
Returns the lifetime in seconds of the token.static String
getJti()
Gets reference idGets status list indexint
getTtl()
boolean
Returntrue
if the token has expired.boolean
Returnstrue
if the token has been revoked.boolean
isValid()
Checks whether a token is valid, it is valid if it is not revoked and not expired.void
void
Sets the token code.void
setCreationDate
(Date creationDate) Sets the creation date of the token.void
setDeletable
(boolean deletable) void
void
setExpirationDate
(Date expirationDate) Sets the expiration date of the token.void
setExpired
(boolean expired) Sets the value of the expired flag to indicate whether the token has expired.void
setReferenceId
(String referenceId) Sets reference idvoid
setRevoked
(boolean revoked) Sets the value of the revoked flag to indicate whether the token has been revoked.void
setSessionDn
(String sessionDn) void
setStatusListIndex
(Integer statusListIndex) Sets status list indexvoid
setX5ts256
(String x5ts256)
-
Constructor Details
-
AbstractToken
protected AbstractToken(int lifeTime) Creates and initializes the values of an abstract token.- Parameters:
lifeTime
- The life time of the token.
-
AbstractToken
-
-
Method Details
-
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
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
true
if the token is valid.
-
getCode
Returns the token code.- Returns:
- The Code of the token.
-
setCode
Sets the token code.- Parameters:
code
- The code of the token.
-
getCreationDate
Returns the creation date of the token.- Returns:
- The creation date.
-
setCreationDate
Sets the creation date of the token.- Parameters:
creationDate
- The creation date.
-
getExpirationDate
Returns the expiration date of the token.- Returns:
- The expiration date.
-
setExpirationDate
Sets the expiration date of the token.- Parameters:
expirationDate
- The expiration date.
-
isRevoked
public boolean isRevoked()Returnstrue
if the token has been revoked.- Returns:
true
if 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
Gets reference id- Returns:
- reference id
-
setReferenceId
Sets reference id- Parameters:
referenceId
- reference id
-
getJti
-
setJti
-
getStatusListIndex
Gets status list index- Returns:
- status list index
-
setStatusListIndex
Sets status list index- Parameters:
statusListIndex
- status list index
-
isExpired
public boolean isExpired()Returntrue
if the token has expired.- Returns:
true
if 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
-
setX5ts256
-
getDpop
-
setDpop
-
getSessionDn
-
setSessionDn
-
isDeletable
- Specified by:
isDeletable
in 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.
-
getHash
-