Sha256: 39c73c4f707a920e91d8253986495815d6905b0f0d11aad9ac68835d2f64f239

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 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(node = nil)
      super(node)
      unless node
        @want_authn_requests_signed = nil
        @single_sign_on_services = []
        @attribute_profiles = []
        @attributes = []
      end
    end

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

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

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

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

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

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saml2-1.0.5 lib/saml2/identity_provider.rb
saml2-1.0.4 lib/saml2/identity_provider.rb
saml2-1.0.3 lib/saml2/identity_provider.rb
saml2-1.0.2 lib/saml2/identity_provider.rb
saml2-1.0.1 lib/saml2/identity_provider.rb
saml2-1.0.0 lib/saml2/identity_provider.rb