Class: OCI::Auth::SecurityTokenContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/auth/security_token_container.rb

Overview

A container class which holds the raw token retrieved from Auth Service and its decoded equivalent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(security_token, key_pair: nil) ⇒ SecurityTokenContainer

Returns a new instance of SecurityTokenContainer.



14
15
16
17
18
# File 'lib/oci/auth/security_token_container.rb', line 14

def initialize(security_token, key_pair: nil)
  @key_pair = key_pair
  @security_token = security_token
  @jwt = JWT.decode(@security_token, nil, false)
end

Instance Attribute Details

#jwtObject (readonly)

Returns the value of attribute jwt.



11
12
13
# File 'lib/oci/auth/security_token_container.rb', line 11

def jwt
  @jwt
end

#security_tokenObject (readonly)

Returns the value of attribute security_token.



12
13
14
# File 'lib/oci/auth/security_token_container.rb', line 12

def security_token
  @security_token
end

Instance Method Details

#token_valid?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/oci/auth/security_token_container.rb', line 20

def token_valid?
  expiration_epoch_seconds = @jwt[0]['exp']
  expiration_epoch_seconds > Time.now.to_i
end