Code Duplication    Length = 20-24 lines in 2 locations

src/Surfnet/StepupGateway/GatewayBundle/Service/Gateway/FailedResponseService.php 2 locations

@@ 58-77 (lines=20) @@
55
     * @param ResponseContext $responseContext
56
     * @return SAMLResponse
57
     */
58
    public function sendLoaCannotBeGiven(ResponseContext $responseContext)
59
    {
60
        $originalRequestId = $responseContext->getInResponseTo();
61
62
        $logger = $this->samlLogger->forAuthentication($originalRequestId);
63
        $logger->notice('Loa cannot be given, creating Response with NoAuthnContext status');
64
65
        $response = $this->responseBuilder
66
            ->createNewResponse($responseContext)
67
            ->setResponseStatus(Constants::STATUS_RESPONDER, Constants::STATUS_NO_AUTHN_CONTEXT)
68
            ->get();
69
70
        $logger->notice(sprintf(
71
            'Responding to request "%s" with response based on response from the remote IdP with response "%s"',
72
            $responseContext->getInResponseTo(),
73
            $response->getId()
74
        ));
75
76
        return $response;
77
    }
78
79
    /**
80
     * @param ResponseContext $responseContext
@@ 83-106 (lines=24) @@
80
     * @param ResponseContext $responseContext
81
     * @return SAMLResponse
82
     */
83
    public function sendAuthenticationCancelledByUser(ResponseContext $responseContext)
84
    {
85
        $originalRequestId = $responseContext->getInResponseTo();
86
87
        $logger = $this->samlLogger->forAuthentication($originalRequestId);
88
        $logger->notice('Authentication was cancelled by the user, creating Response with AuthnFailed status');
89
90
        $response = $this->responseBuilder
91
            ->createNewResponse($responseContext)
92
            ->setResponseStatus(
93
                Constants::STATUS_RESPONDER,
94
                Constants::STATUS_AUTHN_FAILED,
95
                'Authentication cancelled by user'
96
            )
97
            ->get();
98
99
        $logger->notice(sprintf(
100
            'Responding to request "%s" with response based on response from the remote IdP with response "%s"',
101
            $responseContext->getInResponseTo(),
102
            $response->getId()
103
        ));
104
105
        return $response;
106
    }
107
108
    /**
109
     * @return SAMLResponse