|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LightSaml\Logout\Action\Profile\Outbound\LogoutRequest; |
|
4
|
|
|
|
|
5
|
|
|
use LightSaml\Action\Profile\AbstractProfileAction; |
|
6
|
|
|
use LightSaml\Context\Profile\ProfileContext; |
|
7
|
|
|
use LightSaml\Error\LightSamlContextException; |
|
8
|
|
|
use LightSaml\Error\LightSamlProfileException; |
|
9
|
|
|
use LightSaml\Meta\TrustOptions\TrustOptions; |
|
10
|
|
|
use LightSaml\Store\EntityDescriptor\EntityDescriptorStoreInterface; |
|
11
|
|
|
use LightSaml\Store\TrustOptions\TrustOptionsStoreInterface; |
|
12
|
|
|
|
|
13
|
|
|
class ResolveLogoutPartyAction extends AbstractProfileAction |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var EntityDescriptorStoreInterface */ |
|
16
|
|
|
private $idpEntityDescriptorStore; |
|
17
|
|
|
|
|
18
|
|
|
/** @var EntityDescriptorStoreInterface */ |
|
19
|
|
|
private $spEntityDescriptorStore; |
|
20
|
|
|
|
|
21
|
|
|
/** @var TrustOptionsStoreInterface */ |
|
22
|
|
|
protected $trustOptionsProvider; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param EntityDescriptorStoreInterface $idpEntityDescriptorStore |
|
26
|
|
|
* @param EntityDescriptorStoreInterface $spEntityDescriptorStore |
|
27
|
|
|
* @param TrustOptionsStoreInterface $trustOptionsProvider |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct( |
|
30
|
|
|
EntityDescriptorStoreInterface $idpEntityDescriptorStore, |
|
31
|
|
|
EntityDescriptorStoreInterface $spEntityDescriptorStore, |
|
32
|
|
|
TrustOptionsStoreInterface $trustOptionsProvider |
|
33
|
|
|
) { |
|
34
|
|
|
$this->idpEntityDescriptorStore = $idpEntityDescriptorStore; |
|
35
|
|
|
$this->spEntityDescriptorStore = $spEntityDescriptorStore; |
|
36
|
|
|
$this->trustOptionsProvider = $trustOptionsProvider; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param ProfileContext $context |
|
41
|
|
|
*/ |
|
42
|
|
|
protected function doExecute(ProfileContext $context) |
|
43
|
|
|
{ |
|
44
|
|
|
$partyContext = $context->getPartyEntityContext(); |
|
45
|
|
|
|
|
46
|
|
|
$partyEntityDescriptor = $this->getPartyEntityDescriptor($context); |
|
47
|
|
|
$partyContext |
|
48
|
|
|
->setEntityId($partyEntityDescriptor->getEntityID()) |
|
49
|
|
|
->setEntityDescriptor($partyEntityDescriptor); |
|
50
|
|
|
|
|
51
|
|
|
$trustOptions = $this->trustOptionsProvider->get($partyContext->getEntityDescriptor()->getEntityID()); |
|
52
|
|
|
if (null === $trustOptions) { |
|
53
|
|
|
$trustOptions = new TrustOptions(); |
|
54
|
|
|
} |
|
55
|
|
|
$partyContext->setTrustOptions($trustOptions); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function getPartyEntityDescriptor(ProfileContext $context) |
|
59
|
|
|
{ |
|
60
|
|
|
$ssoSessionState = $context->getLogoutSsoSessionState(); |
|
61
|
|
|
$ownEntityId = $context->getOwnEntityDescriptor()->getEntityID(); |
|
62
|
|
|
$partyId = $ssoSessionState->getOtherPartyId($ownEntityId); |
|
63
|
|
|
|
|
64
|
|
|
$partyEntityDescriptor = $this->findParty($partyId, [$this->idpEntityDescriptorStore, $this->spEntityDescriptorStore]); |
|
65
|
|
|
|
|
66
|
|
|
if ($partyEntityDescriptor) { |
|
67
|
|
|
return $partyEntityDescriptor; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
throw new LightSamlContextException($context, sprintf('Unknown party "%s"', $partyId)); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param string $entityId |
|
75
|
|
|
* @param EntityDescriptorStoreInterface[] $entityDescriptorStores |
|
76
|
|
|
* |
|
77
|
|
|
* @return \LightSaml\Model\Metadata\EntityDescriptor|null |
|
78
|
|
|
*/ |
|
79
|
|
|
private function findParty($entityId, array $entityDescriptorStores) |
|
80
|
|
|
{ |
|
81
|
|
|
foreach ($entityDescriptorStores as $entityDescriptorStore) { |
|
82
|
|
|
$entityDescriptor = $entityDescriptorStore->get($entityId); |
|
|
|
|
|
|
83
|
|
|
if ($entityDescriptor) { |
|
84
|
|
|
return $entityDescriptor; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return null; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.