Sha256: b487640336785330b5bd7a6be5af3681e122c5cabe0d92c007af487444c90c19

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

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('|')
        document.find_all(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

3 entries across 3 versions & 1 rubygems

Version Path
saml-kit-1.0.9 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.8 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.7 lib/saml/kit/composite_metadata.rb