Class: Vcert::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/vcert.rb

Overview

DEPRECATED Please use <tt>VenafiConnection<tt> instead.

This class provides an easy way to configure and retrieve a connector for a Venafi platform. Usage: TPP:

Connection.new url: TPP_URL, user: TPP_USER, password: TPP_PASSWORD, trust_bundle: TRUST_BUNDLE

CLoud:

Connection.new token: CLOUD_API_KEY

Direct Known Subclasses

VenafiConnection

Instance Method Summary collapse

Constructor Details

#initialize(url: nil, user: nil, password: nil, cloud_token: nil, trust_bundle: nil, fake: false) ⇒ Connection

Returns a new instance of Connection.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vcert.rb', line 26

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

Instance Method Details

#policy(zone) ⇒ Policy

Parameters:

  • zone (String)

Returns:



63
64
65
# File 'lib/vcert.rb', line 63

def policy(zone)
  @conn.policy(zone)
end

#renew(*args) ⇒ Object



67
68
69
# File 'lib/vcert.rb', line 67

def renew(*args)
  @conn.renew(*args)
end

#request(zone, request) ⇒ Object

Parameters:



41
42
43
# File 'lib/vcert.rb', line 41

def request(zone, request)
  @conn.request(zone, request)
end

#request_and_retrieve(req, zone, timeout: TIMEOUT) ⇒ Certificate

Parameters:

  • req (Request)
  • zone (String)
  • timeout (Integer) (defaults to: TIMEOUT)

Returns:



75
76
77
78
79
# File 'lib/vcert.rb', line 75

def request_and_retrieve(req, zone, timeout: TIMEOUT)
  LOG.info("#{VCERT_PREFIX} Requesting and retrieving Certificate: [#{req}], [#{zone}]")
  request zone, req
  retrieve_loop(req, timeout: timeout)
end

#retrieve(request) ⇒ Certificate

Parameters:

Returns:



47
48
49
# File 'lib/vcert.rb', line 47

def retrieve(request)
  @conn.retrieve(request)
end

#retrieve_loop(req, timeout: TIMEOUT) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/vcert.rb', line 81

def retrieve_loop(req, timeout: TIMEOUT)
  t = Time.new + timeout
  loop do
    if Time.new > t
      LOG.info("#{VCERT_PREFIX} Waiting certificate #{req.id}")
      break
    end
    certificate = @conn.retrieve(req)
    return certificate unless certificate.nil?
    sleep 10
  end
  nil
end

#revoke(*args) ⇒ Object



51
52
53
# File 'lib/vcert.rb', line 51

def revoke(*args)
  @conn.revoke(*args)
end

#zone_configuration(zone) ⇒ ZoneConfiguration

Parameters:

  • zone (String)

Returns:



57
58
59
# File 'lib/vcert.rb', line 57

def zone_configuration(zone)
  @conn.zone_configuration(zone)
end