Code Duplication    Length = 25-29 lines in 2 locations

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

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