Sha256: 1dd5053e9cb6630546832b86d9b6ce9d204c3da76d0d028f38eaa495b79c8300

Contents?: true

Size: 959 Bytes

Versions: 19

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

module Saml
  module Kit
    class Parser
      # Creates a `{Saml::Kit::Metadata}` object from a raw XML [String].
      #
      # @param content [String] the raw metadata XML.
      # @return [Saml::Kit::Metadata] the metadata document or subclass.
      def metadata_from(content)
        document = Nokogiri::XML(content)
        return unless document.at_xpath('/md:EntityDescriptor', XmlParseable::NAMESPACES)

        xpath = '/md:EntityDescriptor/md:SPSSODescriptor'
        sp = document.at_xpath(xpath, XmlParseable::NAMESPACES)
        xpath = '/md:EntityDescriptor/md:IDPSSODescriptor'
        idp = document.at_xpath(xpath, XmlParseable::NAMESPACES)
        if sp && idp
          Saml::Kit::CompositeMetadata.new(content)
        elsif sp
          Saml::Kit::ServiceProviderMetadata.new(content)
        elsif idp
          Saml::Kit::IdentityProviderMetadata.new(content)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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