Class: Saml::Kit::Builders::IdentityProviderMetadata
- Inherits:
-
Object
- Object
- Saml::Kit::Builders::IdentityProviderMetadata
- Defined in:
- lib/saml/kit/builders/identity_provider_metadata.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#contact_email ⇒ Object
Returns the value of attribute contact_email.
-
#entity_id ⇒ Object
Returns the value of attribute entity_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#logout_urls ⇒ Object
readonly
Returns the value of attribute logout_urls.
-
#name_id_formats ⇒ Object
Returns the value of attribute name_id_formats.
-
#organization_name ⇒ Object
Returns the value of attribute organization_name.
-
#organization_url ⇒ Object
Returns the value of attribute organization_url.
-
#sign ⇒ Object
Returns the value of attribute sign.
-
#single_sign_on_urls ⇒ Object
readonly
Returns the value of attribute single_sign_on_urls.
-
#want_authn_requests_signed ⇒ Object
Returns the value of attribute want_authn_requests_signed.
Instance Method Summary collapse
- #add_single_logout_service(url, binding: :http_post) ⇒ Object
- #add_single_sign_on_service(url, binding: :http_post) ⇒ Object
- #build ⇒ Object
-
#initialize(configuration = Saml::Kit.configuration) ⇒ IdentityProviderMetadata
constructor
A new instance of IdentityProviderMetadata.
- #to_xml ⇒ Object
Constructor Details
#initialize(configuration = Saml::Kit.configuration) ⇒ IdentityProviderMetadata
Returns a new instance of IdentityProviderMetadata.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 9 def initialize(configuration = Saml::Kit.configuration) @id = Id.generate @entity_id = configuration.issuer @attributes = [] @name_id_formats = [Namespaces::PERSISTENT] @single_sign_on_urls = [] @logout_urls = [] @configuration = configuration @sign = true @want_authn_requests_signed = true end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def attributes @attributes end |
#contact_email ⇒ Object
Returns the value of attribute contact_email.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def contact_email @contact_email end |
#entity_id ⇒ Object
Returns the value of attribute entity_id.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def entity_id @entity_id end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def id @id end |
#logout_urls ⇒ Object (readonly)
Returns the value of attribute logout_urls.
7 8 9 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 7 def logout_urls @logout_urls end |
#name_id_formats ⇒ Object
Returns the value of attribute name_id_formats.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def name_id_formats @name_id_formats end |
#organization_name ⇒ Object
Returns the value of attribute organization_name.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def organization_name @organization_name end |
#organization_url ⇒ Object
Returns the value of attribute organization_url.
5 6 7 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 5 def organization_url @organization_url end |
#sign ⇒ Object
Returns the value of attribute sign.
6 7 8 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 6 def sign @sign end |
#single_sign_on_urls ⇒ Object (readonly)
Returns the value of attribute single_sign_on_urls.
7 8 9 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 7 def single_sign_on_urls @single_sign_on_urls end |
#want_authn_requests_signed ⇒ Object
Returns the value of attribute want_authn_requests_signed.
6 7 8 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 6 def want_authn_requests_signed @want_authn_requests_signed end |
Instance Method Details
#add_single_logout_service(url, binding: :http_post) ⇒ Object
25 26 27 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 25 def add_single_logout_service(url, binding: :http_post) @logout_urls.push(location: url, binding: Bindings.binding_for(binding)) end |
#add_single_sign_on_service(url, binding: :http_post) ⇒ Object
21 22 23 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 21 def add_single_sign_on_service(url, binding: :http_post) @single_sign_on_urls.push(location: url, binding: Bindings.binding_for(binding)) end |
#build ⇒ Object
78 79 80 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 78 def build Saml::Kit::IdentityProviderMetadata.new(to_xml) end |
#to_xml ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/saml/kit/builders/identity_provider_metadata.rb', line 29 def to_xml Signature.sign(sign: sign) do |xml, signature| xml.instruct! xml.EntityDescriptor do signature.template(id) xml.IDPSSODescriptor do if @configuration.signing_certificate_pem.present? xml.KeyDescriptor use: "signing" do xml.KeyInfo "xmlns": Namespaces::XMLDSIG do xml.X509Data do xml.X509Certificate @configuration.stripped_signing_certificate end end end end if @configuration.encryption_certificate_pem.present? xml.KeyDescriptor use: "encryption" do xml.KeyInfo "xmlns": Namespaces::XMLDSIG do xml.X509Data do xml.X509Certificate @configuration.stripped_encryption_certificate end end end end logout_urls.each do |item| xml.SingleLogoutService Binding: item[:binding], Location: item[:location] end name_id_formats.each do |format| xml.NameIDFormat format end single_sign_on_urls.each do |item| xml.SingleSignOnService Binding: item[:binding], Location: item[:location] end attributes.each do |attribute| xml.tag! 'saml:Attribute', Name: attribute end end xml.Organization do xml.OrganizationName organization_name, 'xml:lang': "en" xml.OrganizationDisplayName organization_name, 'xml:lang': "en" xml.OrganizationURL organization_url, 'xml:lang': "en" end xml.ContactPerson contactType: "technical" do xml.Company "mailto:#{contact_email}" end end end end |