ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SOAP.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2;
4
5use DOMDocument;
6
7use SAML2\XML\ecp\Response as ECPResponse;
8
14class SOAP extends Binding
15{
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>
24SOAP;
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 }
56
66 public function send(Message $message)
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 }
76
85 public function receive()
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 }
100
101 protected function getInputStream()
102 {
103 return file_get_contents('php://input');
104 }
105}
exit
Definition: backend.php:16
An exception for terminatinating execution or to throw for unit testing.
Base class for all SAML 2 messages.
Definition: Message.php:19
getOutputToSend(Message $message)
Definition: SOAP.php:16
receive()
Receive a SAML 2 message sent using the HTTP-POST binding.
Definition: SOAP.php:85
send(Message $message)
Send a SAML 2 message using the SOAP binding.
Definition: SOAP.php:66
getInputStream()
Definition: SOAP.php:101
Class representing the ECP Response element.
Definition: Response.php:14
catch(Exception $e) $message
$response
$results
Definition: svg-scanner.php:47