Class: Saml::XML::Document

Inherits:
Nokogiri::XML::Document
  • Object
show all
Defined in:
lib/saml_idp.rb

Instance Method Summary collapse

Instance Method Details

#signature_namespaceObject



82
83
84
# File 'lib/saml_idp.rb', line 82

def signature_namespace
  Namespaces::SIGNATURE
end

#signed?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/saml_idp.rb', line 69

def signed?
  !!xpath("//ds:Signature", ds: signature_namespace).first
end

#signed_documentObject



78
79
80
# File 'lib/saml_idp.rb', line 78

def signed_document
  SamlIdp::XMLSecurity::SignedDocument.new(to_xml)
end

#to_xmlObject



86
87
88
89
90
# File 'lib/saml_idp.rb', line 86

def to_xml
  super(
    save_with: Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
  ).strip
end

#valid_signature?(certificate, fingerprint) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
76
# File 'lib/saml_idp.rb', line 73

def valid_signature?(certificate, fingerprint)
  signed? &&
    signed_document.validate(certificate, fingerprint, :soft)
end