Sha256: db1cf6952a6c1fe18d7193385bd4841e2418d8e8635475281f827a300e98e10a

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

require 'saml2/attribute'
require 'saml2/sso'

module SAML2
  class IdentityProvider < SSO
    attr_writer :want_authn_requests_signed, :single_sign_on_services, :attribute_profiles, :attributes

    def initialize
      super
      @want_authn_requests_signed = nil
      @single_sign_on_services = []
      @attribute_profiles = []
      @attributes = []
    end

    def from_xml(node)
      super
      remove_instance_variable(:@want_authn_requests_signed)
      @single_sign_on_services = nil
      @attribute_profiles = nil
      @attributes = nil
    end

    def want_authn_requests_signed?
      unless instance_variable_defined?(:@want_authn_requests_signed)
        @want_authn_requests_signed = xml['WantAuthnRequestsSigned'] && xml['WantAuthnRequestsSigned'] == 'true'
      end
      @want_authn_requests_signed
    end

    def single_sign_on_services
      @single_sign_on_services ||= load_object_array(xml, 'md:SingleSignOnService', Endpoint)
    end

    def attribute_profiles
      @attribute_profiles ||= load_string_array(xml, 'md:AttributeProfile')
    end

    def attributes
      @attributes ||= load_object_array(xml, 'saml:Attribute', Attribute)
    end

    def build(builder)
      builder['md'].IDPSSODescriptor do |idp_sso_descriptor|
        super(idp_sso_descriptor)

        idp_sso_descriptor['WantAuthnRequestsSigned'] = want_authn_requests_signed? unless want_authn_requests_signed?.nil?

        single_sign_on_services.each do |sso|
          sso.build(idp_sso_descriptor, 'SingleSignOnService')
        end

        attribute_profiles.each do |ap|
          idp_sso_descriptor['md'].AttributeProfile(ap)
        end

        attributes.each do |attr|
          attr.build(idp_sso_descriptor)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
saml2-2.0.2 lib/saml2/identity_provider.rb
saml2-2.0.1 lib/saml2/identity_provider.rb
saml2-2.0.0 lib/saml2/identity_provider.rb
saml2-1.1.5 lib/saml2/identity_provider.rb
saml2-1.1.4 lib/saml2/identity_provider.rb
saml2-1.1.3 lib/saml2/identity_provider.rb
saml2-1.1.2 lib/saml2/identity_provider.rb
saml2-1.1.1 lib/saml2/identity_provider.rb
saml2-1.1.0 lib/saml2/identity_provider.rb