Sha256: b03c4a660b1714ce81e5b7446f8c2310ea3bfc684c9ce252bdc06556e5f894a9

Contents?: true

Size: 1.98 KB

Versions: 17

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

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

module SAML2
  class IdentityProvider < SSO
    # @return [Boolean, nil]
    attr_writer :want_authn_requests_signed
    attr_writer :single_sign_on_services, :attribute_profiles, :attributes

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

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

    # @return [Boolean, nil]
    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

    # @return [Array<Endpoint>]
    def single_sign_on_services
      @single_sign_on_services ||= load_object_array(xml, 'md:SingleSignOnService', Endpoint)
    end

    # @return [Array<String>]
    def attribute_profiles
      @attribute_profiles ||= load_string_array(xml, 'md:AttributeProfile')
    end

    # @return [Array<Attribute>]
    def attributes
      @attributes ||= load_object_array(xml, 'saml:Attribute', Attribute)
    end

    # (see Base#build)
    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

17 entries across 17 versions & 1 rubygems

Version Path
saml2-3.0.2 lib/saml2/identity_provider.rb
saml2-3.0.1 lib/saml2/identity_provider.rb
saml2-3.0.0 lib/saml2/identity_provider.rb
saml2-2.2.12 lib/saml2/identity_provider.rb
saml2-2.2.11 lib/saml2/identity_provider.rb
saml2-2.2.10 lib/saml2/identity_provider.rb
saml2-2.2.9 lib/saml2/identity_provider.rb
saml2-2.2.8 lib/saml2/identity_provider.rb
saml2-2.2.7 lib/saml2/identity_provider.rb
saml2-2.2.6 lib/saml2/identity_provider.rb
saml2-2.2.5 lib/saml2/identity_provider.rb
saml2-2.2.4 lib/saml2/identity_provider.rb
saml2-2.2.3 lib/saml2/identity_provider.rb
saml2-2.2.2 lib/saml2/identity_provider.rb
saml2-2.2.1 lib/saml2/identity_provider.rb
saml2-2.2.0 lib/saml2/identity_provider.rb
saml2-2.1.0 lib/saml2/identity_provider.rb