Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
44 | class GatewayController extends Controller |
||
|
|||
45 | { |
||
46 | const RESPONSE_CONTEXT_SERVICE_ID = 'gateway.proxy.response_context'; |
||
47 | const MODE_SFO = 'sfo'; |
||
48 | const MODE_SSO = 'sso'; |
||
49 | |||
50 | /** |
||
51 | * Receive an AuthnRequest from a service provider. |
||
52 | * |
||
53 | * The service provider is either a Stepup component (SelfService, RA) or |
||
54 | * an external service provider. |
||
55 | * |
||
56 | * This single sign-on action will start a new SAML request to the remote |
||
57 | * IDP configured in Stepup (most likely to be an instance of OpenConext |
||
58 | * EngineBlock). |
||
59 | * |
||
60 | * @param Request $httpRequest |
||
61 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response |
||
62 | */ |
||
63 | public function ssoAction(Request $httpRequest) |
||
85 | |||
86 | /** |
||
87 | * |
||
88 | */ |
||
89 | public function proxySsoAction() |
||
93 | |||
94 | /** |
||
95 | * Receive an AuthnResponse from an identity provider. |
||
96 | * |
||
97 | * The AuthnRequest started in ssoAction() resulted in an AuthnResponse |
||
98 | * from the IDP. This method handles the assertion and forwards the user |
||
99 | * using an internal redirect to the SecondFactorController to start the |
||
100 | * actual second factor verification. |
||
101 | * |
||
102 | * @param Request $request |
||
103 | * @return \Symfony\Component\HttpFoundation\Response |
||
104 | */ |
||
105 | public function consumeAssertionAction(Request $request) |
||
122 | |||
123 | /** |
||
124 | * Send a SAML response back to the service provider. |
||
125 | * |
||
126 | * Second factor verification handled by SecondFactorController is |
||
127 | * finished. The user was forwarded back to this action with an internal |
||
128 | * redirect. This method sends a AuthnResponse back to the service |
||
129 | * provider in response to the AuthnRequest received in ssoAction(). |
||
130 | */ |
||
131 | public function respondAction() |
||
141 | |||
142 | /** |
||
143 | * This action is also used from the context of SecondFactorOnly authentications |
||
144 | * @param $authenticationMode |
||
145 | * @return Response |
||
146 | */ |
||
147 | public function sendLoaCannotBeGivenAction(Request $request) |
||
161 | |||
162 | /** |
||
163 | * @return Response |
||
164 | */ |
||
165 | public function sendAuthenticationCancelledByUserAction() |
||
185 | |||
186 | /** |
||
187 | * @param string $view |
||
188 | * @param SAMLResponse $response |
||
189 | * @param $authenticationMode |
||
190 | * @return Response |
||
191 | */ |
||
192 | public function renderSamlResponse($view, SAMLResponse $response, $authenticationMode) |
||
203 | |||
204 | /** |
||
205 | * @param string $view |
||
206 | * @param array $parameters |
||
207 | * @param Response $response |
||
208 | * @return Response |
||
209 | */ |
||
210 | public function render($view, array $parameters = array(), Response $response = null): Response |
||
218 | |||
219 | /** |
||
220 | * @return ResponseContext |
||
221 | */ |
||
222 | View Code Duplication | public function getResponseContext($authenticationMode) |
|
233 | |||
234 | /** |
||
235 | * @param SAMLResponse $response |
||
236 | * @return string |
||
237 | */ |
||
238 | private function getResponseAsXML(SAMLResponse $response) |
||
242 | |||
243 | /** |
||
244 | * @return LoginService |
||
245 | */ |
||
246 | private function getGatewayLoginService() |
||
250 | |||
251 | /** |
||
252 | * @return ConsumeAssertionService |
||
253 | */ |
||
254 | private function getGatewayConsumeAssertionService() |
||
258 | |||
259 | /** |
||
260 | * @return RespondService |
||
261 | */ |
||
262 | private function getGatewayRespondService() |
||
266 | |||
267 | /** |
||
268 | * @return FailedResponseService |
||
269 | */ |
||
270 | private function getGatewayFailedResponseService() |
||
274 | |||
275 | private function supportsAuthenticationMode($authenticationMode) |
||
281 | } |
||
282 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.