Skip to content

Commit b88c472

Browse files
committed
Removed unused variables and made xpath selectors more specific
1 parent f878afe commit b88c472

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

lib/onelogin/ruby-saml/idp_metadata_parser.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ module OneLogin
99
module RubySaml
1010
include REXML
1111

12-
METADATA = "urn:oasis:names:tc:SAML:2.0:metadata"
13-
PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol"
14-
DSIG = "http://www.w3.org/2000/09/xmldsig#"
15-
1612
class IdpMetadataParser
1713

14+
METADATA = "urn:oasis:names:tc:SAML:2.0:metadata"
15+
DSIG = "http://www.w3.org/2000/09/xmldsig#"
16+
1817
attr_reader :document
1918

2019
def parse(idp_metadata)
@@ -31,18 +30,18 @@ def parse(idp_metadata)
3130
private
3231

3332
def single_signon_service_url
34-
node = REXML::XPath.first(document, "md:EntityDescriptor/md:IDPSSODescriptor/md:SingleSignOnService/@Location", { "md" => METADATA })
33+
node = REXML::XPath.first(document, "/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleSignOnService/@Location", { "md" => METADATA })
3534
node.value if node
3635
end
3736

3837
def single_logout_service_url
39-
node = REXML::XPath.first(document, "md:EntityDescriptor/md:IDPSSODescriptor/md:SingleLogoutService/@Location", { "md" => METADATA })
38+
node = REXML::XPath.first(document, "/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleLogoutService/@Location", { "md" => METADATA })
4039
node.value if node
4140
end
4241

4342
def certificate
4443
@certificate ||= begin
45-
node = REXML::XPath.first(document, "md:EntityDescriptor/md:IDPSSODescriptor/md:KeyDescriptor[@use='signing']/ds:KeyInfo/ds:X509Data/ds:X509Certificate", { "md" => METADATA, "ds" => DSIG })
44+
node = REXML::XPath.first(document, "/md:EntityDescriptor/md:IDPSSODescriptor/md:KeyDescriptor[@use='signing']/ds:KeyInfo/ds:X509Data/ds:X509Certificate", { "md" => METADATA, "ds" => DSIG })
4645
Base64.decode64(node.text) if node
4746
end
4847
end

0 commit comments

Comments
 (0)