lib/saml/util.rb in libsaml-2.9.0 vs lib/saml/util.rb in libsaml-2.10.0

- old
+ new

@@ -27,11 +27,15 @@ http.cert = OpenSSL::X509::Certificate.new(cert) http.key = OpenSSL::PKey::RSA.new(key) end - headers = { 'Content-Type' => 'text/xml' } + headers = { + 'Content-Type' => 'text/xml', + 'Cache-Control' => 'no-cache, no-store', + 'Pragma' => 'no-cache' + } headers.merge! additional_headers request = Net::HTTP::Post.new(uri.request_uri, headers) request.body = message @@ -81,9 +85,26 @@ encrypted_assertion_xml = encrypted_assertion.is_a?(Saml::Elements::EncryptedAssertion) ? encrypted_assertion.to_xml : encrypted_assertion.to_s encrypted_document = Xmlenc::EncryptedDocument.new(encrypted_assertion_xml) Saml::Assertion.parse(encrypted_document.decrypt(private_key), single: true) + end + + def encrypt_name_id(name_id, key_descriptor, key_options = {}) + encrypted_id = Saml::Elements::EncryptedID.new(name_id: name_id) + encrypt_encrypted_id(encrypted_id, key_descriptor, key_options) + end + + def encrypt_encrypted_id(encrypted_id, key_descriptor, key_options = {}) + encrypted_id.encrypt(key_descriptor, key_options) + encrypted_id + end + + def decrypt_encrypted_id(encrypted_id, private_key) + encrypted_id_xml = encrypted_id.is_a?(Saml::Elements::EncryptedID) ? + encrypted_id.to_xml : encrypted_id.to_s + encrypted_document = Xmlenc::EncryptedDocument.new(encrypted_id_xml) + Saml::Elements::EncryptedID.parse(encrypted_document.decrypt(private_key)) end def verify_xml(message, raw_body) document = Xmldsig::SignedDocument.new(raw_body)