Class AuthToken
- java.lang.Object
-
- com.helger.security.authentication.result.AuthToken
-
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,IAuthToken
@NotThreadSafe public final class AuthToken extends Object implements IAuthToken
Default implementation of theIAuthTokeninterface.- Author:
- Philip Helger
-
-
Field Summary
-
Fields inherited from interface com.helger.security.authentication.result.IAuthToken
EXPIRATION_SECONDS_INFINITE
-
-
Constructor Summary
Constructors Constructor Description AuthToken(IAuthIdentification aIdentification, int nExpirationSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)LocalDateTimegetCreationDate()LocalDateTimegetExpirationDate()Get the date time when this token will expire.intgetExpirationSeconds()StringgetID()IAuthIdentificationgetIdentification()LocalDateTimegetLastAccessDate()inthashCode()booleanisExpirationPossible()Check if this token can expire (expiration seconds > 0) or not (expiration seconds = 0).booleanisExpired()Check if the token is expired.StringtoString()
-
-
-
Constructor Detail
-
AuthToken
public AuthToken(@Nonnull IAuthIdentification aIdentification, @Nonnegative int nExpirationSeconds)
-
-
Method Detail
-
getID
@Nonnull public String getID()
- Specified by:
getIDin interfaceIAuthToken- Specified by:
getIDin interfacecom.helger.commons.id.IHasID<String>- Returns:
- The secret key token representing a session of a subject. Never
null.
-
getIdentification
@Nonnull public IAuthIdentification getIdentification()
- Specified by:
getIdentificationin interfaceIAuthToken- Returns:
- The underlying identification object. Never
null.
-
getCreationDate
@Nonnull public LocalDateTime getCreationDate()
- Specified by:
getCreationDatein interfaceIAuthToken- Returns:
- The date and time when the token was created. Never
null.
-
getLastAccessDate
@Nonnull public LocalDateTime getLastAccessDate()
- Specified by:
getLastAccessDatein interfaceIAuthToken- Returns:
- The date and time when the token was last accessed. If the token
was never accessed before, the creation date time is returned.
Never
null.
-
getExpirationSeconds
@Nonnegative public int getExpirationSeconds()
- Specified by:
getExpirationSecondsin interfaceIAuthToken- Returns:
- The expiration seconds. Always ≥ 0. A value of 0 means no expiration.
- See Also:
IAuthToken.isExpirationPossible()
-
isExpirationPossible
public boolean isExpirationPossible()
Description copied from interface:IAuthTokenCheck if this token can expire (expiration seconds > 0) or not (expiration seconds = 0).- Specified by:
isExpirationPossiblein interfaceIAuthToken- Returns:
trueif this token can expire,falseotherwise.- See Also:
IAuthToken.getExpirationSeconds()
-
getExpirationDate
@Nullable public LocalDateTime getExpirationDate()
Get the date time when this token will expire. This date time changes every time the last access is updated.- Specified by:
getExpirationDatein interfaceIAuthToken- Returns:
- The expiration date and time or
nullif this token cannot expire. - See Also:
isExpirationPossible()
-
isExpired
public boolean isExpired()
Description copied from interface:IAuthTokenCheck if the token is expired. Expired tokens are considered invalid.- Specified by:
isExpiredin interfaceIAuthToken- Returns:
trueif the token is already expired,falseif the token is still valid.
-
-