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\Profile\WebBrowserSso\Idp; |
13
|
|
|
|
14
|
|
|
use LightSaml\Build\Container\BuildContainerInterface; |
15
|
|
|
use LightSaml\Builder\Action\ActionBuilderInterface; |
16
|
|
|
use LightSaml\Idp\Builder\Action\Profile\SingleSignOn\Idp\SsoIdpSendResponseActionBuilder; |
17
|
|
|
use LightSaml\Builder\Profile\AbstractProfileBuilder; |
18
|
|
|
use LightSaml\Context\Profile\ProfileContext; |
19
|
|
|
use LightSaml\Meta\TrustOptions\TrustOptions; |
20
|
|
|
use LightSaml\Model\Metadata\Endpoint; |
21
|
|
|
use LightSaml\Model\Metadata\EntityDescriptor; |
22
|
|
|
use LightSaml\Model\Protocol\SamlMessage; |
23
|
|
|
use LightSaml\Profile\Profiles; |
24
|
|
|
|
25
|
|
|
class SsoIdpSendResponseProfileBuilder extends AbstractProfileBuilder |
26
|
|
|
{ |
27
|
|
|
/** @var ActionBuilderInterface[] */ |
28
|
|
|
private $assertionBuilders = array(); |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
private $entityId; |
32
|
|
|
|
33
|
|
|
/** @var EntityDescriptor */ |
34
|
|
|
private $partyEntityDescriptor; |
35
|
|
|
|
36
|
|
|
/** @var TrustOptions */ |
37
|
|
|
private $partyTrustOptions; |
38
|
|
|
|
39
|
|
|
/** @var Endpoint */ |
40
|
|
|
private $endpoint; |
41
|
|
|
|
42
|
|
|
/** @var SamlMessage */ |
43
|
|
|
private $message; |
44
|
|
|
|
45
|
|
|
/** @var string */ |
46
|
|
|
private $relayState; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param BuildContainerInterface $buildContainer |
50
|
|
|
* @param ActionBuilderInterface[] $assertionBuilders |
51
|
|
|
* @param string $entityId |
52
|
|
|
*/ |
53
|
|
|
public function __construct(BuildContainerInterface $buildContainer, array $assertionBuilders, $entityId) |
54
|
|
|
{ |
55
|
|
|
parent::__construct($buildContainer); |
56
|
|
|
|
57
|
|
|
$this->entityId = $entityId; |
58
|
|
|
foreach ($assertionBuilders as $builder) { |
59
|
|
|
$this->addAssertionBuilder($builder); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param EntityDescriptor $entityDescriptor |
65
|
|
|
* |
66
|
|
|
* @return SsoIdpSendResponseProfileBuilder |
67
|
|
|
*/ |
68
|
|
|
public function setPartyEntityDescriptor(EntityDescriptor $entityDescriptor) |
69
|
|
|
{ |
70
|
|
|
$this->partyEntityDescriptor = $entityDescriptor; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param TrustOptions $partyTrustOptions |
77
|
|
|
* |
78
|
|
|
* @return SsoIdpSendResponseProfileBuilder |
79
|
|
|
*/ |
80
|
|
|
public function setPartyTrustOptions(TrustOptions $partyTrustOptions) |
81
|
|
|
{ |
82
|
|
|
$this->partyTrustOptions = $partyTrustOptions; |
83
|
|
|
|
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param Endpoint $endpoint |
89
|
|
|
* |
90
|
|
|
* @return SsoIdpSendResponseProfileBuilder |
91
|
|
|
*/ |
92
|
|
|
public function setEndpoint(Endpoint $endpoint) |
93
|
|
|
{ |
94
|
|
|
$this->endpoint = $endpoint; |
95
|
|
|
|
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param SamlMessage $message |
101
|
|
|
* |
102
|
|
|
* @return SsoIdpSendResponseProfileBuilder |
103
|
|
|
*/ |
104
|
|
|
public function setMessage($message) |
105
|
|
|
{ |
106
|
|
|
$this->message = $message; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param string $relayState |
113
|
|
|
* |
114
|
|
|
* @return SsoIdpSendResponseProfileBuilder |
115
|
|
|
*/ |
116
|
|
|
public function setRelayState($relayState) |
117
|
|
|
{ |
118
|
|
|
$this->relayState = $relayState; |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param ActionBuilderInterface $assertionBuilder |
125
|
|
|
*/ |
126
|
|
|
private function addAssertionBuilder(ActionBuilderInterface $assertionBuilder) |
127
|
|
|
{ |
128
|
|
|
$this->assertionBuilders[] = $assertionBuilder; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
|
|
protected function getProfileId() |
135
|
|
|
{ |
136
|
|
|
return Profiles::SSO_IDP_SEND_RESPONSE; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
|
|
protected function getProfileRole() |
143
|
|
|
{ |
144
|
|
|
return ProfileContext::ROLE_IDP; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return SsoIdpSendResponseActionBuilder |
149
|
|
|
*/ |
150
|
|
|
protected function getActionBuilder() |
151
|
|
|
{ |
152
|
|
|
$result = new SsoIdpSendResponseActionBuilder($this->container); |
153
|
|
|
|
154
|
|
|
foreach ($this->assertionBuilders as $assertionAction) { |
155
|
|
|
$result->addAssertionBuilder($assertionAction); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
return $result; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return ProfileContext |
163
|
|
|
*/ |
164
|
|
|
public function buildContext() |
165
|
|
|
{ |
166
|
|
|
$result = parent::buildContext(); |
167
|
|
|
|
168
|
|
|
$result->getPartyEntityContext()->setEntityId($this->entityId); |
169
|
|
|
|
170
|
|
|
if ($this->partyEntityDescriptor) { |
171
|
|
|
$result->getPartyEntityContext()->setEntityDescriptor($this->partyEntityDescriptor); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
if ($this->partyTrustOptions) { |
175
|
|
|
$result->getPartyEntityContext()->setTrustOptions($this->partyTrustOptions); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
if ($this->endpoint) { |
179
|
|
|
$result->getEndpointContext()->setEndpoint($this->endpoint); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
if ($this->message) { |
183
|
|
|
$result->getInboundContext()->setMessage($this->message); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
if ($this->relayState) { |
187
|
|
|
$result->setRelayState($this->relayState); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
return $result; |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|