Class: SamlIdp::IncomingMetadata
- Inherits:
-
Object
- Object
- SamlIdp::IncomingMetadata
- Includes:
- Hashable
- Defined in:
- lib/saml_idp/incoming_metadata.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
- #assertion_consumer_services ⇒ Object
- #company ⇒ Object
- #contact_person ⇒ Object
- #contact_person_document ⇒ Object
- #display_name ⇒ Object
- #document ⇒ Object
- #email_address ⇒ Object
- #encryption_certificate ⇒ Object
- #given_name ⇒ Object
- #idp_descriptor_document ⇒ Object
-
#initialize(raw = "") ⇒ IncomingMetadata
constructor
A new instance of IncomingMetadata.
- #name_id_formats ⇒ Object
- #role_descriptor_document ⇒ Object
- #service_provider_descriptor_document ⇒ Object
- #sign_assertions ⇒ Object
- #signing_certificate ⇒ Object
- #single_logout_services ⇒ Object
- #surname ⇒ Object
- #telephone_number ⇒ Object
Methods included from Hashable
Constructor Details
#initialize(raw = "") ⇒ IncomingMetadata
Returns a new instance of IncomingMetadata.
11 12 13 |
# File 'lib/saml_idp/incoming_metadata.rb', line 11 def initialize(raw = "") self.raw = raw end |
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
6 7 8 |
# File 'lib/saml_idp/incoming_metadata.rb', line 6 def raw @raw end |
Instance Method Details
#assertion_consumer_services ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/saml_idp/incoming_metadata.rb', line 86 def assertion_consumer_services xpath( "//md:SPSSODescriptor/md:AssertionConsumerService", md: ).sort_by { |el| el["index"].to_i }.reduce([]) do |array, el| props = el["Binding"].to_s.match /urn:oasis:names:tc:SAML:(?<version>\S+):bindings:(?<name>\S+)/ array << { binding: props[:name], location: el["Location"], default: !!el["isDefault"] } array end end |
#company ⇒ Object
106 107 108 |
# File 'lib/saml_idp/incoming_metadata.rb', line 106 def company contact_person_document.xpath("//md:Company", md: ).first.try(:content).to_s end |
#contact_person ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/saml_idp/incoming_metadata.rb', line 34 def contact_person { given_name: given_name, surname: surname, company: company, telephone_number: telephone_number, email_address: email_address } end |
#contact_person_document ⇒ Object
130 131 132 |
# File 'lib/saml_idp/incoming_metadata.rb', line 130 def contact_person_document @contact_person_document ||= xpath("//md:ContactPerson", md: ).first end |
#display_name ⇒ Object
29 30 31 |
# File 'lib/saml_idp/incoming_metadata.rb', line 29 def display_name role_descriptor_document.present? ? role_descriptor_document["ServiceDisplayName"] : "" end |
#document ⇒ Object
15 16 17 |
# File 'lib/saml_idp/incoming_metadata.rb', line 15 def document @document ||= Saml::XML::Document.parse raw end |
#email_address ⇒ Object
114 115 116 |
# File 'lib/saml_idp/incoming_metadata.rb', line 114 def email_address contact_person_document.xpath("//md:EmailAddress", md: ).first.try(:content).to_s.gsub("mailto:", "") end |
#encryption_certificate ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/saml_idp/incoming_metadata.rb', line 54 def encryption_certificate xpath( "//md:SPSSODescriptor/md:KeyDescriptor[@use='encryption']/ds:KeyInfo/ds:X509Data/ds:X509Certificate", ds: signature_namespace, md: ).first.try(:content).to_s end |
#given_name ⇒ Object
98 99 100 |
# File 'lib/saml_idp/incoming_metadata.rb', line 98 def given_name contact_person_document.xpath("//md:GivenName", md: ).first.try(:content).to_s end |
#idp_descriptor_document ⇒ Object
126 127 128 |
# File 'lib/saml_idp/incoming_metadata.rb', line 126 def idp_descriptor_document @idp_descriptor ||= xpath("//md:IDPSSODescriptor", md: ).first end |
#name_id_formats ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/saml_idp/incoming_metadata.rb', line 74 def name_id_formats xpath( "//md:SPSSODescriptor/md:NameIDFormat", md: ).reduce(Set.new) do |set, el| props = el.content.to_s.match /urn:oasis:names:tc:SAML:(?<version>\S+):nameid-format:(?<name>\S+)/ set << props[:name].to_s.underscore if props[:name].present? set end end |
#role_descriptor_document ⇒ Object
118 119 120 |
# File 'lib/saml_idp/incoming_metadata.rb', line 118 def role_descriptor_document @role_descriptor ||= xpath("//md:RoleDescriptor", md: ).first end |
#service_provider_descriptor_document ⇒ Object
122 123 124 |
# File 'lib/saml_idp/incoming_metadata.rb', line 122 def service_provider_descriptor_document @service_provider_descriptor ||= xpath("//md:SPSSODescriptor", md: ).first end |
#sign_assertions ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/saml_idp/incoming_metadata.rb', line 19 def sign_assertions doc = xpath( "//md:SPSSODescriptor", ds: signature_namespace, md: ).first doc ? !!doc["WantAssertionsSigned"] : false end |
#signing_certificate ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/saml_idp/incoming_metadata.rb', line 45 def signing_certificate xpath( "//md:SPSSODescriptor/md:KeyDescriptor[@use='signing']/ds:KeyInfo/ds:X509Data/ds:X509Certificate", ds: signature_namespace, md: ).first.try(:content).to_s end |
#single_logout_services ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/saml_idp/incoming_metadata.rb', line 63 def single_logout_services xpath( "//md:SPSSODescriptor/md:SingleLogoutService", md: ).reduce({}) do |hash, el| hash[el["Binding"].to_s.split(":").last] = el["Location"] hash end end |
#surname ⇒ Object
102 103 104 |
# File 'lib/saml_idp/incoming_metadata.rb', line 102 def surname contact_person_document.xpath("//md:SurName", md: ).first.try(:content).to_s end |
#telephone_number ⇒ Object
110 111 112 |
# File 'lib/saml_idp/incoming_metadata.rb', line 110 def telephone_number contact_person_document.xpath("//md:TelephoneNumber", md: ).first.try(:content).to_s end |