Class: Vcert::Connection
- Inherits:
-
Object
- Object
- Vcert::Connection
- Defined in:
- lib/vcert.rb
Overview
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(url: nil, user: nil, password: nil, cloud_token: nil, trust_bundle: nil, fake: false) ⇒ Connection
constructor
A new instance of Connection.
- #policy(zone) ⇒ Policy
- #renew(*args) ⇒ Object
- #request(zone, request) ⇒ Object
- #request_and_retrieve(req, zone, timeout: TIMEOUT) ⇒ Certificate
- #retrieve(request) ⇒ Certificate
- #retrieve_loop(req, timeout: TIMEOUT) ⇒ Object
- #revoke(*args) ⇒ Object
- #zone_configuration(zone) ⇒ ZoneConfiguration
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
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
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
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
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
57 58 59 |
# File 'lib/vcert.rb', line 57 def zone_configuration(zone) @conn.zone_configuration(zone) end |