Class: Saml::Kit::Signature

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/saml/kit/signature.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml_hash) ⇒ Signature

Returns a new instance of Signature.



6
7
8
# File 'lib/saml/kit/signature.rb', line 6

def initialize(xml_hash)
  @xml_hash = xml_hash
end

Instance Method Details

#certificateObject

Returns the embedded X509 Certificate



11
12
13
14
15
# File 'lib/saml/kit/signature.rb', line 11

def certificate
  value = to_h.fetch('KeyInfo', {}).fetch('X509Data', {}).fetch('X509Certificate', nil)
  return if value.nil?
  ::Xml::Kit::Certificate.new(value, use: :signing)
end

#to_hObject

Returns the XML Hash.



24
25
26
# File 'lib/saml/kit/signature.rb', line 24

def to_h
  @xml_hash
end

#trusted?(metadata) ⇒ Boolean

Returns true when the fingerprint of the certificate matches one of the certificates registered in the metadata.

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/saml/kit/signature.rb', line 18

def trusted?()
  return false if .nil?
  .matches?(certificate.fingerprint, use: :signing)
end