ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
HTTPPost.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2;
4
10class HTTPPost extends Binding
11{
19 public function send(Message $message)
20 {
21 if ($this->destination === null) {
22 $destination = $message->getDestination();
23 } else {
25 }
26 $relayState = $message->getRelayState();
27
28 $msgStr = $message->toSignedXML();
29 $msgStr = $msgStr->ownerDocument->saveXML($msgStr);
30
31 Utils::getContainer()->debugMessage($msgStr, 'out');
32
33 $msgStr = base64_encode($msgStr);
34
35 if ($message instanceof Request) {
36 $msgType = 'SAMLRequest';
37 } else {
38 $msgType = 'SAMLResponse';
39 }
40
41 $post = array();
42 $post[$msgType] = $msgStr;
43
44 if ($relayState !== null) {
45 $post['RelayState'] = $relayState;
46 }
47
48 Utils::getContainer()->postRedirect($destination, $post);
49 }
50
59 public function receive()
60 {
61 if (array_key_exists('SAMLRequest', $_POST)) {
62 $msg = $_POST['SAMLRequest'];
63 } elseif (array_key_exists('SAMLResponse', $_POST)) {
64 $msg = $_POST['SAMLResponse'];
65 } else {
66 throw new \Exception('Missing SAMLRequest or SAMLResponse parameter.');
67 }
68
69 $msg = base64_decode($msg);
70
71 Utils::getContainer()->debugMessage($msg, 'in');
72
73 $document = DOMDocumentFactory::fromString($msg);
74 $xml = $document->firstChild;
75
76 $msg = Message::fromXML($xml);
77
78 if (array_key_exists('RelayState', $_POST)) {
79 $msg->setRelayState($_POST['RelayState']);
80 }
81
82 return $msg;
83 }
84}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
send(Message $message)
Send a SAML 2 message using the HTTP-POST binding.
Definition: HTTPPost.php:19
receive()
Receive a SAML 2 message sent using the HTTP-POST binding.
Definition: HTTPPost.php:59
Base class for all SAML 2 messages.
Definition: Message.php:19
$xml
Definition: metadata.php:240
catch(Exception $e) $message
$destination
$relayState
$post
Definition: post.php:34