Code Duplication    Length = 25-29 lines in 2 locations

src/Surfnet/StepupGateway/GatewayBundle/Controller/GatewayController.php 2 locations

@@ 204-228 (lines=25) @@
201
        return $this->renderSamlResponse('consumeAssertion', $response);
202
    }
203
204
    public function sendLoaCannotBeGivenAction()
205
    {
206
        $responseContext = $this->getResponseContext();
207
        $originalRequestId = $responseContext->getInResponseTo();
208
209
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
210
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
211
        $logger->notice('Loa cannot be given, creating Response with NoAuthnContext status');
212
213
        /** @var \Surfnet\StepupGateway\GatewayBundle\Saml\ResponseBuilder $responseBuilder */
214
        $responseBuilder = $this->get('gateway.proxy.response_builder');
215
216
        $response = $responseBuilder
217
            ->createNewResponse($responseContext)
218
            ->setResponseStatus(SAML2_Const::STATUS_RESPONDER, SAML2_Const::STATUS_NO_AUTHN_CONTEXT)
219
            ->get();
220
221
        $logger->notice(sprintf(
222
            'Responding to request "%s" with response based on response from the remote IdP with response "%s"',
223
            $responseContext->getInResponseTo(),
224
            $response->getId()
225
        ));
226
227
        return $this->renderSamlResponse('consumeAssertion', $response);
228
    }
229
230
    public function sendAuthenticationCancelledByUserAction()
231
    {
@@ 230-258 (lines=29) @@
227
        return $this->renderSamlResponse('consumeAssertion', $response);
228
    }
229
230
    public function sendAuthenticationCancelledByUserAction()
231
    {
232
        $responseContext = $this->getResponseContext();
233
        $originalRequestId = $responseContext->getInResponseTo();
234
235
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
236
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
237
        $logger->notice('Authentication was cancelled by the user, creating Response with AuthnFailed status');
238
239
        /** @var \Surfnet\StepupGateway\GatewayBundle\Saml\ResponseBuilder $responseBuilder */
240
        $responseBuilder = $this->get('gateway.proxy.response_builder');
241
242
        $response = $responseBuilder
243
            ->createNewResponse($responseContext)
244
            ->setResponseStatus(
245
                SAML2_Const::STATUS_RESPONDER,
246
                SAML2_Const::STATUS_AUTHN_FAILED,
247
                'Authentication cancelled by user'
248
            )
249
            ->get();
250
251
        $logger->notice(sprintf(
252
            'Responding to request "%s" with response based on response from the remote IdP with response "%s"',
253
            $responseContext->getInResponseTo(),
254
            $response->getId()
255
        ));
256
257
        return $this->renderSamlResponse('consumeAssertion', $response);
258
    }
259
260
    /**
261
     * @param string         $view