class Cerberus::CerberusClientToken

Object to hold the Cerberus client token credentials and check for expiration and refresh

Attributes

authToken[R]
cacheLifetimeSec[R]

Public Class Methods

new(authToken, cacheLifetimeSec, policiesArray) click to toggle source

Init with an authToken. Expired will be true approximately cacheLifetimeSec seconds from when new is called. Optionally, set the cache lifetime. For now this is primarily used for testing.

# File lib/cerberus/cerberus_client_token.rb, line 19
def initialize(authToken, cacheLifetimeSec, policiesArray)
  @createTime = Time.now
  @cacheLifetimeSec = cacheLifetimeSec
  @policies = policiesArray
  CerberusUtils::Log.instance.debug("AwsCredentials cache lifetime set to #{@cacheLifetimeSec} seconds")
  CerberusUtils::Log.instance.debug("AwsCredentials policies: #{@policies.join(", ")}")
  @authToken = authToken
end

Public Instance Methods

expired?() click to toggle source

Return true if cache lifetime has expired This object doesn't enforce expiration - someone else can worry about making sure the credentials are valid

# File lib/cerberus/cerberus_client_token.rb, line 32
def expired?
  ((@createTime + @cacheLifetimeSec) <=> Time.now) == -1
end