Sha256: c3ae2c95821792f13560c261305a645174192adc11fcf8862b541f9bf784a5be

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Saml
  module Kit
    class CompositeMetadata < Metadata # :nodoc:
      include Enumerable
      attr_reader :service_provider, :identity_provider

      def initialize(xml)
        super('IDPSSODescriptor', xml)
        @metadatum = [
          Saml::Kit::ServiceProviderMetadata.new(xml),
          Saml::Kit::IdentityProviderMetadata.new(xml),
        ]
      end

      def services(type)
        xpath = map { |x| "//md:EntityDescriptor/md:#{x.name}/md:#{type}" }.join('|')
        search(xpath).map do |item|
          binding = item.attribute('Binding').value
          location = item.attribute('Location').value
          Saml::Kit::Bindings.create_for(binding, location)
        end
      end

      def certificates
        flat_map(&:certificates)
      end

      def each(&block)
        @metadatum.each(&block)
      end

      def method_missing(name, *args)
        if (target = find { |x| x.respond_to?(name) })
          target.public_send(name, *args)
        else
          super
        end
      end

      def respond_to_missing?(method, *)
        find { |x| x.respond_to?(method) }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saml-kit-1.0.14 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.13 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.12 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.11 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.10 lib/saml/kit/composite_metadata.rb