Sha256: e05c0b99eef2460b94a6919f72ae24ac67d09e250e55204713f788ee30730398

Contents?: true

Size: 772 Bytes

Versions: 2

Compression:

Stored size: 772 Bytes

Contents

module Saml
  module Kit
    class Signature
      include ActiveModel::Validations

      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?
        ::Xml::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

2 entries across 2 versions & 1 rubygems

Version Path
saml-kit-1.0.6 lib/saml/kit/signature.rb
saml-kit-1.0.5 lib/saml/kit/signature.rb