@Override
    public AppResponse process(Flow flow, RsStartAppApplicationRequest request) throws SharedServiceClientException {

        checkSwitchesEnabled();

        long appSessionExpirationInMinutes = sharedServiceClient.getSSConfigLong("Geldigheidstermijn_AppActivatieCode_RvIG-Aanvraagstation_gemeente-balie");
        appSession = new AppSession(appSessionExpirationInMinutes * 60);

        digidClient.remoteLog("1409");

        boolean authenticated = false;
        if (request.getAuthenticate().equals("true")) {
            Map<String, Object> result = digidClient.authenticateAccount(request.getUsername(), request.getPassword());

            if (result.get(lowerUnderscore(STATUS)).equals("OK")) {
                authenticated = true;
                appSession.setAccountId(Long.valueOf((Integer) result.get(lowerUnderscore(ACCOUNT_ID))));
            } else if (result.get(lowerUnderscore(STATUS)).equals("NOK") && result.get(ERROR) != null) {
                String error = (String) result.get("error");
                return new NokResponse(error);
            }
        }

        final String appActivationCode = getNewlyGenerateAppActivationCode();
        final String user_app_id = UUID.randomUUID().toString();

        appSession.setFlow((ApplyForAppAtRequestStationFlow.NAME));
        appSession.setState(State.INITIALIZED.name());
        appSession.setActivationMethod(ActivationMethod.RS);
        appSession.setAuthenticated(authenticated);
        appSession.setAuthenticationLevel("25");
        appSession.setInstanceId(request.getInstanceId());
        appSession.setDeviceName(request.getDeviceName());
        appSession.setActivationStatus("PENDING");
        appSession.setUserAppId(user_app_id);
        appSession.setAppActivationCode(appActivationCode);

        if (!authenticated) {
            digidClient.remoteLog("1089", Map.of("app_code", request.getInstanceId().substring(0,6), "device_name", request.getDeviceName(), lowerUnderscore(HIDDEN), true));
        }

        // lb is not used anymore but the api, must remain the same therefore lb is always null.
        return new RsStartAppApplicationResponse(appSession.getId(), null, Instant.now().getEpochSecond(), appActivationCode );
    }
@Test
    public void processRsStartAppApplicationWithoutAuthenticationTest() throws SharedServiceClientException {
        when(sharedServiceClient.getSSConfigLong("RvIG-Aanvraagstation_session_expiration")).thenReturn(15L);
        when(switchService.digidAppSwitchEnabled()).thenReturn(true);
        when(switchService.digidRequestStationEnabled()).thenReturn(true);

        mockedRsStartAppApplicationRequest = new RsStartAppApplicationRequest();
        mockedRsStartAppApplicationRequest.setAuthenticate("false");
        mockedRsStartAppApplicationRequest.setUsername(USER_NAME);
        mockedRsStartAppApplicationRequest.setPassword(PASSWORD);
        mockedRsStartAppApplicationRequest.setInstanceId(INSTANCE_ID);
        mockedRsStartAppApplicationRequest.setDeviceName(DEVICENAME);

        AppResponse appResponse = rsStartAppApplication.process(mockedApplyForAppAtRequestStationFlow, mockedRsStartAppApplicationRequest);

        verify(digidClient, times(1)).remoteLog("1089", Map.of(lowerUnderscore(APP_CODE), INSTANCE_ID.substring(0,6), lowerUnderscore(DEVICE_NAME), DEVICENAME, lowerUnderscore(HIDDEN), true));
        assertTrue(appResponse instanceof RsStartAppApplicationResponse);
        assertNull(((RsStartAppApplicationResponse) appResponse).getLb());
        assertTrue(((RsStartAppApplicationResponse) appResponse).getActivationCode().startsWith("R"));
    }