Class: Saml::Kit::Signature

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

Instance Method Summary collapse

Constructor Details

#initialize(xml_hash) ⇒ Signature

Returns a new instance of Signature.



4
5
6
# File 'lib/saml/kit/signature.rb', line 4

def initialize(xml_hash)
  @xml_hash = xml_hash
end

Instance Method Details

#certificateObject

Returns the embedded X509 Certificate



9
10
11
12
13
# File 'lib/saml/kit/signature.rb', line 9

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.



22
23
24
# File 'lib/saml/kit/signature.rb', line 22

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)


16
17
18
19
# File 'lib/saml/kit/signature.rb', line 16

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