Sha256: 3e2663a4bfaf2a513939e408ddeb7a1dec7ea28d9d5854387b255a1de6daab97

Contents?: true

Size: 731 Bytes

Versions: 5

Compression:

Stored size: 731 Bytes

Contents

module Saml
  module Kit
    class Signature
      def initialize(xml_hash)
        @xml_hash = xml_hash
      end

      # Returns the embedded X509 Certificate
      def certificate
        value = to_h.fetch('KeyInfo', {}).fetch('X509Data', {}).fetch('X509Certificate', nil)
        return if value.nil?
        Saml::Kit::Certificate.new(value, use: :signing)
      end

      # Returns true when the fingerprint of the certificate matches one of the certificates registered in the metadata.
      def trusted?(metadata)
        return false if metadata.nil?
        metadata.matches?(certificate.fingerprint, use: :signing)
      end

      # Returns the XML Hash.
      def to_h
        @xml_hash
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saml-kit-0.3.0 lib/saml/kit/signature.rb
saml-kit-0.2.18 lib/saml/kit/signature.rb
saml-kit-0.2.17 lib/saml/kit/signature.rb
saml-kit-0.2.16 lib/saml/kit/signature.rb
saml-kit-0.2.15 lib/saml/kit/signature.rb