1 | <?php |
||
36 | class SamlInteractionProvider |
||
37 | { |
||
38 | /** |
||
39 | * @var \Surfnet\SamlBundle\Entity\ServiceProvider |
||
40 | */ |
||
41 | private $serviceProvider; |
||
42 | |||
43 | /** |
||
44 | * @var \Surfnet\SamlBundle\Entity\IdentityProvider |
||
45 | */ |
||
46 | private $identityProvider; |
||
47 | |||
48 | /** |
||
49 | * @var \Surfnet\SamlBundle\Http\RedirectBinding |
||
50 | */ |
||
51 | private $redirectBinding; |
||
52 | |||
53 | /** |
||
54 | * @var \Surfnet\SamlBundle\Http\PostBinding |
||
55 | */ |
||
56 | private $postBinding; |
||
57 | |||
58 | /** |
||
59 | * @var \Surfnet\StepupRa\RaBundle\Security\Authentication\SamlAuthenticationStateHandler |
||
60 | */ |
||
61 | private $samlAuthenticationStateHandler; |
||
62 | |||
63 | /** |
||
64 | * @var \Surfnet\StepupBundle\Service\LoaResolutionService |
||
65 | */ |
||
66 | private $loaResolutionService; |
||
67 | |||
68 | /** |
||
69 | * @var \Surfnet\StepupBundle\Value\Loa |
||
70 | */ |
||
71 | private $requiredLoa; |
||
72 | |||
73 | public function __construct( |
||
90 | |||
91 | /** |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function isSamlAuthenticationInitiated() |
||
98 | |||
99 | /** |
||
100 | * @return \Symfony\Component\HttpFoundation\RedirectResponse |
||
101 | */ |
||
102 | public function initiateSamlRequest() |
||
115 | |||
116 | /** |
||
117 | * @param Request $request |
||
118 | * @return \SAML2\Assertion |
||
119 | * @throws LoaTooLowException When required LoA is not met by response |
||
120 | * @throws AuthenticationException When response LoA cannot be resolved |
||
121 | * @throws UnexpectedIssuerException |
||
122 | */ |
||
123 | public function processSamlResponse(Request $request) |
||
124 | { |
||
125 | /** @var \SAML2\Assertion $assertion */ |
||
126 | $assertion = $this->postBinding->processResponse( |
||
127 | $request, |
||
128 | $this->identityProvider, |
||
129 | $this->serviceProvider |
||
130 | ); |
||
131 | |||
132 | $this->samlAuthenticationStateHandler->clearRequestId(); |
||
133 | |||
134 | if ($assertion->getIssuer() !== $this->identityProvider->getEntityId()) { |
||
135 | throw new UnexpectedIssuerException(sprintf( |
||
136 | 'Expected issuer to be configured remote IdP "%s", got "%s"', |
||
137 | $this->identityProvider->getEntityId(), |
||
138 | $assertion->getIssuer() |
||
139 | )); |
||
140 | } |
||
141 | |||
142 | $authnContextClassRef = $assertion->getAuthnContextClassRef(); |
||
143 | if (!$this->loaResolutionService->hasLoa($authnContextClassRef)) { |
||
144 | throw new AuthenticationException('Received SAML response with unresolvable LoA'); |
||
145 | } |
||
146 | |||
147 | if (!$this->loaResolutionService->getLoa($authnContextClassRef)->canSatisfyLoa($this->requiredLoa)) { |
||
148 | throw new LoaTooLowException( |
||
149 | sprintf( |
||
150 | "Gateway responded with LoA '%s', which is lower than required LoA '%s'", |
||
151 | $assertion->getAuthnContextClassRef(), |
||
152 | (string) $this->requiredLoa |
||
153 | ) |
||
154 | ); |
||
155 | } |
||
156 | |||
157 | return $assertion; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * Resets the SAML flow. |
||
162 | */ |
||
163 | public function reset() |
||
167 | } |
||
168 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.