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



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

def signature_namespace
  Namespaces::SIGNATURE
end

#signed?Boolean

Returns:

  • (Boolean)


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

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

#signed_documentObject



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

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

#to_xmlObject



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

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

#valid_signature?(fingerprint) ⇒ Boolean

Returns:

  • (Boolean)


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

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