Sha256: 1ae6c293306e5dae09bc84e4dddd42b810d4a9a02c9f37fc2539451620dddb11

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

module Saml
  module ComplexTypes
    module SSODescriptorType
      extend ActiveSupport::Concern
      include Saml::Base

      class ArtifactResolutionService
        include Saml::ComplexTypes::IndexedEndpointType

        tag 'ArtifactResolutionService'
        namespace 'md'
      end

      class SingleLogoutService
        include Saml::ComplexTypes::EndpointType

        tag 'SingleLogoutService'
        namespace 'md'
      end

      included do
        namespace 'md'

        PROTOCOL_SUPPORT_ENUMERATION = "urn:oasis:names:tc:SAML:2.0:protocol" unless defined?(PROTOCOL_SUPPORT_ENUMERATION)

        attribute :protocol_support_enumeration, String, :tag => "protocolSupportEnumeration"
        attribute :valid_until, Time, :tag => "validUntil"
        attribute :cache_duration, String, :tag => "cacheDuration"
        attribute :error_url, String, :tag => "errorURL"

        has_many :key_descriptors, Saml::Elements::KeyDescriptor

        has_many :artifact_resolution_services, ArtifactResolutionService
        has_many :single_logout_services, SingleLogoutService

        validates :protocol_support_enumeration, :presence => true, :inclusion => [PROTOCOL_SUPPORT_ENUMERATION]
      end

      def initialize(*args)
        super(*args)
        @single_logout_services       ||= []
        @key_descriptors              ||= []
        @artifact_resolution_services ||= []
        @protocol_support_enumeration ||= PROTOCOL_SUPPORT_ENUMERATION
      end

      def find_key_descriptor(key_name, use)
        key_descriptors_by_use = find_key_descriptors_by_use(use)

        if key_name.present?
          key_descriptors_by_use.find { |key| key.key_info.key_name == key_name }
        else
          key_descriptors_by_use.first
        end
      end

      private

      def find_key_descriptors_by_use(use)
        key_descriptors.select { |key| key.use == use || key.use.blank? }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
libsaml-2.6.2 lib/saml/complex_types/sso_descriptor_type.rb
libsaml-2.6.1 lib/saml/complex_types/sso_descriptor_type.rb
libsaml-2.6.0 lib/saml/complex_types/sso_descriptor_type.rb
libsaml-2.5.2 lib/saml/complex_types/sso_descriptor_type.rb