Skip to content

Commit

Permalink
Add parameter to the decryptElement method to make optional the forma…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
pitbulk committed May 15, 2018
1 parent 428ffa8 commit ab7fff7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/Saml2/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1100,12 +1100,13 @@ public static function getStatus($dom)
*
* @param DOMElement $encryptedData The encrypted data.
* @param XMLSecurityKey $inputKey The decryption key.
* @param bool $formatOutput Format or not the output.
*
* @return DOMElement The decrypted element.
*
* @throws Exception
*/
public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey)
public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey, $formatOutput = true)
{

$enc = new XMLSecEnc();
Expand Down Expand Up @@ -1190,8 +1191,10 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey

$xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$decrypted.'</root>';
$newDoc = new DOMDocument();
$newDoc->preserveWhiteSpace = false;
$newDoc->formatOutput = true;
if ($formatOutput) {
$newDoc->preserveWhiteSpace = false;
$newDoc->formatOutput = true;
}
$newDoc = self::loadXML($newDoc, $xml);
if (!$newDoc) {
throw new OneLogin_Saml2_ValidationError(
Expand All @@ -1211,7 +1214,7 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
return $decryptedElement;
}

/**
/**
* Converts a XMLSecurityKey to the correct algorithm.
*
* @param XMLSecurityKey $key The key.
Expand Down

0 comments on commit ab7fff7

Please sign in to comment.