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 Details

    • TOLERANCE

      public static final long TOLERANCE
      The 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

      public AccessTokenSecret(String accessToken, String context)
      Creates the secret exchanging the access token for a token of the Context.
      Parameters:
      accessToken - the encoded access token
      context - the Context
  • Method Details

    • getOwner

      public org.gcube.common.security.Owner getOwner()
      Specified by:
      getOwner in class org.gcube.common.security.secrets.Secret
    • priority

      public int priority()
      Specified by:
      priority in class org.gcube.common.security.secrets.Secret
    • getContext

      public String getContext()
      Specified by:
      getContext in class org.gcube.common.security.secrets.Secret
    • getHTTPAuthorizationHeaders

      public Map<String,String> getHTTPAuthorizationHeaders()
      Specified by:
      getHTTPAuthorizationHeaders in class org.gcube.common.security.secrets.Secret
    • isValid

      public boolean isValid()
      Specified by:
      isValid in class org.gcube.common.security.secrets.Secret
    • isExpired

      public boolean isExpired()
      Tells whether the token of the Context expires within TOLERANCE.
      Specified by:
      isExpired in class org.gcube.common.security.secrets.Secret
      Returns:
      true when the token of the Context is expired or about to expire