ruby_aem 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,138 @@
1
+ # Copyright 2016-2017 Shine Solutions
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'openssl'
16
+ require 'retries'
17
+ require 'tempfile'
18
+ require 'ruby_aem/error'
19
+
20
+ module RubyAem
21
+ module Resources
22
+ # AEM class contains API calls related to managing the AEM Truststore.
23
+ class Truststore
24
+ # Initialise Truststore resource.
25
+ #
26
+ # @param client RubyAem::Client
27
+ # @return new RubyAem::Resources::Truststore instance
28
+ def initialize(client)
29
+ @client = client
30
+ @call_params = {}
31
+ end
32
+
33
+ # Create AEM Truststore.
34
+ #
35
+ # @param password Password for AEM Truststore
36
+ # @return RubyAem::Result
37
+ def create(password)
38
+ @call_params[:password] = password
39
+ @client.call(self.class, __callee__.to_s, @call_params)
40
+ end
41
+
42
+ # Read the content of Truststore file on filesystem
43
+ # and convert it to PKCS12 Truststore object.
44
+ #
45
+ # @param file_path path to Truststore file
46
+ def read(file_path, password)
47
+ truststore_raw = File.read file_path
48
+ OpenSSL::PKCS12.new(truststore_raw, password)
49
+ end
50
+
51
+ # Download the AEM Truststore to a specified directory.
52
+ #
53
+ # @param file_path the directory where the Truststore will be downloaded to
54
+ # @return RubyAem::Result
55
+ def download(
56
+ file_path
57
+ )
58
+ @call_params[:file_path] = file_path
59
+ @client.call(self.class, __callee__.to_s, @call_params)
60
+ end
61
+
62
+ # Upload a truststore PKCS12 file.
63
+ #
64
+ # @param file_path local file path to truststore PKCS12 file
65
+ # @param opts optional parameters:
66
+ # - force: if true then AEM Truststore will be overwritten if already exists
67
+ # @return RubyAem::Result
68
+ def upload(
69
+ file_path,
70
+ opts = {
71
+ force: true
72
+ }
73
+ )
74
+ @call_params[:file_path] = file_path
75
+ @call_params = @call_params.merge(opts)
76
+ @client.call(self.class, __callee__.to_s, @call_params)
77
+ end
78
+
79
+ # Delete AEM Truststore.
80
+ #
81
+ # @return RubyAem::Result
82
+ def delete
83
+ @client.call(self.class, __callee__.to_s, @call_params)
84
+ end
85
+
86
+ # Check if AEM Truststore exists.
87
+ #
88
+ # @return RubyAem::Result
89
+ def exists
90
+ @client.call(self.class, __callee__.to_s, @call_params)
91
+ end
92
+
93
+ # Retrieve AEM Truststore info.
94
+ #
95
+ # @return RubyAem::Result
96
+ def info
97
+ @client.call(self.class, __callee__.to_s, @call_params)
98
+ end
99
+
100
+ # Upload AEM Truststore and wait until the certificate is uploaded.
101
+ #
102
+ # @param file_path local file path to truststore PKCS12 file
103
+ # @param opts optional parameters:
104
+ # - _retries: retries library's options (http://www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_tries, base_sleep_seconds, max_sleep_seconds
105
+ # @return RubyAem::Result
106
+ def upload_wait_until_ready(
107
+ file_path,
108
+ opts = {
109
+ force: true,
110
+ _retries: {
111
+ max_tries: 30,
112
+ base_sleep_seconds: 2,
113
+ max_sleep_seconds: 2
114
+ }
115
+ }
116
+ )
117
+ opts[:_retries] ||= {}
118
+ opts[:_retries][:max_tries] ||= 30
119
+ opts[:_retries][:base_sleep_seconds] ||= 2
120
+ opts[:_retries][:max_sleep_seconds] ||= 2
121
+
122
+ # ensure integer retries setting (Puppet 3 passes numeric string)
123
+ opts[:_retries][:max_tries] = opts[:_retries][:max_tries].to_i
124
+ opts[:_retries][:base_sleep_seconds] = opts[:_retries][:base_sleep_seconds].to_i
125
+ opts[:_retries][:max_sleep_seconds] = opts[:_retries][:max_sleep_seconds].to_i
126
+
127
+ result = upload(file_path, force: opts[:force])
128
+
129
+ 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|
130
+ check_result = exists
131
+ 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.message)
132
+ raise StandardError.new(check_result.message) if check_result.data == false
133
+ }
134
+ result
135
+ end
136
+ end
137
+ end
138
+ end
@@ -67,6 +67,8 @@ module RubyAem
67
67
  'AEM Password Reset Activator'
68
68
  when 'com.shinesolutions.healthcheck.hc.impl.ActiveBundleHealthCheck'
69
69
  'AEM Health Check Servlet'
70
+ when 'com.adobe.granite.auth.saml.SamlAuthenticationHandler.config'
71
+ 'Adobe Granite SAML Authentication Handler'
70
72
  end
71
73
  end
72
74
  end
data/lib/ruby_aem.rb CHANGED
@@ -14,7 +14,10 @@
14
14
 
15
15
  require 'ruby_aem/client'
16
16
  require 'ruby_aem/resources/aem'
