@Override
    public AppResponse process(Flow flow, ConfirmRequest request) throws FlowNotDefinedException, IOException, NoSuchAlgorithmException {
        var authAppSession = appSessionService.getSession(request.getAuthSessionId());

        if (!isAppSessionAuthenticated(authAppSession) || !request.getUserAppId().equals(authAppSession.getUserAppId())){
            return new NokResponse();
        }

        appAuthenticator = appAuthenticatorService.findByUserAppId(authAppSession.getUserAppId());
        if (!isAppAuthenticatorActivated(appAuthenticator) || !appAuthenticatorService.exists(appAuthenticator)) return new NokResponse();

        if (appSession.getEidasUit()){
            var response = validatePipSignature(request.getSignatureOfPip());
            if (response != null) return response;
        }

        if (appSession.getAction() != null ) {
            var result = digidClient.getAccountStatus(appAuthenticator.getAccountId());
            if (ERROR_DECEASED.equals(result.get("error"))) return deceasedResponse();

            switch(appSession.getAction()){
                case "activate_with_app" ->
                    digidClient.remoteLog("1366", Map.of(lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId(), lowerUnderscore(HIDDEN), true));
                case "upgrade_rda_widchecker" ->
                    digidClient.remoteLog("1318", getAppDetails());
                default ->
                    digidClient.remoteLog("1344", getAppDetails());
            }
        }

        appSession.setAppAuthenticationLevel(appAuthenticator.getAuthenticationLevel());
        appSession.setAccountId(authAppSession.getAccountId());
        appSession.setSubstantialActivatedAt(appAuthenticator.getSubstantieelActivatedAt());
        appSession.setSubstantialDocumentType(appAuthenticator.getSubstantieelDocumentType());
        appSession.setUserAppId(authAppSession.getUserAppId());

        if (appSession.getOidcSessionId() != null && authAppSession.getState().equals(State.AUTHENTICATED.name())) {
            oidcClient.confirmOidc(appSession.getAccountId(), appAuthenticator.getAuthenticationLevel(), appSession.getOidcSessionId());
        }

        if (appSession.getAdSessionId() != null && authAppSession.getState().equals(State.AUTHENTICATED.name())) {
            var bsn = digidClient.getBsn(appSession.getAccountId());
            samlClient.updateAdSession(appSession.getAdSessionId(), appAuthenticator.getAuthenticationLevel(), bsn.get(BSN));
        }

        return new ConfirmationResponse(appAuthenticator.getId().equals(appSession.getAppToDestroy()));
    }
@Test
    public void processReturnsNokResponseIfNotExisting() throws FlowNotDefinedException, IOException, NoSuchAlgorithmException {
        //given
        when(appAuthenticatorService.exists(mockedAppAuthenticator)).thenReturn(false);
        when(appSessionService.getSession(confirmRequest.getAuthSessionId())).thenReturn(authAppSession);
        //when
        AppResponse appResponse = confirmed.process(mockedFlow, confirmRequest);
        //then
        assertTrue(appResponse instanceof NokResponse);
    }