|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SAML2; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class which implements the SOAP binding. |
|
7
|
|
|
* |
|
8
|
|
|
* @package SimpleSAMLphp |
|
9
|
|
|
*/ |
|
10
|
|
|
class SOAP extends Binding |
|
11
|
|
|
{ |
|
12
|
|
|
public function getOutputToSend(Message $message) |
|
13
|
|
|
{ |
|
14
|
|
|
$outputFromIdp = '<?xml version="1.0" encoding="UTF-8"?>'; |
|
15
|
|
|
$outputFromIdp .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">'; |
|
16
|
|
|
$outputFromIdp .= '<SOAP-ENV:Body>'; |
|
17
|
|
|
$xmlMessage = $message->toSignedXML(); |
|
18
|
|
|
Utils::getContainer()->debugMessage($xmlMessage, 'out'); |
|
|
|
|
|
|
19
|
|
|
$tempOutputFromIdp = $xmlMessage->ownerDocument->saveXML($xmlMessage); |
|
20
|
|
|
$outputFromIdp .= $tempOutputFromIdp; |
|
21
|
|
|
$outputFromIdp .= '</SOAP-ENV:Body>'; |
|
22
|
|
|
$outputFromIdp .= '</SOAP-ENV:Envelope>'; |
|
23
|
|
|
|
|
24
|
|
|
return $outputFromIdp; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Send a SAML 2 message using the SOAP binding. |
|
29
|
|
|
* |
|
30
|
|
|
* Note: This function never returns. |
|
31
|
|
|
* |
|
32
|
|
|
* @param \SAML2\Message $message The message we should send. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function send(Message $message) |
|
35
|
|
|
{ |
|
36
|
|
|
header('Content-Type: text/xml', true); |
|
37
|
|
|
print($this->getOutputToSend($message)); |
|
38
|
|
|
exit(0); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Receive a SAML 2 message sent using the HTTP-POST binding. |
|
43
|
|
|
* |
|
44
|
|
|
* Throws an exception if it is unable receive the message. |
|
45
|
|
|
* |
|
46
|
|
|
* @return \SAML2\Message The received message. |
|
47
|
|
|
* @throws \Exception |
|
48
|
|
|
*/ |
|
49
|
|
|
public function receive() |
|
50
|
|
|
{ |
|
51
|
|
|
$postText = $this->getInputStream(); |
|
52
|
|
|
|
|
53
|
|
|
if (empty($postText)) { |
|
54
|
|
|
throw new \Exception('Invalid message received to AssertionConsumerService endpoint.'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$document = DOMDocumentFactory::fromString($postText); |
|
58
|
|
|
$xml = $document->firstChild; |
|
59
|
|
|
Utils::getContainer()->debugMessage($xml, 'in'); |
|
|
|
|
|
|
60
|
|
|
$results = Utils::xpQuery($xml, '/soap-env:Envelope/soap-env:Body/*[1]'); |
|
61
|
|
|
|
|
62
|
|
|
return Message::fromXML($results[0]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
protected function getInputStream() |
|
66
|
|
|
{ |
|
67
|
|
|
return file_get_contents('php://input'); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: