Class: Lyrebird::Signature

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

Constant Summary collapse

C14N_EXCLUSIVE =
Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0

Instance Method Summary collapse

Constructor Details

#initialize(element, certificate) ⇒ Signature

Returns a new instance of Signature.



7
8
9
10
11
# File 'lib/lyrebird/signature.rb', line 7

def initialize(element, certificate)
  @element = element
  @certificate = certificate
  @doc = element.document
end

Instance Method Details

#sign!Object



13
14
15
16
17
18
19
20
# File 'lib/lyrebird/signature.rb', line 13

def sign!
  ns = { "saml" => SAML_ASSERTION_NS, "ds" => XMLDSIG_NS }
  @element.at_xpath("ds:Signature", ns)&.remove
  issuer = @element.at_xpath("saml:Issuer", ns)
  issuer.add_next_sibling(build_signature)
  populate_signature_value
  self
end