Sha256: b07e7d0838306ff22d8043b141e9d24c4604b74c57ce0c930dd30e3ae2b71053

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Saml
  module Kit
    # This class implements the Composite
    # design pattern to allow client
    # component to work with a metadata
    # that provides an IDPSSODescriptor
    # and SPSSODescriptor element.
    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 organization
        find { |x| x.organization.present? }.try(:organization)
      end

      def organization_name
        organization.name
      end

      def organization_url
        organization.url
      end

      def services(type)
        xpath = map do |x|
          "//md:EntityDescriptor/md:#{x.name}/md:#{type}"
        end.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

18 entries across 18 versions & 1 rubygems

Version Path
saml-kit-1.2.0 lib/saml/kit/composite_metadata.rb
saml-kit-1.1.0 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.31 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.30 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.29 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.28 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.27 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.26 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.25 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.24 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.23 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.22 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.21 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.20 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.19 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.18 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.17 lib/saml/kit/composite_metadata.rb
saml-kit-1.0.16 lib/saml/kit/composite_metadata.rb