ruby_aem 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/conf/spec.yaml +424 -21
- data/lib/ruby_aem/client.rb +13 -2
- data/lib/ruby_aem/handlers/file.rb +14 -1
- data/lib/ruby_aem/handlers/json.rb +102 -2
- data/lib/ruby_aem/handlers/simple.rb +12 -0
- data/lib/ruby_aem/resources/aem.rb +4 -2
- data/lib/ruby_aem/resources/authorizable_keystore.rb +102 -0
- data/lib/ruby_aem/resources/certificate.rb +153 -0
- data/lib/ruby_aem/resources/certificate_chain.rb +119 -0
- data/lib/ruby_aem/resources/config_property.rb +2 -4
- data/lib/ruby_aem/resources/package.rb +1 -1
- data/lib/ruby_aem/resources/path.rb +0 -1
- data/lib/ruby_aem/resources/saml.rb +62 -0
- data/lib/ruby_aem/resources/truststore.rb +138 -0
- data/lib/ruby_aem/swagger.rb +2 -0
- data/lib/ruby_aem.rb +44 -0
- metadata +10 -5
@@ -41,10 +41,12 @@ module RubyAem
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Handle package JSON payload. Result status is determined directly by success field.
|
44
|
+
# NOTE: _response_spec and _call_params are not used in the implementation
|
45
|
+
# of this method, but they are needed for the handler signature.
|
44
46
|
#
|
45
47
|
# @param response HTTP response containing status_code, body, and headers
|
46
|
-
# @param
|
47
|
-
# @param
|
48
|
+
# @param _response_spec response specification as configured in conf/spec.yaml
|
49
|
+
# @param _call_params additional call_params information
|
48
50
|
# @return RubyAem::Result
|
49
51
|
def self.json_package_service(response, _response_spec, _call_params)
|
50
52
|
json = JSON.parse(response.body)
|
@@ -113,5 +115,103 @@ module RubyAem
|
|
113
115
|
result.data = agent_names
|
114
116
|
result
|
115
117
|
end
|
118
|
+
|
119
|
+
# Truststore payload handler, checks for the existence of certificate within
|
120
|
+
# AEM Truststore, identified by cert_alias call parameter.
|
121
|
+
#
|
122
|
+
# @param response HTTP response containing status_code, body, and headers
|
123
|
+
# @param response_spec response specification as configured in conf/spec.yaml
|
124
|
+
# @param call_params API call parameters
|
125
|
+
# @return RubyAem::Result
|
126
|
+
def self.json_certificate_exists(response, response_spec, call_params)
|
127
|
+
truststore_info = response.body
|
128
|
+
|
129
|
+
result = Handlers.simple(response, response_spec, call_params)
|
130
|
+
|
131
|
+
certificate_exists = false
|
132
|
+
truststore_info.aliases.each { |certificate_alias|
|
133
|
+
certificate_exists = true if certificate_alias.serial_number.to_s == call_params[:serial_number].to_s
|
134
|
+
}
|
135
|
+
if certificate_exists == false
|
136
|
+
result.data = false
|
137
|
+
result.message = 'Certificate not found'
|
138
|
+
else
|
139
|
+
result.data = true
|
140
|
+
result.message = 'Certificate exists'
|
141
|
+
end
|
142
|
+
|
143
|
+
result
|
144
|
+
end
|
145
|
+
|
146
|
+
# Authorizable keystore payload handler, checks for the existence of certificate within
|
147
|
+
# AEM Truststore, identified by cert_alias call parameter.
|
148
|
+
#
|
149
|
+
# @param response HTTP response containing status_code, body, and headers
|
150
|
+
# @param response_spec response specification as configured in conf/spec.yaml
|
151
|
+
# @param call_params API call parameters
|
152
|
+
# @return RubyAem::Result
|
153
|
+
def self.json_certificate_chain_exists(response, response_spec, call_params)
|
154
|
+
authorizable_keystore_info = response.body
|
155
|
+
|
156
|
+
result = Handlers.simple(response, response_spec, call_params)
|
157
|
+
|
158
|
+
certificate_chain_exists = false
|
159
|
+
authorizable_keystore_info.aliases.each { |certificate_chain_alias|
|
160
|
+
certificate_chain_exists = true if certificate_chain_alias._alias.to_s == call_params[:private_key_alias].to_s
|
161
|
+
}
|
162
|
+
if certificate_chain_exists == false
|
163
|
+
result.data = false
|
164
|
+
result.message = 'Certificate chain not found'
|
165
|
+
else
|
166
|
+
result.data = true
|
167
|
+
result.message = 'Certificate chain exists'
|
168
|
+
end
|
169
|
+
|
170
|
+
result
|
171
|
+
end
|
172
|
+
|
173
|
+
# Truststore payload handler, checks for exists and aliases properties in
|
174
|
+
# order to identify existence.
|
175
|
+
#
|
176
|
+
# @param response HTTP response containing status_code, body, and headers
|
177
|
+
# @param response_spec response specification as configured in conf/spec.yaml
|
178
|
+
# @param call_params API call parameters
|
179
|
+
# @return RubyAem::Result
|
180
|
+
def self.json_truststore_exists(response, response_spec, call_params)
|
181
|
+
truststore_info = response.body
|
182
|
+
|
183
|
+
result = Handlers.simple(response, response_spec, call_params)
|
184
|
+
|
185
|
+
if truststore_info.exists == false
|
186
|
+
result.data = false
|
187
|
+
result.message = 'Truststore not found'
|
188
|
+
elsif truststore_info.aliases.is_a?(Array)
|
189
|
+
result.data = true
|
190
|
+
end
|
191
|
+
|
192
|
+
result
|
193
|
+
end
|
194
|
+
|
195
|
+
# Authorizable keystore payload handler, checks for exists and aliases
|
196
|
+
# properties in order to identify existence.
|
197
|
+
#
|
198
|
+
# @param response HTTP response containing status_code, body, and headers
|
199
|
+
# @param response_spec response specification as configured in conf/spec.yaml
|
200
|
+
# @param call_params API call parameters
|
201
|
+
# @return RubyAem::Result
|
202
|
+
def self.json_authorizable_keystore_exists(response, response_spec, call_params)
|
203
|
+
keystore_info = response.body
|
204
|
+
|
205
|
+
result = Handlers.simple(response, response_spec, call_params)
|
206
|
+
|
207
|
+
if keystore_info.exists == false
|
208
|
+
result.data = false
|
209
|
+
result.message = 'Authorizable keystore not found'
|
210
|
+
elsif keystore_info.aliases.is_a?(Array)
|
211
|
+
result.data = true
|
212
|
+
end
|
213
|
+
|
214
|
+
result
|
215
|
+
end
|
116
216
|
end
|
117
217
|
end
|
@@ -76,5 +76,17 @@ module RubyAem
|
|
76
76
|
result = Handlers.simple(response, response_spec, call_params)
|
77
77
|
raise RubyAem::Error.new(result.message, result)
|
78
78
|
end
|
79
|
+
|
80
|
+
# Simple handler with response body as result data.
|
81
|
+
#
|
82
|
+
# @param response HTTP response containing status_code, body, and headers
|
83
|
+
# @param response_spec response specification as configured in conf/spec.yaml
|
84
|
+
# @param call_params API call parameters
|
85
|
+
# @return RubyAem::Result
|
86
|
+
def self.simple_body(response, response_spec, call_params)
|
87
|
+
result = Handlers.simple(response, response_spec, call_params)
|
88
|
+
result.data = response.body
|
89
|
+
result
|
90
|
+
end
|
79
91
|
end
|
80
92
|
end
|
@@ -50,8 +50,10 @@ module RubyAem
|
|
50
50
|
# https://github.com/shinesolutions/aem-healthcheck
|
51
51
|
# to be installed.
|
52
52
|
#
|
53
|
-
# @param
|
54
|
-
#
|
53
|
+
# @param opts optional parameters:
|
54
|
+
# - tags: comma separated tags of AEM Health Check tags
|
55
|
+
# - combine_tags_or: if true, the check needs to only pass one of the check tags in order to get the health check pass,
|
56
|
+
# if false, all check tags need to pass in order to get the health check pass.
|
55
57
|
# @return RubyAem::Result
|
56
58
|
def get_aem_health_check(opts = {})
|
57
59
|
@call_params = @call_params.merge(opts)
|
@@ -0,0 +1,102 @@
|
|
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 Authorizable Keystore.
|
23
|
+
class AuthorizableKeystore
|
24
|
+
# Initialise an Authorizable Keystore
|
25
|
+
#
|
26
|
+
# @param client RubyAem::Client
|
27
|
+
# @param intermediate_path AEM User home path
|
28
|
+
# @param authorizable_id AEM User id
|
29
|
+
# @return new RubyAem::Resources::AuhtorizableKeystore instance
|
30
|
+
def initialize(client, intermediate_path, authorizable_id)
|
31
|
+
@client = client
|
32
|
+
@call_params = {
|
33
|
+
intermediate_path: intermediate_path,
|
34
|
+
authorizable_id: authorizable_id
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create AEM Authorizable Keystore.
|
39
|
+
#
|
40
|
+
# @param password Password for the keystore
|
41
|
+
# @return RubyAem::Result
|
42
|
+
def create(password)
|
43
|
+
@call_params[:password] = password
|
44
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Change the password of an AEM Authorizable Keystore
|
48
|
+
#
|
49
|
+
# @param old_password Current password for the authorizable keystore
|
50
|
+
# @param new_password New password for the authorizable keystore
|
51
|
+
|
52
|
+
# @return RubyAem::Result
|
53
|
+
def change_password(old_password, new_password)
|
54
|
+
@call_params[:old_password] = old_password
|
55
|
+
@call_params[:new_password] = new_password
|
56
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Read an authorizable keystore in PKCS#12 Format
|
60
|
+
#
|
61
|
+
# @param file_path local file path to Keystore PKCS12 file
|
62
|
+
# @param password Password of the Keystore PKCS12 File
|
63
|
+
# @return OpenSSL::PKCS12
|
64
|
+
def read(file_path, password)
|
65
|
+
authorizable_keystore_raw = File.read file_path
|
66
|
+
OpenSSL::PKCS12.new(authorizable_keystore_raw, password)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Download the AEM Keystore to a specified directory.
|
70
|
+
#
|
71
|
+
# @param file_path the directory where the Keystore will be downloaded to
|
72
|
+
# @return RubyAem::Result
|
73
|
+
def download(
|
74
|
+
file_path
|
75
|
+
)
|
76
|
+
@call_params[:file_path] = file_path
|
77
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Delete AEM Authorizable Keystore
|
81
|
+
#
|
82
|
+
# @return RubyAem::Result
|
83
|
+
def delete
|
84
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Check if a keystore for the given authorizable id already exists.
|
88
|
+
#
|
89
|
+
# @return RubyAem::Result
|
90
|
+
def exists
|
91
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Retrieve AEM Authorizable Keystore info.
|
95
|
+
#
|
96
|
+
# @return RubyAem::Result
|
97
|
+
def info
|
98
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# Copyright 2016-2018 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
|
+
require 'ruby_aem/resources/truststore'
|
20
|
+
|
21
|
+
module RubyAem
|
22
|
+
module Resources
|
23
|
+
# AEM class contains API calls related to managing a certificate within AEM Truststore.
|
24
|
+
# Since there is only 0 or 1 AEM Truststore with a global scope, a certificate
|
25
|
+
# is by default associated to that global AEM Truststore.
|
26
|
+
class Certificate
|
27
|
+
# Initialise certificate.
|
28
|
+
# Certificate resource uses serial number as identifier because AEM API endpoint
|
29
|
+
# for importing a certificate does not allow the ability to specify an alias,
|
30
|
+
# hence alias is assigned randomly by AEM, and this force us to use serial
|
31
|
+
# number as the identifier because serial number is immutable on the certificate.
|
32
|
+
# This is obviously not ideal, but we have to do it due to AEM API limitations.
|
33
|
+
#
|
34
|
+
# @param client RubyAem::Client
|
35
|
+
# @param serial_number the certificate's serial number
|
36
|
+
# @return new RubyAem::Resources::Certificate instance
|
37
|
+
def initialize(
|
38
|
+
client,
|
39
|
+
serial_number
|
40
|
+
)
|
41
|
+
@client = client
|
42
|
+
@truststore = RubyAem::Resources::Truststore.new(client)
|
43
|
+
@serial_number = serial_number
|
44
|
+
@call_params = {
|
45
|
+
serial_number: serial_number
|
46
|
+
}
|
47
|
+
@cert_alias = _get_alias
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create is an alias to import.
|
51
|
+
# Create is needed to satisfy Puppet resource `ensure`.
|
52
|
+
#
|
53
|
+
# @param file_path local file path to certificate file
|
54
|
+
# @return RubyAem::Result
|
55
|
+
def create(file_path)
|
56
|
+
import(file_path)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Import a certificate file into AEM Truststore.
|
60
|
+
#
|
61
|
+
# @param file_path local file path to certificate file
|
62
|
+
# @return RubyAem::Result
|
63
|
+
def import(file_path)
|
64
|
+
@call_params[:file_path] = file_path
|
65
|
+
result = @client.call(self.class, __callee__.to_s, @call_params)
|
66
|
+
@cert_alias = _get_alias
|
67
|
+
result
|
68
|
+
end
|
69
|
+
|
70
|
+
# Export a certificate file from AEM Truststore.
|
71
|
+
#
|
72
|
+
# @param truststore_password Password for AEM Truststore
|
73
|
+
# @return RubyAem::Result
|
74
|
+
def export(truststore_password)
|
75
|
+
temp_file = Tempfile.new.path
|
76
|
+
@truststore.download(temp_file)
|
77
|
+
|
78
|
+
truststore_raw = File.read temp_file
|
79
|
+
truststore = OpenSSL::PKCS12.new(truststore_raw, truststore_password)
|
80
|
+
|
81
|
+
certificate = nil
|
82
|
+
truststore.ca_certs.each { |ca_cert|
|
83
|
+
certificate = ca_cert if ca_cert.serial.to_s == @serial_number.to_s
|
84
|
+
}
|
85
|
+
result = RubyAem::Result.new('Certificate exported', nil)
|
86
|
+
result.data = certificate
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
# Delete a specific certificate from AEM Truststore by alias name or serial number.
|
91
|
+
#
|
92
|
+
# @return RubyAem::Result
|
93
|
+
def delete
|
94
|
+
result = exists
|
95
|
+
raise RubyAem::Error.new('Certificate not found', result) if result.data == false
|
96
|
+
@call_params[:cert_alias] = @cert_alias
|
97
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Check if the certificate exists in AEM truststore.
|
101
|
+
#
|
102
|
+
# @return RubyAem::Result
|
103
|
+
def exists
|
104
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
105
|
+
end
|
106
|
+
|
107
|
+
def _get_alias
|
108
|
+
truststore_info = @truststore.info.data
|
109
|
+
cert_alias = nil
|
110
|
+
truststore_info.aliases.each { |certificate_alias|
|
111
|
+
cert_alias = certificate_alias._alias.to_s if certificate_alias.serial_number.to_s == @serial_number.to_s
|
112
|
+
}
|
113
|
+
cert_alias
|
114
|
+
end
|
115
|
+
|
116
|
+
# Import a certificate file into AEM Truststore and wait until the certificate is imported.
|
117
|
+
#
|
118
|
+
# @param file_path local file path to certificate file
|
119
|
+
# @param opts optional parameters:
|
120
|
+
# - _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
|
121
|
+
# @return RubyAem::Result
|
122
|
+
def import_wait_until_ready(
|
123
|
+
file_path,
|
124
|
+
opts = {
|
125
|
+
_retries: {
|
126
|
+
max_tries: 30,
|
127
|
+
base_sleep_seconds: 2,
|
128
|
+
max_sleep_seconds: 2
|
129
|
+
}
|
130
|
+
}
|
131
|
+
)
|
132
|
+
opts[:_retries] ||= {}
|
133
|
+
opts[:_retries][:max_tries] ||= 30
|
134
|
+
opts[:_retries][:base_sleep_seconds] ||= 2
|
135
|
+
opts[:_retries][:max_sleep_seconds] ||= 2
|
136
|
+
|
137
|
+
# ensure integer retries setting (Puppet 3 passes numeric string)
|
138
|
+
opts[:_retries][:max_tries] = opts[:_retries][:max_tries].to_i
|
139
|
+
opts[:_retries][:base_sleep_seconds] = opts[:_retries][:base_sleep_seconds].to_i
|
140
|
+
opts[:_retries][:max_sleep_seconds] = opts[:_retries][:max_sleep_seconds].to_i
|
141
|
+
|
142
|
+
result = import(file_path)
|
143
|
+
|
144
|
+
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|
|
145
|
+
check_result = exists
|
146
|
+
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.message)
|
147
|
+
raise StandardError.new(check_result.message) if check_result.data == false
|
148
|
+
}
|
149
|
+
result
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Copyright 2016-2018 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
|
+
require 'ruby_aem/resources/authorizable_keystore'
|
20
|
+
|
21
|
+
module RubyAem
|
22
|
+
module Resources
|
23
|
+
# AEM class contains API calls related to managing a certificate chain within AEM Authorizable Keystore.
|
24
|
+
class CertificateChain
|
25
|
+
# Initialise certificate chain
|
26
|
+
#
|
27
|
+
# @param client RubyAem::Client
|
28
|
+
# @param private_key_alias Alias of the private key associated to this certificate chain
|
29
|
+
# @param keystore_intermediate_path AEM User home path
|
30
|
+
# @param keystore_authorizable_id AEM User id
|
31
|
+
# @return new RubyAem::Resources::AuhtorizableKeystore instance
|
32
|
+
def initialize(client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id)
|
33
|
+
@client = client
|
34
|
+
@truststore = RubyAem::Resources::Truststore.new(client)
|
35
|
+
@private_key_alias = private_key_alias
|
36
|
+
@call_params = {
|
37
|
+
private_key_alias: private_key_alias,
|
38
|
+
keystore_intermediate_path: keystore_intermediate_path,
|
39
|
+
keystore_authorizable_id: keystore_authorizable_id
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create is an alias to import.
|
44
|
+
# Create is needed to satisfy Puppet resource `ensure`.
|
45
|
+
#
|
46
|
+
# @param certificate_chain_file_path file path to certificate chain file
|
47
|
+
# @param private_key_file_path file path to private key associated to the certificate chain
|
48
|
+
# @return RubyAem::Result
|
49
|
+
def create(certificate_chain_file_path, private_key_file_path)
|
50
|
+
import(certificate_chain_file_path, private_key_file_path)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Import a certificate file into AEM Truststore.
|
54
|
+
#
|
55
|
+
# @param certificate_chain_file_path file path to certificate chain file
|
56
|
+
# @param private_key_file_path file path to private key associated to the certificate chain
|
57
|
+
# @return RubyAem::Result
|
58
|
+
def import(certificate_chain_file_path, private_key_file_path)
|
59
|
+
@call_params[:file_path_certificate] = certificate_chain_file_path
|
60
|
+
@call_params[:file_path_private_key] = private_key_file_path
|
61
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Delete a specific certificate chain by its associated private key alias.
|
65
|
+
#
|
66
|
+
# @return RubyAem::Result
|
67
|
+
def delete
|
68
|
+
result = exists
|
69
|
+
raise RubyAem::Error.new('Certificate chain not found', result) if result.data == false
|
70
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Check if certificate chain exists in the Authorizable Keystore.
|
74
|
+
#
|
75
|
+
# @return RubyAem::Result
|
76
|
+
def exists
|
77
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Import a certificate file into AEM Truststore and wait until the certificate is imported.
|
81
|
+
#
|
82
|
+
# @param certificate_chain_file_path file path to certificate chain file
|
83
|
+
# @param private_key_file_path file path to private key associated to the certificate chain
|
84
|
+
# @param opts optional parameters:
|
85
|
+
# - _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
|
86
|
+
# @return RubyAem::Result
|
87
|
+
def import_wait_until_ready(
|
88
|
+
certificate_chain_file_path,
|
89
|
+
private_key_file_path,
|
90
|
+
opts = {
|
91
|
+
_retries: {
|
92
|
+
max_tries: 30,
|
93
|
+
base_sleep_seconds: 2,
|
94
|
+
max_sleep_seconds: 2
|
95
|
+
}
|
96
|
+
}
|
97
|
+
)
|
98
|
+
opts[:_retries] ||= {}
|
99
|
+
opts[:_retries][:max_tries] ||= 30
|
100
|
+
opts[:_retries][:base_sleep_seconds] ||= 2
|
101
|
+
opts[:_retries][:max_sleep_seconds] ||= 2
|
102
|
+
|
103
|
+
# ensure integer retries setting (Puppet 3 passes numeric string)
|
104
|
+
opts[:_retries][:max_tries] = opts[:_retries][:max_tries].to_i
|
105
|
+
opts[:_retries][:base_sleep_seconds] = opts[:_retries][:base_sleep_seconds].to_i
|
106
|
+
opts[:_retries][:max_sleep_seconds] = opts[:_retries][:max_sleep_seconds].to_i
|
107
|
+
|
108
|
+
result = import(certificate_chain_file_path, private_key_file_path)
|
109
|
+
|
110
|
+
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|
|
111
|
+
check_result = exists
|
112
|
+
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.message)
|
113
|
+
raise StandardError.new(check_result.message) if check_result.data == false
|
114
|
+
}
|
115
|
+
result
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -35,14 +35,12 @@ module RubyAem
|
|
35
35
|
|
36
36
|
# Create a new config property.
|
37
37
|
#
|
38
|
-
# @param
|
39
|
-
# @param @param config_node_name the node name of a given OSGI config
|
38
|
+
# @param config_node_name the node name of a given OSGI config
|
40
39
|
# @return RubyAem::Result
|
41
|
-
def create(
|
40
|
+
def create(config_node_name)
|
42
41
|
name = RubyAem::Swagger.property_to_parameter(@call_params[:name])
|
43
42
|
type_hint_prefix = name.gsub(/^_/, '')
|
44
43
|
|
45
|
-
@call_params[:run_mode] = run_mode
|
46
44
|
@call_params[:config_node_name] = config_node_name
|
47
45
|
@call_params[name.to_sym] = @call_params[:value]
|
48
46
|
@call_params["#{type_hint_prefix}_type_hint".to_sym] = @call_params[:type]
|
@@ -46,7 +46,7 @@ module RubyAem
|
|
46
46
|
# Update the package with specific filter.
|
47
47
|
#
|
48
48
|
# @param filter package filter JSON string
|
49
|
-
#
|
49
|
+
# example: [{ "root": "/apps/geometrixx", "rules": [] }, { "root": "/apps/geometrixx-common", "rules": []}]
|
50
50
|
# @return RubyAem::Result
|
51
51
|
def update(filter)
|
52
52
|
@call_params[:filter] = filter
|
@@ -0,0 +1,62 @@
|
|
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 'ruby_aem/error'
|
16
|
+
|
17
|
+
module RubyAem
|
18
|
+
module Resources
|
19
|
+
# AEM class contains API calls related to managing SAML.
|
20
|
+
class Saml
|
21
|
+
# Initialise Saml.
|
22
|
+
#
|
23
|
+
# @param client RubyAem::Client
|
24
|
+
# @return new RubyAem::Resources::Saml instance
|
25
|
+
def initialize(client)
|
26
|
+
@client = client
|
27
|
+
@call_params = {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create SAML configuration
|
31
|
+
#
|
32
|
+
# @param opts optional parameters, parameter names can be retrieved from
|
33
|
+
# AEM OSGI config page for `com.adobe.granite.auth.saml.SamlAuthenticationHandler.config`
|
34
|
+
# Alternatively, they can also be retrieved from Swagger AEM specification
|
35
|
+
# at https://github.com/shinesolutions/swagger-aem/blob/master/conf/api.yml
|
36
|
+
# on operation ID `postConfigAdobeGraniteSamlAuthenticationHandler`
|
37
|
+
# Some parameters explanation can be found on https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/saml-2-0-authenticationhandler.html
|
38
|
+
# @return RubyAem::Result
|
39
|
+
def create(opts)
|
40
|
+
@call_params = @call_params.merge(opts)
|
41
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delete SAML configuration
|
45
|
+
#
|
46
|
+
# @return RubyAem::Result
|
47
|
+
def delete
|
48
|
+
@call_params[:apply] = true
|
49
|
+
@call_params[:delete] = true
|
50
|
+
|
51
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get SAML configuration
|
55
|
+
#
|
56
|
+
# @return RubyAem::Result
|
57
|
+
def get
|
58
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|