ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SAML2\SOAP Class Reference
+ Inheritance diagram for SAML2\SOAP:
+ Collaboration diagram for SAML2\SOAP:

Public Member Functions

 getOutputToSend (Message $message)
 
 send (Message $message)
 Send a SAML 2 message using the SOAP binding. More...
 
 receive ()
 Receive a SAML 2 message sent using the HTTP-POST binding. More...
 
- Public Member Functions inherited from SAML2\Binding
 getDestination ()
 Retrieve the destination of a message. More...
 
 setDestination ($destination)
 Override the destination of a message. More...
 
 send (Message $message)
 Send a SAML 2 message. More...
 
 receive ()
 Receive a SAML 2 message. More...
 

Protected Member Functions

 getInputStream ()
 

Additional Inherited Members

- Static Public Member Functions inherited from SAML2\Binding
static getBinding ($urn)
 Retrieve a binding with the given URN. More...
 
static getCurrentBinding ()
 Guess the current binding. More...
 
- Protected Attributes inherited from SAML2\Binding
 $destination
 The destination of messages. More...
 

Detailed Description

Definition at line 14 of file SOAP.php.

Member Function Documentation

◆ getInputStream()

SAML2\SOAP::getInputStream ( )
protected

Definition at line 101 of file SOAP.php.

102  {
103  return file_get_contents('php://input');
104  }

◆ getOutputToSend()

SAML2\SOAP::getOutputToSend ( Message  $message)

Definition at line 16 of file SOAP.php.

References $header, $response, SAML2\Message\getDestination(), and SAML2\Message\toSignedXML().

17  {
18  $envelope = <<<SOAP
19 <?xml version="1.0" encoding="utf-8"?>
20 <SOAP-ENV:Envelope xmlns:SOAP-ENV="%s">
21  <SOAP-ENV:Header />
22  <SOAP-ENV:Body />
23 </SOAP-ENV:Envelope>
24 SOAP;
25  $envelope = sprintf($envelope, Constants::NS_SOAP);
26 
27  $doc = new DOMDocument;
28  $doc->loadXML($envelope);
29 
30  // In the Artifact Resolution profile, this will be an ArtifactResolve
31  // containing another message (e.g. a Response), however in the ECP
32  // profile, this is the Response itself.
33  if ($message instanceof Response) {
34  $header = $doc->getElementsByTagNameNS(Constants::NS_SOAP, 'Header')->item(0);
35 
36  $response = new ECPResponse;
37  $response->AssertionConsumerServiceURL = $this->getDestination() ?: $message->getDestination();
38 
39  $response->toXML($header);
40 
41  // TODO We SHOULD add ecp:RequestAuthenticated SOAP header if we
42  // authenticated the AuthnRequest. It may make sense to have a
43  // standardized way for Message objects to contain (optional) SOAP
44  // headers for use with the SOAP binding.
45  //
46  // https://docs.oasis-open.org/security/saml/Post2.0/saml-ecp/v2.0/cs01/saml-ecp-v2.0-cs01.html#_Toc366664733
47  // See Section 2.3.6.1
48  }
49 
50  $body = $doc->getElementsByTagNameNs(Constants::NS_SOAP, 'Body')->item(0);
51 
52  $body->appendChild($doc->importNode($message->toSignedXML(), true));
53 
54  return $doc->saveXML();
55  }
const NS_SOAP
The namespace for the SOAP protocol.
Definition: Constants.php:215
getDestination()
Retrieve the destination of a message.
Definition: Binding.php:112
catch(Exception $e) $message
$response
+ Here is the call graph for this function:

◆ receive()

SAML2\SOAP::receive ( )

Receive a SAML 2 message sent using the HTTP-POST binding.

Throws an exception if it is unable receive the message.

Returns
The received message.
Exceptions

Definition at line 85 of file SOAP.php.

References $results, and $xml.

86  {
87  $postText = $this->getInputStream();
88 
89  if (empty($postText)) {
90  throw new \Exception('Invalid message received to AssertionConsumerService endpoint.');
91  }
92 
93  $document = DOMDocumentFactory::fromString($postText);
94  $xml = $document->firstChild;
95  Utils::getContainer()->debugMessage($xml, 'in');
96  $results = Utils::xpQuery($xml, '/soap-env:Envelope/soap-env:Body/*[1]');
97 
98  return Message::fromXML($results[0]);
99  }
getInputStream()
Definition: SOAP.php:101
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
$results
Definition: svg-scanner.php:47
static fromXML(\DOMElement $xml)
Convert an XML element into a message.
Definition: Message.php:562
static getContainer()
Definition: Utils.php:752

◆ send()

SAML2\SOAP::send ( Message  $message)

Send a SAML 2 message using the SOAP binding.

Note: This function never returns.

Parameters
\SAML2\Message$messageThe message we should send.

(PHPMD.ExitExpression)

Definition at line 66 of file SOAP.php.

References $xml, and exit.

67  {
68  header('Content-Type: text/xml', true);
69 
70  $xml = $this->getOutputToSend($message);
71  Utils::getContainer()->debugMessage($xml, 'out');
72  echo $xml;
73 
74  exit(0);
75  }
catch(Exception $e) $message
getOutputToSend(Message $message)
Definition: SOAP.php:16
exit
Definition: backend.php:16
static getContainer()
Definition: Utils.php:752

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