123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Crypt::KMS::Azure::AccessToken Private

Relationships & Source Files
Inherits: Object
Defined in: lib/mongo/crypt/kms/azure/access_token.rb

Overview

::Mongo::Crypt::KMS::Azure access token for temporary credentials.

Class Method Summary

Instance Attribute Summary

Constructor Details

.new(access_token, expires_in) ⇒ AccessToken

Creates an ::Mongo::Crypt::KMS::Azure access token object.

Parameters:

[ GitHub ]

  
# File 'lib/mongo/crypt/kms/azure/access_token.rb', line 35

def initialize(access_token, expires_in)
  @access_token = access_token
  @expires_in = expires_in
  @expires_at = Time.now.to_i + @expires_in
end

Instance Attribute Details

#access_tokenString (readonly)

Returns:

[ GitHub ]

  
# File 'lib/mongo/crypt/kms/azure/access_token.rb', line 26

attr_reader :access_token

#expired?true | false (readonly)

Checks if the access token is expired.

The access token is considered expired if it is within 60 seconds of its expiration time.

Returns:

  • (true | false)

    Whether the access token is expired.

[ GitHub ]

  
# File 'lib/mongo/crypt/kms/azure/access_token.rb', line 47

def expired?
  Time.now.to_i >= @expires_at - 60
end

#expires_inInteger (readonly)

Returns:

[ GitHub ]

  
# File 'lib/mongo/crypt/kms/azure/access_token.rb', line 29

attr_reader :expires_in