Class: Vcert::VenafiConnection

Inherits:
Connection show all
Defined in:
lib/vcert.rb

Overview

This class provides an easy way to configure and retrieve a connector for a Venafi platform. It supports the use of token authentication for TPP, and drops the use of user/password credentials. Usage: TPP:

VenafiConnection.new url: TPP_TOKEN_URL, user: TPPUSER, password: TPPPASSWORD, trust_bundle: TRUST_BUNDLE
VenafiConnection.new url: TPP_TOKEN_URL, access_token: TPP_ACCESS_TOKEN, trust_bundle: TRUST_BUNDLE
VenafiConnection.new url: TPP_TOKEN_URL, refresh_token: TPP_REFRESH_TOKEN, trust_bundle: TRUST_BUNDLE

CLoud:

VenafiConnection.new token: CLOUD_API_KEY

Instance Method Summary collapse

Methods inherited from Connection

#policy, #renew, #request, #request_and_retrieve, #retrieve, #retrieve_loop, #revoke, #zone_configuration

Constructor Details

#initialize(url: nil, access_token: nil, refresh_token: nil, user: nil, password: nil, apikey: nil, trust_bundle: nil, fake: false) ⇒ VenafiConnection

Returns a new instance of VenafiConnection.



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/vcert.rb', line 109

def initialize(url: nil, access_token: nil, refresh_token: nil, user: nil, password: nil, apikey: nil, trust_bundle:nil, fake: false)
  if fake
    @conn = FakeConnection.new
  elsif !apikey.nil?
    @conn = CloudConnection.new url, apikey
  elsif (!access_token.nil? || !refresh_token.nil? || (!user.nil? && !password.nil?)) && !url.nil?
    @conn = TokenConnection.new url, access_token: access_token, refresh_token: refresh_token, user: user,
                                password: password, trust_bundle: trust_bundle
  else
    raise ClientBadDataError, 'Invalid credentials list'
  end
end

Instance Method Details

#get_access_token(authentication: nil) ⇒ Vcert::TokenInfo

Parameters:

Returns:



124
125
126
# File 'lib/vcert.rb', line 124

def get_access_token(authentication: nil)
  @conn.get_access_token authentication: authentication if @conn.is_a?(Vcert::TokenConnection)
end

#refresh_access_tokenVcert::TokenInfo

Returns:



129
130
131
# File 'lib/vcert.rb', line 129

def refresh_access_token
  @conn.refresh_access_token if @conn.is_a?(Vcert::TokenConnection)
end

#revoke_access_tokenObject

Returns [].

Returns:



134
135
136
# File 'lib/vcert.rb', line 134

def revoke_access_token
  @conn.revoke_access_token if @conn.is_a?(Vcert::TokenConnection)
end