Skip to content
Snippets Groups Projects
Commit 093e5e56 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utilities:: debugMessage() to...

Move SimpleSAML_Utilities:: debugMessage() to SimpleSAML\Utils\HTTP::debugSAMLMessage() and deprecate the former.
parent 4b45e4f1
No related branches found
No related tags found
No related merge requests found
......@@ -121,7 +121,7 @@ class SimpleSAML_Bindings_Shib13_Artifact {
$artifacts = self::getArtifacts();
$request = self::buildRequest($artifacts);
SimpleSAML_Utilities::debugMessage($msgStr, 'out');
\SimpleSAML\Utils\XML::debugSAMLMessage($request, 'out');
$url = $idpMetadata->getDefaultEndpoint('ArtifactResolutionService', array('urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding'));
$url = $url['Location'];
......@@ -166,7 +166,7 @@ class SimpleSAML_Bindings_Shib13_Artifact {
throw new SimpleSAML_Error_Exception('Failed to retrieve assertion from IdP.');
}
SimpleSAML_Utilities::debugMessage($response, 'in');
\SimpleSAML\Utils\XML::debugSAMLMessage($response, 'in');
/* Find the response in the SOAP message. */
$response = self::extractResponse($response);
......
......@@ -78,7 +78,7 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
$response = $responsedom->saveXML();
SimpleSAML_Utilities::debugMessage($response, 'out');
\SimpleSAML\Utils\XML::debugSAMLMessage($response, 'out');
\SimpleSAML\Utils\HTTP::submitPOSTData($shire, array(
'TARGET' => $relayState,
......@@ -103,7 +103,7 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
$rawResponse = $post['SAMLResponse'];
$samlResponseXML = base64_decode($rawResponse);
SimpleSAML_Utilities::debugMessage($samlResponseXML, 'in');
\SimpleSAML\Utils\XML::debugSAMLMessage($samlResponseXML, 'in');
SimpleSAML_Utilities::validateXMLDocument($samlResponseXML, 'saml11');
......
......@@ -886,45 +886,10 @@ class SimpleSAML_Utilities {
/**
* Helper function to log messages that we send or receive.
*
* @param string|DOMElement $message The message, as an XML string or an XML element.
* @param string $type Whether this message is sent or received, encrypted or decrypted.
* @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::debugSAMLMessage() instead.
*/
public static function debugMessage($message, $type) {
assert('is_string($message) || $message instanceof DOMElement');
$globalConfig = SimpleSAML_Configuration::getInstance();
if (!$globalConfig->getBoolean('debug', FALSE)) {
/* Message debug disabled. */
return;
}
if ($message instanceof DOMElement) {
$message = $message->ownerDocument->saveXML($message);
}
switch ($type) {
case 'in':
SimpleSAML_Logger::debug('Received message:');
break;
case 'out':
SimpleSAML_Logger::debug('Sending message:');
break;
case 'decrypt':
SimpleSAML_Logger::debug('Decrypted message:');
break;
case 'encrypt':
SimpleSAML_Logger::debug('Encrypted message:');
break;
default:
assert(FALSE);
}
$str = SimpleSAML\Utils\XML::formatXMLString($message);
foreach (explode("\n", $str) as $line) {
SimpleSAML_Logger::debug($line);
}
return \SimpleSAML\Utils\XML::debugSAMLMessage($message, $type);
}
......
......@@ -11,6 +11,61 @@ namespace SimpleSAML\Utils;
class XML
{
/**
* Helper function to log SAML messages that we send or receive.
*
* @param string|\DOMElement $message The message, as an string containing the XML or an XML element.
* @param string $type Whether this message is sent or received, encrypted or decrypted. The following
* values are supported:
* - 'in': for messages received.
* - 'out': for outgoing messages.
* - 'decrypt': for decrypted messages.
* - 'encrypt': for encrypted messages.
*
* @throws \SimpleSAML_Error_Exception If $type is not a string or $message is neither a string nor a \DOMElement.
*
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
*/
public static function debugSAMLMessage($message, $type)
{
if (!(is_string($type) && (is_string($message) || $message instanceof \DOMElement))) {
throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
}
$globalConfig = \SimpleSAML_Configuration::getInstance();
if (!$globalConfig->getBoolean('debug', false)) {
// message debug disabled
return;
}
if ($message instanceof \DOMElement) {
$message = $message->ownerDocument->saveXML($message);
}
switch ($type) {
case 'in':
\SimpleSAML_Logger::debug('Received message:');
break;
case 'out':
\SimpleSAML_Logger::debug('Sending message:');
break;
case 'decrypt':
\SimpleSAML_Logger::debug('Decrypted message:');
break;
case 'encrypt':
\SimpleSAML_Logger::debug('Encrypted message:');
break;
default:
assert(false);
}
$str = self::formatXMLString($message);
foreach (explode("\n", $str) as $line) {
\SimpleSAML_Logger::debug($line);
}
}
/**
* Format a DOM element.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment