T - AccessToken typepublic class TemporalAccessToken<T extends AccessToken> extends Object
| Constructor and Description |
|---|
TemporalAccessToken(T token,
java.time.Instant validSinceMoment)
Constructs temporal access token wrapper using the supplied moment as first moment of validity
for the token and defaulting to ChornoUnit.SECONDS as reference temporal unit for temporal
properties such as expires-in.
|
TemporalAccessToken(T token,
java.time.Instant validSinceMoment,
java.time.temporal.TemporalUnit temporalUnit)
Constructs temporal access token wrappers considering the supplied moment as initial moment
of the validity of the token and using the supplied temporal unit as reference unit for
temporal operations including operands such as the expires_in property.
|
| Modifier and Type | Method and Description |
|---|---|
static <T extends AccessToken> |
create(T token)
Static object factory defaulting the initial moment of token validitiy to the current moment.
|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isExpired()
Checks if this token has expired.
|
static <T extends AccessToken> |
isExpired(T token,
java.time.Instant since,
java.time.temporal.TemporalUnit expireInUnits)
Static check for tokens whether they are still valid if they have been
active since the provided moment.
|
T |
token()
Returns the wrapped token instance
|
String |
toString() |
java.time.Duration |
ttl()
Returns the time-to-live duration in which the token is valid.
|
java.time.Duration |
ttlLeft()
Returns the remaining time-to-live until this token expires as duration.
|
long |
ttlLeft(java.time.temporal.ChronoUnit unit)
Returns the remaining time-to-live until this token expires, as long value
in the requested temporal units.
|
java.time.temporal.TemporalUnit |
ttlUnit()
Returns the reference temporal unit used in this wrapper.
|
TemporalAccessToken<T> |
ttlUnit(java.time.temporal.TemporalUnit unit)
Sets the reference temporal unit used in this wrapper and returns its instance for method
chaining.
|
java.time.Instant |
validSince()
Returns the java.time.Instant since the token is valid (was issued)
|
public TemporalAccessToken(T token, java.time.Instant validSinceMoment, java.time.temporal.TemporalUnit temporalUnit)
token - validSinceMoment - temporalUnit - public TemporalAccessToken(T token, java.time.Instant validSinceMoment)
token - validSinceMoment - public TemporalAccessToken<T> ttlUnit(java.time.temporal.TemporalUnit unit)
public java.time.temporal.TemporalUnit ttlUnit()
public T token()
public java.time.Instant validSince()
public java.time.Duration ttl()
public java.time.Duration ttlLeft()
public long ttlLeft(java.time.temporal.ChronoUnit unit)
unit - public boolean isExpired()
public static <T extends AccessToken> boolean isExpired(T token, java.time.Instant since, java.time.temporal.TemporalUnit expireInUnits)
token - since - expireInUnits - public static <T extends AccessToken> TemporalAccessToken<T> create(T token)
token - Copyright © 2017. All rights reserved.