ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleSAML\Bindings\Shib13\Artifact Class Reference
+ Collaboration diagram for SimpleSAML\Bindings\Shib13\Artifact:

Static Private Member Functions

static getArtifacts ()
 Parse the query string, and extract the SAMLart parameters. More...
 
static buildRequest (array $artifacts)
 Build the request we will send to the IdP. More...
 
static extractResponse ($soapResponse)
 Extract the response element from the SOAP response. More...
 

Detailed Description

Definition at line 19 of file Artifact.php.

Member Function Documentation

◆ buildRequest()

static SimpleSAML\Bindings\Shib13\Artifact::buildRequest ( array  $artifacts)
staticprivate

Build the request we will send to the IdP.

Parameters
array$artifactsThe artifacts we will request.
Returns
string The request, as an XML string.

Definition at line 59 of file Artifact.php.

References SimpleSAML\Utils\Random\generateID(), and SimpleSAML\Utils\Time\generateTimestamp().

60  {
61  $msg = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' .
62  '<SOAP-ENV:Body>' .
63  '<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"' .
64  ' RequestID="' . Random::generateID() . '"' .
65  ' MajorVersion="1" MinorVersion="1"' .
66  ' IssueInstant="' . Time::generateTimestamp() . '"' .
67  '>';
68 
69  foreach ($artifacts as $a) {
70  $msg .= '<samlp:AssertionArtifact>' . htmlspecialchars($a) . '</samlp:AssertionArtifact>';
71  }
72 
73  $msg .= '</samlp:Request>' .
74  '</SOAP-ENV:Body>' .
75  '</SOAP-ENV:Envelope>';
76 
77  return $msg;
78  }
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
Definition: Random.php:26
static generateTimestamp($instant=null)
This function generates a timestamp on the form used by the SAML protocols.
Definition: Time.php:31
+ Here is the call graph for this function:

◆ extractResponse()

static SimpleSAML\Bindings\Shib13\Artifact::extractResponse (   $soapResponse)
staticprivate

Extract the response element from the SOAP response.

Parameters
string$soapResponseThe SOAP response.
Returns
string The <saml1p:Response> element, as a string.
Exceptions

Definition at line 88 of file Artifact.php.

References $idpMetadata, $key, $request, $response, $spMetadata, $url, SAML2\DOMDocumentFactory\create(), SimpleSAML\Utils\XML\debugSAMLMessage(), SimpleSAML\Utils\HTTP\fetch(), SAML2\DOMDocumentFactory\fromString(), SimpleSAML\Utils\Config\getCertPath(), SimpleSAML_Configuration\getDefaultEndpoint(), SimpleSAML_Configuration\getPublicKeys(), SimpleSAML_Configuration\getString(), SimpleSAML\Utils\System\getTempDir(), SimpleSAML\Utils\XML\isDOMNodeOfType(), and SimpleSAML\Utils\System\writeFile().

89  {
90  assert(is_string($soapResponse));
91 
92  try {
93  $doc = DOMDocumentFactory::fromString($soapResponse);
94  } catch (\Exception $e) {
95  throw new \SimpleSAML_Error_Exception('Error parsing SAML 1 artifact response.');
96  }
97 
98  $soapEnvelope = $doc->firstChild;
99  if (!XML::isDOMNodeOfType($soapEnvelope, 'Envelope', 'http://schemas.xmlsoap.org/soap/envelope/')) {
100  throw new \SimpleSAML_Error_Exception('Expected artifact response to contain a <soap:Envelope> element.');
101  }
102 
103  $soapBody = XML::getDOMChildren($soapEnvelope, 'Body', 'http://schemas.xmlsoap.org/soap/envelope/');
104  if (count($soapBody) === 0) {
105  throw new \SimpleSAML_Error_Exception('Couldn\'t find <soap:Body> in <soap:Envelope>.');
106  }
107  $soapBody = $soapBody[0];
108 
109 
110  $responseElement = XML::getDOMChildren($soapBody, 'Response', 'urn:oasis:names:tc:SAML:1.0:protocol');
111  if (count($responseElement) === 0) {
112  throw new \SimpleSAML_Error_Exception('Couldn\'t find <saml1p:Response> in <soap:Body>.');
113  }
114  $responseElement = $responseElement[0];
115 
116  /*
117  * Save the <saml1p:Response> element. Note that we need to import it
118  * into a new document, in order to preserve namespace declarations.
119  */
120  $newDoc = DOMDocumentFactory::create();
121  $newDoc->appendChild($newDoc->importNode($responseElement, true));
122  $responseXML = $newDoc->saveXML();
123 
124  return $responseXML;
125  }
static isDOMNodeOfType(\DOMNode $element, $name, $nsURI)
This function checks if the DOMElement has the correct localName and namespaceURI.
Definition: XML.php:357
+ Here is the call graph for this function:

◆ getArtifacts()

static SimpleSAML\Bindings\Shib13\Artifact::getArtifacts ( )
staticprivate

Parse the query string, and extract the SAMLart parameters.

This function is required because each query contains multiple artifact with the same parameter name.

Returns
array The artifacts.

Definition at line 30 of file Artifact.php.

References $_SERVER, and $name.

31  {
32  assert(array_key_exists('QUERY_STRING', $_SERVER));
33 
34  // We need to process the query string manually, to capture all SAMLart parameters
35 
36  $artifacts = array();
37 
38  $elements = explode('&', $_SERVER['QUERY_STRING']);
39  foreach ($elements as $element) {
40  list($name, $value) = explode('=', $element, 2);
41  $name = urldecode($name);
42  $value = urldecode($value);
43 
44  if ($name === 'SAMLart') {
45  $artifacts[] = $value;
46  }
47  }
48 
49  return $artifacts;
50  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

The documentation for this class was generated from the following file: