1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once __DIR__.'/_config.php'; |
4
|
|
|
|
5
|
|
|
$buildContainer = SpConfig::current()->getBuildContainer(); |
6
|
|
|
$builder = new \LightSaml\Builder\Profile\WebBrowserSso\Sp\SsoSpReceiveResponseProfileBuilder($buildContainer); |
7
|
|
|
|
8
|
|
|
$context = $builder->buildContext(); |
9
|
|
|
$action = $builder->buildAction(); |
10
|
|
|
|
11
|
|
|
if (SpConfig::current()->debug) { |
12
|
|
|
var_dump('ACTION TREE'); |
13
|
|
|
var_dump($action->__toString()); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
try { |
17
|
|
|
$action->execute($context); |
18
|
|
|
} catch (\Exception $ex) { |
19
|
|
|
var_dump('CONTEXT TREE'); |
20
|
|
|
var_dump($context->__toString()); |
21
|
|
|
throw new \RuntimeException('Error', 0, $ex); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
var_dump('CONTEXT TREE'); |
25
|
|
|
var_dump($context->__toString()); |
26
|
|
|
|
27
|
|
|
$response = \LightSaml\Context\Profile\Helper\MessageContextHelper::asResponse($context->getInboundContext()); |
|
|
|
|
28
|
|
|
|
29
|
|
|
var_dump('RELAY STATE'); |
30
|
|
|
var_dump($response->getRelayState()); |
31
|
|
|
|
32
|
|
|
var_dump('ATTRIBUTES'); |
33
|
|
|
foreach ($response->getAllAssertions() as $assertion) { |
34
|
|
|
foreach ($assertion->getAllAttributeStatements() as $attributeStatement) { |
35
|
|
|
foreach ($attributeStatement->getAllAttributes() as $attribute) { |
36
|
|
|
var_dump($attribute); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** @var \LightSaml\Model\Context\DeserializationContext $inboundMessageDeserializationContext */ |
42
|
|
|
$inboundMessageDeserializationContext = $context->getPath('inbound_message/deserialization'); |
43
|
|
|
$inboundMessageDeserializationContext->getDocument()->formatOutput = true; |
44
|
|
|
var_dump('RECEIVED MESSAGE'); |
45
|
|
|
var_dump($inboundMessageDeserializationContext->getDocument()->saveXML()); |
46
|
|
|
|
47
|
|
|
/** @var \LightSaml\Model\Context\DeserializationContext $decryptedAssertionContext */ |
48
|
|
|
$decryptedAssertionContext = $context->getPath('inbound_message/assertion_encrypted_0'); |
49
|
|
|
if ($decryptedAssertionContext) { |
50
|
|
|
$decryptedAssertionContext->getDocument()->formatOutput = true; |
51
|
|
|
var_dump('DECRYPTED ASSERTION'); |
52
|
|
|
var_dump($decryptedAssertionContext->getDocument()->saveXML()); |
53
|
|
|
} |
54
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: