@@ -164,34 +164,32 @@ def entity_descriptor
164
164
end
165
165
166
166
def entity_descriptor_path
167
- path = "//md:EntityDescriptor"
168
- entity_id = options [ :entity_id ]
169
- return path unless entity_id
167
+ path = "//md:EntityDescriptor"
168
+ entity_id = options [ :entity_id ]
169
+ return path unless entity_id
170
170
path << "[@entityID=\" #{ entity_id } \" ]"
171
171
end
172
172
173
173
def idpsso_descriptor
174
- unless entity_descriptor . nil?
175
- return REXML ::XPath . first (
176
- entity_descriptor ,
177
- "md:IDPSSODescriptor" ,
178
- namespace
179
- )
180
- end
174
+ REXML ::XPath . first (
175
+ document ,
176
+ entity_descriptor_path << "/md:IDPSSODescriptor" ,
177
+ namespace
178
+ )
181
179
end
182
180
183
181
# @return [String|nil] IdP Entity ID value if exists
184
182
#
185
183
def idp_entity_id
186
- entity_descriptor . attributes [ "entityID" ]
184
+ idpsso_descriptor . parent . attributes [ "entityID" ]
187
185
end
188
186
189
187
# @return [String|nil] IdP Name ID Format value if exists
190
188
#
191
189
def idp_name_id_format
192
190
node = REXML ::XPath . first (
193
- entity_descriptor ,
194
- "md:IDPSSODescriptor/md: NameIDFormat" ,
191
+ idpsso_descriptor ,
192
+ "md:NameIDFormat" ,
195
193
namespace
196
194
)
197
195
Utils . element_text ( node )
@@ -202,8 +200,8 @@ def idp_name_id_format
202
200
#
203
201
def single_signon_service_binding ( binding_priority = nil )
204
202
nodes = REXML ::XPath . match (
205
- entity_descriptor ,
206
- "md:IDPSSODescriptor/md: SingleSignOnService/@Binding" ,
203
+ idpsso_descriptor ,
204
+ "md:SingleSignOnService/@Binding" ,
207
205
namespace
208
206
)
209
207
if binding_priority
@@ -221,8 +219,8 @@ def single_signon_service_url(options = {})
221
219
binding = single_signon_service_binding ( options [ :sso_binding ] )
222
220
unless binding . nil?
223
221
node = REXML ::XPath . first (
224
- entity_descriptor ,
225
- "md:IDPSSODescriptor/md: SingleSignOnService[@Binding=\" #{ binding } \" ]/@Location" ,
222
+ idpsso_descriptor ,
223
+ "md:SingleSignOnService[@Binding=\" #{ binding } \" ]/@Location" ,
226
224
namespace
227
225
)
228
226
return node . value if node
@@ -234,8 +232,8 @@ def single_signon_service_url(options = {})
234
232
#
235
233
def single_logout_service_binding ( binding_priority = nil )
236
234
nodes = REXML ::XPath . match (
237
- entity_descriptor ,
238
- "md:IDPSSODescriptor/md: SingleLogoutService/@Binding" ,
235
+ idpsso_descriptor ,
236
+ "md:SingleLogoutService/@Binding" ,
239
237
namespace
240
238
)
241
239
if binding_priority
@@ -253,8 +251,8 @@ def single_logout_service_url(options = {})
253
251
binding = single_logout_service_binding ( options [ :slo_binding ] )
254
252
unless binding . nil?
255
253
node = REXML ::XPath . first (
256
- entity_descriptor ,
257
- "md:IDPSSODescriptor/md: SingleLogoutService[@Binding=\" #{ binding } \" ]/@Location" ,
254
+ idpsso_descriptor ,
255
+ "md:SingleLogoutService[@Binding=\" #{ binding } \" ]/@Location" ,
258
256
namespace
259
257
)
260
258
return node . value if node
@@ -266,14 +264,14 @@ def single_logout_service_url(options = {})
266
264
def certificates
267
265
@certificates ||= begin
268
266
signing_nodes = REXML ::XPath . match (
269
- entity_descriptor ,
270
- "md:IDPSSODescriptor/md: KeyDescriptor[not(contains(@use, 'encryption'))]/ds:KeyInfo/ds:X509Data/ds:X509Certificate" ,
267
+ idpsso_descriptor ,
268
+ "md:KeyDescriptor[not(contains(@use, 'encryption'))]/ds:KeyInfo/ds:X509Data/ds:X509Certificate" ,
271
269
namespace
272
270
)
273
271
274
272
encryption_nodes = REXML ::XPath . match (
275
- entity_descriptor ,
276
- "md:IDPSSODescriptor/md: KeyDescriptor[not(contains(@use, 'signing'))]/ds:KeyInfo/ds:X509Data/ds:X509Certificate" ,
273
+ idpsso_descriptor ,
274
+ "md:KeyDescriptor[not(contains(@use, 'signing'))]/ds:KeyInfo/ds:X509Data/ds:X509Certificate" ,
277
275
namespace
278
276
)
279
277
@@ -315,8 +313,8 @@ def fingerprint(certificate, fingerprint_algorithm = XMLSecurity::Document::SHA1
315
313
#
316
314
def attribute_names
317
315
nodes = REXML ::XPath . match (
318
- entity_descriptor ,
319
- "md:IDPSSODescriptor/ saml:Attribute/@Name" ,
316
+ idpsso_descriptor ,
317
+ "saml:Attribute/@Name" ,
320
318
namespace
321
319
)
322
320
nodes . map ( &:value )
0 commit comments