|
static | checkSAMLMessage ($message, $type) |
| This function performs some sanity checks on XML documents, and optionally validates them against their schema if the 'validatexml' debugging option is enabled. More...
|
|
static | debugSAMLMessage ($message, $type) |
| Helper function to log SAML messages that we send or receive. More...
|
|
static | formatXMLString ($xml, $indentBase='') |
| Format an XML string. More...
|
|
static | isDOMNodeOfType (\DOMNode $element, $name, $nsURI) |
| This function checks if the DOMElement has the correct localName and namespaceURI. More...
|
|
Definition at line 13 of file XML.php.
◆ checkSAMLMessage()
static SimpleSAML\Utils\XML::checkSAMLMessage |
( |
|
$message, |
|
|
|
$type |
|
) |
| |
|
static |
This function performs some sanity checks on XML documents, and optionally validates them against their schema if the 'validatexml' debugging option is enabled.
A warning will be printed to the log if validation fails.
- Parameters
-
string | $message | The SAML document we want to check. |
string | $type | The type of document. Can be one of:
- 'saml20'
- 'saml11'
- 'saml-meta'
|
- Exceptions
-
Definition at line 35 of file XML.php.
References Sabre\VObject\$debug, $message, $result, $type, SimpleSAML_Configuration\getInstance(), and SimpleSAML\Logger\warning().
Referenced by SimpleSAML\Bindings\Shib13\HTTPPost\decodeResponse(), SimpleSAML\Bindings\Shib13\HTTPPost\sendResponse(), and SimpleSAML_Utilities\validateXMLDocument().
37 $allowed_types = array(
'saml20',
'saml11',
'saml-meta');
38 if (!(is_string(
$message) && in_array(
$type, $allowed_types,
true))) {
39 throw new \InvalidArgumentException(
'Invalid input parameters.');
43 if (strpos(
$message,
'<!DOCTYPE') !==
false) {
44 throw new \SimpleSAML_Error_Exception(
'XML contained a doctype declaration.');
51 if (!(in_array(
'validatexml',
$debug,
true)
52 || (array_key_exists(
'validatexml',
$debug) &&
$debug[
'validatexml'] ===
true)
63 $result = self::isValid(
$message,
'oasis-sstc-saml-schema-protocol-1.1.xsd');
catch(Exception $e) $message
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
◆ debugSAMLMessage()
static SimpleSAML\Utils\XML::debugSAMLMessage |
( |
|
$message, |
|
|
|
$type |
|
) |
| |
|
static |
Helper function to log SAML messages that we send or receive.
- Parameters
-
string | \DOMElement | $message | The message, as an string containing the XML or an XML element. |
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.
|
- Exceptions
-
Definition at line 94 of file XML.php.
References Sabre\VObject\$debug, $i, $message, $root, $type, SimpleSAML\Logger\debug(), and SimpleSAML_Configuration\getInstance().
Referenced by SimpleSAML_Utilities\debugMessage(), SimpleSAML\Bindings\Shib13\HTTPPost\decodeResponse(), SimpleSAML\Bindings\Shib13\Artifact\extractResponse(), and SimpleSAML\Bindings\Shib13\HTTPPost\sendResponse().
97 throw new \InvalidArgumentException(
'Invalid input parameters.');
103 if (!(in_array(
'saml',
$debug,
true)
104 || (array_key_exists(
'saml',
$debug) &&
$debug[
'saml'] ===
true)
112 if (
$message instanceof \DOMElement) {
133 $str = self::formatXMLString(
$message);
134 foreach (explode(
"\n", $str) as $line) {
catch(Exception $e) $message
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
◆ formatXMLString()
static SimpleSAML\Utils\XML::formatXMLString |
( |
|
$xml, |
|
|
|
$indentBase = '' |
|
) |
| |
|
static |
Format an XML string.
This function formats an XML string using the formatDOMElement() function.
- Parameters
-
string | $xml | An XML string which should be formatted. |
string | $indentBase | Optional indentation which should be applied to all the output. Optional, defaults to ''. |
- Returns
- string The formatted string.
- Exceptions
-
Definition at line 246 of file XML.php.
References $i, $ret, $txt, $xml, and SAML2\DOMDocumentFactory\fromString().
Referenced by SimpleSAML_Utilities\formatXMLString().
248 if (!is_string(
$xml) || !is_string($indentBase)) {
249 throw new \InvalidArgumentException(
'Invalid input parameters');
255 throw new \DOMException(
'Error parsing XML string.');
258 $root = $doc->firstChild;
259 self::formatDOMElement(
$root, $indentBase);
261 return $doc->saveXML(
$root);
◆ isDOMNodeOfType()
static SimpleSAML\Utils\XML::isDOMNodeOfType |
( |
\DOMNode |
$element, |
|
|
|
$name, |
|
|
|
$nsURI |
|
) |
| |
|
static |
This function checks if the DOMElement has the correct localName and namespaceURI.
We also define the following shortcuts for namespaces:
- '': 'http://www.w3.org/2000/09/xmldsig#'
- '': 'urn:oasis:names:tc:SAML:2.0:metadata'
- '': 'urn:oasis:names:tc:SAML:1.0:assertion'
- '': 'urn:oasis:names:tc:SAML:profiles:v1metadata'
- '': 'urn:oasis:names:tc:SAML:1.0:protocol'
- '': 'urn:oasis:names:tc:SAML:2.0:assertion'
- '': 'urn:oasis:names:tc:SAML:2.0:protocol'
- Parameters
-
\DOMNode | $element | The element we should check. |
string | $name | The local name the element should have. |
string | $nsURI | The namespaceURI the element should have. |
- Returns
- boolean True if both namespace and local name matches, false otherwise.
- Exceptions
-
Definition at line 357 of file XML.php.
References $config, $errors, $name, $res, $xml, SimpleSAML\XML\Errors\begin(), SimpleSAML\XML\Errors\end(), SimpleSAML\XML\Errors\formatErrors(), SAML2\DOMDocumentFactory\fromString(), and SimpleSAML_Configuration\getInstance().
Referenced by SimpleSAML\Bindings\Shib13\Artifact\extractResponse(), and SimpleSAML_Utilities\isDOMElementOfType().
359 if (!is_string(
$name) || !is_string($nsURI) || strlen($nsURI) === 0) {
365 if ($nsURI[0] ===
'@') {
368 '@ds' =>
'http://www.w3.org/2000/09/xmldsig#',
369 '@md' =>
'urn:oasis:names:tc:SAML:2.0:metadata',
370 '@saml1' =>
'urn:oasis:names:tc:SAML:1.0:assertion',
371 '@saml1md' =>
'urn:oasis:names:tc:SAML:profiles:v1metadata',
372 '@saml1p' =>
'urn:oasis:names:tc:SAML:1.0:protocol',
373 '@saml2' =>
'urn:oasis:names:tc:SAML:2.0:assertion',
374 '@saml2p' =>
'urn:oasis:names:tc:SAML:2.0:protocol',
375 '@shibmd' =>
'urn:mace:shibboleth:metadata:1.0',
379 if (!array_key_exists($nsURI, $shortcuts)) {
380 throw new \InvalidArgumentException(
'Unknown namespace shortcut: '.$nsURI);
384 $nsURI = $shortcuts[$nsURI];
386 if ($element->localName !==
$name) {
389 if ($element->namespaceURI !== $nsURI) {
The documentation for this class was generated from the following file:
- libs/composer/vendor/simplesamlphp/simplesamlphp/lib/SimpleSAML/Utils/XML.php