1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the LightSAML-IDP package. |
5
|
|
|
* |
6
|
|
|
* (c) Milos Tomic <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the GPL-3 license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LightSaml\Idp\Builder\Action\Profile\SingleSignOn\Idp; |
13
|
|
|
|
14
|
|
|
use LightSaml\Action\Profile\Inbound\Message\ResolvePartyEntityIdAction; |
15
|
|
|
use LightSaml\Action\Profile\Outbound\Message\CreateMessageIssuerAction; |
16
|
|
|
use LightSaml\Action\Profile\Outbound\Message\DestinationAction; |
17
|
|
|
use LightSaml\Action\Profile\Outbound\Message\ForwardRelayStateAction; |
18
|
|
|
use LightSaml\Action\Profile\Outbound\Message\MessageIdAction; |
19
|
|
|
use LightSaml\Action\Profile\Outbound\Message\MessageIssueInstantAction; |
20
|
|
|
use LightSaml\Action\Profile\Outbound\Message\ResolveEndpointSpAcsAction; |
21
|
|
|
use LightSaml\Action\Profile\Outbound\Message\SendMessageAction; |
22
|
|
|
use LightSaml\Action\Profile\Outbound\Message\SignMessageAction; |
23
|
|
|
use LightSaml\Action\Profile\Outbound\Message\MessageVersionAction; |
24
|
|
|
use LightSaml\Idp\Action\Profile\Outbound\Response\HandleAssertionsAction; |
25
|
|
|
use LightSaml\Idp\Action\Profile\Outbound\Response\CreateResponseAction; |
26
|
|
|
use LightSaml\Idp\Action\Profile\Outbound\StatusResponse\InResponseToAction; |
27
|
|
|
use LightSaml\Idp\Action\Profile\Outbound\StatusResponse\SetStatusAction; |
28
|
|
|
use LightSaml\Builder\Action\ActionBuilderInterface; |
29
|
|
|
use LightSaml\Builder\Action\Profile\AbstractProfileActionBuilder; |
30
|
|
|
use LightSaml\Error\LightSamlException; |
31
|
|
|
use LightSaml\SamlConstants; |
32
|
|
|
|
33
|
|
|
class SsoIdpSendResponseActionBuilder extends AbstractProfileActionBuilder |
34
|
|
|
{ |
35
|
|
|
/** @var ActionBuilderInterface[] */ |
36
|
|
|
private $assertionActions = array(); |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param ActionBuilderInterface $assertionBuilder |
40
|
|
|
* |
41
|
|
|
* @return SsoIdpSendResponseActionBuilder |
42
|
|
|
*/ |
43
|
|
|
public function addAssertionBuilder(ActionBuilderInterface $assertionBuilder) |
44
|
|
|
{ |
45
|
|
|
$this->assertionActions[] = $assertionBuilder; |
46
|
|
|
|
47
|
|
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
protected function doInitialize() |
54
|
|
|
{ |
55
|
|
|
if (empty($this->assertionActions)) { |
56
|
|
|
throw new LightSamlException('No assertion builder set'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
// Receive |
60
|
|
|
$this->add(new ResolvePartyEntityIdAction( |
61
|
|
|
$this->buildContainer->getSystemContainer()->getLogger(), |
62
|
|
|
$this->buildContainer->getPartyContainer()->getSpEntityDescriptorStore(), |
63
|
|
|
$this->buildContainer->getPartyContainer()->getIdpEntityDescriptorStore(), |
64
|
|
|
$this->buildContainer->getPartyContainer()->getTrustOptionsStore() |
65
|
|
|
), 100); |
66
|
|
|
|
67
|
|
|
// Response building |
68
|
|
|
$this->add(new ResolveEndpointSpAcsAction( |
69
|
|
|
$this->buildContainer->getSystemContainer()->getLogger(), |
70
|
|
|
$this->buildContainer->getServiceContainer()->getEndpointResolver() |
71
|
|
|
), 300); |
72
|
|
|
$this->add(new CreateResponseAction( |
73
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
74
|
|
|
)); |
75
|
|
|
$this->add(new ForwardRelayStateAction( |
76
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
77
|
|
|
)); |
78
|
|
|
$this->add(new MessageIdAction( |
79
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
80
|
|
|
)); |
81
|
|
|
$this->add(new MessageVersionAction( |
82
|
|
|
$this->buildContainer->getSystemContainer()->getLogger(), |
83
|
|
|
SamlConstants::VERSION_20 |
84
|
|
|
)); |
85
|
|
|
$this->add(new MessageIssueInstantAction( |
86
|
|
|
$this->buildContainer->getSystemContainer()->getLogger(), |
87
|
|
|
$this->buildContainer->getSystemContainer()->getTimeProvider() |
88
|
|
|
)); |
89
|
|
|
$this->add(new DestinationAction( |
90
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
91
|
|
|
)); |
92
|
|
|
$this->add(new CreateMessageIssuerAction( |
93
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
94
|
|
|
)); |
95
|
|
|
$this->add(new SignMessageAction( |
96
|
|
|
$this->buildContainer->getSystemContainer()->getLogger(), |
97
|
|
|
$this->buildContainer->getServiceContainer()->getSignatureResolver() |
98
|
|
|
)); |
99
|
|
|
|
100
|
|
|
$assertionAction = new HandleAssertionsAction( |
101
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
102
|
|
|
); |
103
|
|
|
foreach ($this->assertionActions as $assertionActionBuilder) { |
104
|
|
|
$assertionAction->add($assertionActionBuilder->build()); |
105
|
|
|
} |
106
|
|
|
$this->add($assertionAction); |
107
|
|
|
|
108
|
|
|
$this->add(new InResponseToAction( |
109
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
110
|
|
|
)); |
111
|
|
|
|
112
|
|
|
$this->add(new SetStatusAction( |
113
|
|
|
$this->buildContainer->getSystemContainer()->getLogger() |
114
|
|
|
)); |
115
|
|
|
|
116
|
|
|
// Send |
117
|
|
|
$this->add(new SendMessageAction( |
118
|
|
|
$this->buildContainer->getSystemContainer()->getLogger(), |
119
|
|
|
$this->buildContainer->getServiceContainer()->getBindingFactory() |
120
|
|
|
), 400); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|