Class: Saml::Kit::Builders::ServiceProviderMetadata
- Inherits:
-
Object
- Object
- Saml::Kit::Builders::ServiceProviderMetadata
- Defined in:
- lib/saml/kit/builders/service_provider_metadata.rb
Instance Attribute Summary collapse
-
#acs_urls ⇒ Object
Returns the value of attribute acs_urls.
-
#entity_id ⇒ Object
Returns the value of attribute entity_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#logout_urls ⇒ Object
Returns the value of attribute logout_urls.
-
#name_id_formats ⇒ Object
Returns the value of attribute name_id_formats.
-
#sign ⇒ Object
Returns the value of attribute sign.
-
#want_assertions_signed ⇒ Object
Returns the value of attribute want_assertions_signed.
Instance Method Summary collapse
- #add_assertion_consumer_service(url, binding: :http_post) ⇒ Object
- #add_single_logout_service(url, binding: :http_post) ⇒ Object
- #build ⇒ Object
-
#initialize(configuration = Saml::Kit.configuration) ⇒ ServiceProviderMetadata
constructor
A new instance of ServiceProviderMetadata.
- #to_xml ⇒ Object
Constructor Details
#initialize(configuration = Saml::Kit.configuration) ⇒ ServiceProviderMetadata
Returns a new instance of ServiceProviderMetadata.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 8 def initialize(configuration = Saml::Kit.configuration) @id = Id.generate @configuration = configuration @entity_id = configuration.issuer @acs_urls = [] @logout_urls = [] @name_id_formats = [Namespaces::PERSISTENT] @sign = true @want_assertions_signed = true end |
Instance Attribute Details
#acs_urls ⇒ Object
Returns the value of attribute acs_urls.
5 6 7 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 5 def acs_urls @acs_urls end |
#entity_id ⇒ Object
Returns the value of attribute entity_id.
5 6 7 |
# File 'lib/saml/kit/builders/service_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/service_provider_metadata.rb', line 5 def id @id end |
#logout_urls ⇒ Object
Returns the value of attribute logout_urls.
5 6 7 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 5 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/service_provider_metadata.rb', line 5 def name_id_formats @name_id_formats end |
#sign ⇒ Object
Returns the value of attribute sign.
5 6 7 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 5 def sign @sign end |
#want_assertions_signed ⇒ Object
Returns the value of attribute want_assertions_signed.
6 7 8 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 6 def want_assertions_signed @want_assertions_signed end |
Instance Method Details
#add_assertion_consumer_service(url, binding: :http_post) ⇒ Object
19 20 21 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 19 def add_assertion_consumer_service(url, binding: :http_post) @acs_urls.push(location: url, binding: Bindings.binding_for(binding)) end |
#add_single_logout_service(url, binding: :http_post) ⇒ Object
23 24 25 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 23 def add_single_logout_service(url, binding: :http_post) @logout_urls.push(location: url, binding: Bindings.binding_for(binding)) end |
#build ⇒ Object
65 66 67 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 65 def build Saml::Kit::ServiceProviderMetadata.new(to_xml) end |
#to_xml ⇒ Object
27 28 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 |
# File 'lib/saml/kit/builders/service_provider_metadata.rb', line 27 def to_xml Signature.sign(sign: sign) do |xml, signature| xml.instruct! xml.EntityDescriptor do signature.template(id) xml.SPSSODescriptor 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 acs_urls.each_with_index do |item, index| xml.AssertionConsumerService Binding: item[:binding], Location: item[:location], index: index, isDefault: index == 0 ? true : false end end end end end |