Class: RubyAem::Resources::CertificateChain
- Inherits:
-
Object
- Object
- RubyAem::Resources::CertificateChain
- Defined in:
- lib/ruby_aem/resources/certificate_chain.rb
Overview
AEM class contains API calls related to managing a certificate chain within AEM Authorizable Keystore.
Instance Method Summary collapse
-
#create(certificate_chain_file_path, private_key_file_path) ⇒ Object
Create is an alias to import.
-
#delete ⇒ Object
Delete a specific certificate chain by its associated private key alias.
-
#exists ⇒ Object
Check if certificate chain exists in the Authorizable Keystore.
-
#import(certificate_chain_file_path, private_key_file_path) ⇒ Object
Import a certificate file into AEM Truststore.
-
#import_wait_until_ready(certificate_chain_file_path, private_key_file_path, opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Import a certificate file into AEM Truststore and wait until the certificate is imported.
-
#initialize(client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id) ⇒ Object
constructor
Initialise certificate chain.
Constructor Details
#initialize(client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id) ⇒ Object
Initialise certificate chain
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_aem/resources/certificate_chain.rb', line 32 def initialize(client, private_key_alias, keystore_intermediate_path, ) @client = client @truststore = RubyAem::Resources::Truststore.new(client) @private_key_alias = private_key_alias @call_params = { private_key_alias: private_key_alias, keystore_intermediate_path: keystore_intermediate_path, keystore_authorizable_id: } @call_params[:keystore_intermediate_path] = RubyAem::Swagger.path(@call_params[:keystore_intermediate_path]) end |
Instance Method Details
#create(certificate_chain_file_path, private_key_file_path) ⇒ Object
Create is an alias to import. Create is needed to satisfy Puppet resource ‘ensure`.
51 52 53 |
# File 'lib/ruby_aem/resources/certificate_chain.rb', line 51 def create(certificate_chain_file_path, private_key_file_path) import(certificate_chain_file_path, private_key_file_path) end |
#delete ⇒ Object
Delete a specific certificate chain by its associated private key alias.
69 70 71 72 73 74 |
# File 'lib/ruby_aem/resources/certificate_chain.rb', line 69 def delete result = exists raise RubyAem::Error.new('Certificate chain not found', result) if result.data == false @client.call(self.class, __callee__.to_s, @call_params) end |
#exists ⇒ Object
Check if certificate chain exists in the Authorizable Keystore.
79 80 81 |
# File 'lib/ruby_aem/resources/certificate_chain.rb', line 79 def exists @client.call(self.class, __callee__.to_s, @call_params) end |
#import(certificate_chain_file_path, private_key_file_path) ⇒ Object
Import a certificate file into AEM Truststore.
60 61 62 63 64 |
# File 'lib/ruby_aem/resources/certificate_chain.rb', line 60 def import(certificate_chain_file_path, private_key_file_path) @call_params[:file_path_certificate] = certificate_chain_file_path @call_params[:file_path_private_key] = private_key_file_path @client.call(self.class, __callee__.to_s, @call_params) end |
#import_wait_until_ready(certificate_chain_file_path, private_key_file_path, opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Import a certificate file into AEM Truststore and wait until the certificate is imported.
-
_retries: retries library’s options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ruby_aem/resources/certificate_chain.rb', line 90 def import_wait_until_ready( certificate_chain_file_path, private_key_file_path, opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } } ) opts[:_retries] ||= {} opts[:_retries][:max_tries] ||= 30 opts[:_retries][:base_sleep_seconds] ||= 2 opts[:_retries][:max_sleep_seconds] ||= 2 # ensure integer retries setting (Puppet 3 passes numeric string) opts[:_retries][:max_tries] = opts[:_retries][:max_tries].to_i opts[:_retries][:base_sleep_seconds] = opts[:_retries][:base_sleep_seconds].to_i opts[:_retries][:max_sleep_seconds] = opts[:_retries][:max_sleep_seconds].to_i result = import(certificate_chain_file_path, private_key_file_path) with_retries(max_tries: opts[:_retries][:max_tries], base_sleep_seconds: opts[:_retries][:base_sleep_seconds], max_sleep_seconds: opts[:_retries][:max_sleep_seconds]) { |retries_count| check_result = exists puts format('Import check #%<retries_count>d: %<check_result_data>s - %<check_result_message>s', retries_count: retries_count, check_result_data: check_result.data, check_result_message: check_result.) raise StandardError.new(check_result.) if check_result.data == false } result end |