Class: RubyAem::Resources::Truststore
- Inherits:
-
Object
- Object
- RubyAem::Resources::Truststore
- Defined in:
- lib/ruby_aem/resources/truststore.rb
Overview
AEM class contains API calls related to managing the AEM Truststore.
Instance Method Summary collapse
-
#create(password) ⇒ Object
Create AEM Truststore.
-
#delete ⇒ Object
Delete AEM Truststore.
-
#download(file_path) ⇒ Object
Download the AEM Truststore to a specified directory.
-
#exists ⇒ Object
Check if AEM Truststore exists.
-
#info ⇒ Object
Retrieve AEM Truststore info.
-
#initialize(client) ⇒ Object
constructor
Initialise Truststore resource.
-
#read(file_path, password) ⇒ Object
Read the content of Truststore file on filesystem and convert it to PKCS12 Truststore object.
-
#upload(file_path, opts = { force: true }) ⇒ Object
Upload a truststore PKCS12 file.
-
#upload_wait_until_ready(file_path, opts = { force: true, _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Upload AEM Truststore and wait until the certificate is uploaded.
Constructor Details
#initialize(client) ⇒ Object
Initialise Truststore resource.
28 29 30 31 |
# File 'lib/ruby_aem/resources/truststore.rb', line 28 def initialize(client) @client = client @call_params = {} end |
Instance Method Details
#create(password) ⇒ Object
Create AEM Truststore.
37 38 39 40 |
# File 'lib/ruby_aem/resources/truststore.rb', line 37 def create(password) @call_params[:password] = password @client.call(self.class, __callee__.to_s, @call_params) end |
#delete ⇒ Object
Delete AEM Truststore.
82 83 84 |
# File 'lib/ruby_aem/resources/truststore.rb', line 82 def delete @client.call(self.class, __callee__.to_s, @call_params) end |
#download(file_path) ⇒ Object
Download the AEM Truststore to a specified directory.
55 56 57 58 59 60 |
# File 'lib/ruby_aem/resources/truststore.rb', line 55 def download( file_path ) @call_params[:file_path] = file_path @client.call(self.class, __callee__.to_s, @call_params) end |
#exists ⇒ Object
Check if AEM Truststore exists.
89 90 91 |
# File 'lib/ruby_aem/resources/truststore.rb', line 89 def exists @client.call(self.class, __callee__.to_s, @call_params) end |
#info ⇒ Object
Retrieve AEM Truststore info.
96 97 98 |
# File 'lib/ruby_aem/resources/truststore.rb', line 96 def info @client.call(self.class, __callee__.to_s, @call_params) end |
#read(file_path, password) ⇒ Object
Read the content of Truststore file on filesystem and convert it to PKCS12 Truststore object.
46 47 48 49 |
# File 'lib/ruby_aem/resources/truststore.rb', line 46 def read(file_path, password) truststore_raw = File.read file_path OpenSSL::PKCS12.new(truststore_raw, password) end |
#upload(file_path, opts = { force: true }) ⇒ Object
Upload a truststore PKCS12 file.
-
force: if true then AEM Truststore will be overwritten if already exists
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ruby_aem/resources/truststore.rb', line 68 def upload( file_path, opts = { force: true } ) @call_params[:file_path] = file_path @call_params = @call_params.merge(opts) @client.call(self.class, __callee__.to_s, @call_params) end |
#upload_wait_until_ready(file_path, opts = { force: true, _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Upload AEM Truststore and wait until the certificate is uploaded.
-
_retries: retries library’s options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ruby_aem/resources/truststore.rb', line 106 def upload_wait_until_ready( file_path, opts = { force: true, _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 = upload(file_path, force: opts[:force]) 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('Upload 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 |