Code Duplication    Length = 25-29 lines in 2 locations

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

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