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

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/crypt/kms/azure/access_token.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Azure access token for temporary credentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, expires_in) ⇒ AccessToken

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates an Azure access token object.

Parameters:

  • access_token (String)

    Azure access token.

  • expires_in (Integer)

    Azure access token expiration time.



35
36
37
38
39
# 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)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Azure access token.

Returns:

  • (String)

    Azure access token.



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

def access_token
  @access_token
end

#expires_inInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Azure access token expiration time.

Returns:

  • (Integer)

    Azure access token expiration time.



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

def expires_in
  @expires_in
end

Instance Method Details

#expired?true | false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.



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

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