17
+ require 'ruby_aem/resources/authorizable_keystore'
17
18
  require 'ruby_aem/resources/bundle'
19
+ require 'ruby_aem/resources/certificate'
20
+ require 'ruby_aem/resources/certificate_chain'
18
21
  require 'ruby_aem/resources/config_property'
19
22
  require 'ruby_aem/resources/flush_agent'
20
23
  require 'ruby_aem/resources/group'
@@ -24,7 +27,9 @@ require 'ruby_aem/resources/path'
24
27
  require 'ruby_aem/resources/replication_agent'
25
28
  require 'ruby_aem/resources/outbox_replication_agent'
26
29
  require 'ruby_aem/resources/reverse_replication_agent'
30
+ require 'ruby_aem/resources/saml'
27
31
  require 'ruby_aem/resources/repository'
32
+ require 'ruby_aem/resources/truststore'
28
33
  require 'ruby_aem/resources/user'
29
34
  require 'swagger_aem'
30
35
  require 'yaml'
@@ -104,6 +109,24 @@ module RubyAem
104
109
  RubyAem::Resources::Bundle.new(@client, name)
105
110
  end
106
111
 
112
+ # Create a certificate instance.
113
+ #
114
+ # @param serial_number the certificate's serial number
115
+ # @return new RubyAem::Resources::Certificate instance
116
+ def certificate(serial_number)
117
+ RubyAem::Resources::Certificate.new(@client, serial_number)
118
+ end
119
+
120
+ # # Create a certificate chain instance.
121
+ # #
122
+ # @param private_key_alias Alias of the private key associated to this certificate chain
123
+ # @param keystore_intermediate_path AEM User home path
124
+ # @param keystore_authorizable_id AEM User id
125
+ # # @return new RubyAem::Resources::CertificateChain instance
126
+ def certificate_chain(private_key_alias, keystore_intermediate_path, keystore_authorizable_id)
127
+ RubyAem::Resources::CertificateChain.new(@client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id)
128
+ end
129
+
107
130
  # Create a config property instance.
108
131
  #
109
132
  # @param name the property's name
@@ -132,6 +155,13 @@ module RubyAem
132
155
  RubyAem::Resources::Group.new(@client, path, name)
133
156
  end
134
157
 
158
+ # Create a Keystore instance for given authorizable id.
159
+ #
160
+ # @return new RubyAem::Resources::AuhtorizableKeystore instance
161
+ def authorizable_keystore(intermediate_path, authorizable_id)
162
+ RubyAem::Resources::AuthorizableKeystore.new(@client, intermediate_path, authorizable_id)
163
+ end
164
+
135
165
  # Create a node instance.
136
166
  #
137
167
  # @param path the path to the node, e.g. /apps/system/
@@ -193,6 +223,20 @@ module RubyAem
193
223
  RubyAem::Resources::Repository.new(@client)
194
224
  end
195
225
 
226
+ # Create a Saml instance.
227
+ #
228
+ # @return new RubyAem::Resources::Saml instance
229
+ def saml
230
+ RubyAem::Resources::Saml.new(@client)
231
+ end
232
+
233
+ # Create a Truststore instance.
234
+ #
235
+ # @return new RubyAem::Resources::Truststore instance
236
+ def truststore
237
+ RubyAem::Resources::Truststore.new(@client)
238
+ end
239
+
196
240
  # Create a user instance.
197
241
  #
198
242
  # @param path the path to user node, e.g. /home/users/s/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_aem
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shine Solutions
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-07-26 00:00:00.000000000 Z
12
+ date: 2018-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 2.1.0
62
+ version: 2.2.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 2.1.0
69
+ version: 2.2.0
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,10 @@ files:
114
114
  - lib/ruby_aem/handlers/simple.rb
115
115
  - lib/ruby_aem/handlers/xml.rb
116
116
  - lib/ruby_aem/resources/aem.rb
117
+ - lib/ruby_aem/resources/authorizable_keystore.rb
117
118
  - lib/ruby_aem/resources/bundle.rb
119
+ - lib/ruby_aem/resources/certificate.rb
120
+ - lib/ruby_aem/resources/certificate_chain.rb
118
121
  - lib/ruby_aem/resources/config_property.rb
119
122
  - lib/ruby_aem/resources/flush_agent.rb
120
123
  - lib/ruby_aem/resources/group.rb
@@ -125,6 +128,8 @@ files:
125
128
  - lib/ruby_aem/resources/replication_agent.rb
126
129
  - lib/ruby_aem/resources/repository.rb
127
130
  - lib/ruby_aem/resources/reverse_replication_agent.rb
131
+ - lib/ruby_aem/resources/saml.rb
132
+ - lib/ruby_aem/resources/truststore.rb
128
133
  - lib/ruby_aem/resources/user.rb
129
134
  - lib/ruby_aem/response.rb
130
135
  - lib/ruby_aem/result.rb
@@ -141,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
146
  requirements:
142
147
  - - ">="
143
148
  - !ruby/object:Gem::Version
144
- version: '2.2'
149
+ version: '2.3'
145
150
  required_rubygems_version: !ruby/object:Gem::Requirement
146
151
  requirements:
147
152
  - - ">="