Class AccessTokenSecret
java.lang.Object
org.gcube.common.security.secrets.Secret
org.gcube.common.security.secrets.AccessTokenSecret
public class AccessTokenSecret
extends org.gcube.common.security.secrets.Secret
The secret of an access token of the D4Science IAM, exchanged for a token of a Context.
The token of the Context is renewed from the original access token when it expires, as long as
the original access token has not expired too. Once both have expired the secret stays expired:
isExpired() returns true and the expired token of the Context is used.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final longThe interval of time expressed in milliseconds used as guard to refresh the token before that it expires: a token that expires within this interval is considered expired. -
Constructor Summary
ConstructorsConstructorDescriptionAccessTokenSecret(String accessToken, String context) Creates the secret exchanging the access token for a token of the Context. -
Method Summary
-
Field Details
-
TOLERANCE
public static final long TOLERANCEThe interval of time expressed in milliseconds used as guard to refresh the token before that it expires: a token that expires within this interval is considered expired. TimeUnit has been used to in place of just using the number to have a clearer code -
initialised
protected boolean initialised
-
-
Constructor Details
-
AccessTokenSecret
Creates the secret exchanging the access token for a token of the Context.- Parameters:
accessToken- the encoded access tokencontext- the Context
-
-
Method Details
-
getOwner
public org.gcube.common.security.Owner getOwner()- Specified by:
getOwnerin classorg.gcube.common.security.secrets.Secret
-
priority
public int priority()- Specified by:
priorityin classorg.gcube.common.security.secrets.Secret
-
getContext
- Specified by:
getContextin classorg.gcube.common.security.secrets.Secret
-
getHTTPAuthorizationHeaders
- Specified by:
getHTTPAuthorizationHeadersin classorg.gcube.common.security.secrets.Secret
-
isValid
public boolean isValid()- Specified by:
isValidin classorg.gcube.common.security.secrets.Secret
-
isExpired
public boolean isExpired()Tells whether the token of the Context expires withinTOLERANCE.- Specified by:
isExpiredin classorg.gcube.common.security.secrets.Secret- Returns:
truewhen the token of the Context is expired or about to expire
-