Skip to content

Commit 811618d

Browse files
authored
Merge pull request #533 from JDrizzy/master
Check if response is encrypted
2 parents 0814853 + 33dd34b commit 811618d

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ Remember to provide it to the Signature builder if you are sending a `GET RelayS
579579
signature validation process will fail at the Identity Provider.
580580
581581
The Service Provider will sign the request/responses with its private key.
582-
The Identity Provider will validate the sign of the received request/responses with the public x500 cert of the
582+
The Identity Provider will validate the sign of the received request/responses with the public x509 cert of the
583583
Service Provider.
584584
585585
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key' for the sign and decrypt processes.

lib/onelogin/ruby-saml/response.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@ def allowed_clock_drift
341341
return options[:allowed_clock_drift].to_f
342342
end
343343

344+
# Checks if the SAML Response contains or not an EncryptedAssertion element
345+
# @return [Boolean] True if the SAML Response contains an EncryptedAssertion element
346+
#
347+
def assertion_encrypted?
348+
! REXML::XPath.first(
349+
document,
350+
"(/p:Response/EncryptedAssertion/)|(/p:Response/a:EncryptedAssertion/)",
351+
{ "p" => PROTOCOL, "a" => ASSERTION }
352+
).nil?
353+
end
354+
344355
private
345356

346357
# Validates the SAML Response (calls several validation methods)
@@ -967,17 +978,6 @@ def decrypt_assertion_from_document(document_copy)
967978
XMLSecurity::SignedDocument.new(response_node.to_s)
968979
end
969980

970-
# Checks if the SAML Response contains or not an EncryptedAssertion element
971-
# @return [Boolean] True if the SAML Response contains an EncryptedAssertion element
972-
#
973-
def assertion_encrypted?
974-
! REXML::XPath.first(
975-
document,
976-
"(/p:Response/EncryptedAssertion/)|(/p:Response/a:EncryptedAssertion/)",
977-
{ "p" => PROTOCOL, "a" => ASSERTION }
978-
).nil?
979-
end
980-
981981
# Decrypts an EncryptedAssertion element
982982
# @param encrypted_assertion_node [REXML::Element] The EncryptedAssertion element
983983
# @return [REXML::Document] The decrypted EncryptedAssertion element

0 commit comments

Comments
 (0)