@Test void login() { when(responseUtils.consentCookie(any())).thenReturn(COOKIE); when(redirectConsentService.identifyConsent(anyString(), anyString(), anyBoolean(), anyString(), any())).thenReturn(getConsentWorkflow(PSUIDENTIFIED, ConsentStatus.RECEIVED)); when(xisService.performLoginForConsent(anyString(), anyString(), anyString(), anyString(), any(OpTypeTO.class))).thenReturn(getScaLoginResponse(true)); when(cmsPsuAisClient.updatePsuDataInConsent(anyString(), anyString(), anyString(), any())).thenReturn(ResponseEntity.ok(null)); when(accountRestClient.getListOfAccounts()).thenReturn(ResponseEntity.ok(new ArrayList<>())); ResponseEntity<ConsentAuthorizeResponse> result = controller.login(ENCRYPTED_ID, AUTH_ID, LOGIN, PIN, COOKIE); assertEquals(ResponseEntity.ok(getConsentAuthorizeResponse(true, true, false, PSUIDENTIFIED)), result); }
@Override public ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString) { ConsentWorkflow workflow; try { String consentCookie = responseUtils.consentCookie(consentCookieString); workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, false, consentCookie, null); } catch (ConsentAuthorizeException e) { return e.getError(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.consentId(), workflow.authId(), OpTypeTO.CONSENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getConsentResponse().getAccountConsent().getPsuIdDataList()); workflow.storeSCAResponse(loginResult.getBody()); if (AuthUtils.success(loginResult)) { String psuId = AuthUtils.psuId(workflow.bearerToken()); try { updatePSUIdentification(workflow, psuId); redirectConsentService.updateScaStatusConsentStatusConsentData(psuId, workflow); } catch (ConsentAuthorizeException e) { return e.getError(); } return resolveResponseByScaStatus(workflow, true); } else { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString) { ConsentWorkflow workflow; try { String consentCookie = responseUtils.consentCookie(consentCookieString); workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, false, consentCookie, null); } catch (ConsentAuthorizeException e) { return e.getError(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.consentId(), workflow.authId(), OpTypeTO.CONSENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getConsentResponse().getAccountConsent().getPsuIdDataList()); workflow.storeSCAResponse(loginResult.getBody()); if (AuthUtils.success(loginResult)) { String psuId = AuthUtils.psuId(workflow.bearerToken()); try { updatePSUIdentification(workflow, psuId); redirectConsentService.updateScaStatusConsentStatusConsentData(psuId, workflow); } catch (ConsentAuthorizeException e) { return e.getError(); } return resolveResponseByScaStatus(workflow, true); } else { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } } }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString) { ConsentWorkflow workflow; try { String consentCookie = responseUtils.consentCookie(consentCookieString); workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, false, consentCookie, null); } catch (ConsentAuthorizeException e) { return e.getError(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.consentId(), workflow.authId(), OpTypeTO.CONSENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getConsentResponse().getAccountConsent().getPsuIdDataList()); workflow.storeSCAResponse(loginResult.getBody()); if (AuthUtils.success(loginResult)) { String psuId = AuthUtils.psuId(workflow.bearerToken()); try { updatePSUIdentification(workflow, psuId); redirectConsentService.updateScaStatusConsentStatusConsentData(psuId, workflow); } catch (ConsentAuthorizeException e) { return e.getError(); } return resolveResponseByScaStatus(workflow, true); } else { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }  }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString) { ConsentWorkflow workflow; try { String consentCookie = responseUtils.consentCookie(consentCookieString); workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, false, consentCookie, null); } catch (ConsentAuthorizeException e) { return e.getError(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.consentId(), workflow.authId(), OpTypeTO.CONSENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getConsentResponse().getAccountConsent().getPsuIdDataList()); workflow.storeSCAResponse(loginResult.getBody()); if (AuthUtils.success(loginResult)) { String psuId = AuthUtils.psuId(workflow.bearerToken()); try { updatePSUIdentification(workflow, psuId); redirectConsentService.updateScaStatusConsentStatusConsentData(psuId, workflow); } catch (ConsentAuthorizeException e) { return e.getError(); } return resolveResponseByScaStatus(workflow, true); } else { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }  @Override @ApiOperation(value = "Entry point for authenticating ais consent requests.") ResponseEntity<AuthorizeResponse> aisAuth(String redirectId, String encryptedConsentId, String token); @Override ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString); @Override ResponseEntity<ConsentAuthorizeResponse> startConsentAuth(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, AisConsentTO aisConsent); @Override ResponseEntity<ConsentAuthorizeResponse> authrizedConsent(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, String authCode); @Override ResponseEntity<ConsentAuthorizeResponse> selectMethod(String encryptedConsentId, String authorisationId, String scaMethodId, String consentAndAccessTokenCookieString); @Override ResponseEntity<List<AccountDetailsTO>> getListOfAccounts(String accessTokenCookieString); @Override ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode); @Override ResponseEntity<ConsentAuthorizeResponse> revokeConsent(@NotNull String encryptedConsentId, @NotNull String authorisationId, String cookieString); }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString) { ConsentWorkflow workflow; try { String consentCookie = responseUtils.consentCookie(consentCookieString); workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, false, consentCookie, null); } catch (ConsentAuthorizeException e) { return e.getError(); } ResponseEntity<SCALoginResponseTO> loginResult = xisService.performLoginForConsent(login, pin, workflow.consentId(), workflow.authId(), OpTypeTO.CONSENT); AuthUtils.checkIfUserInitiatedOperation(loginResult, workflow.getConsentResponse().getAccountConsent().getPsuIdDataList()); workflow.storeSCAResponse(loginResult.getBody()); if (AuthUtils.success(loginResult)) { String psuId = AuthUtils.psuId(workflow.bearerToken()); try { updatePSUIdentification(workflow, psuId); redirectConsentService.updateScaStatusConsentStatusConsentData(psuId, workflow); } catch (ConsentAuthorizeException e) { return e.getError(); } return resolveResponseByScaStatus(workflow, true); } else { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } }  @Override @ApiOperation(value = "Entry point for authenticating ais consent requests.") ResponseEntity<AuthorizeResponse> aisAuth(String redirectId, String encryptedConsentId, String token); @Override ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString); @Override ResponseEntity<ConsentAuthorizeResponse> startConsentAuth(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, AisConsentTO aisConsent); @Override ResponseEntity<ConsentAuthorizeResponse> authrizedConsent(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, String authCode); @Override ResponseEntity<ConsentAuthorizeResponse> selectMethod(String encryptedConsentId, String authorisationId, String scaMethodId, String consentAndAccessTokenCookieString); @Override ResponseEntity<List<AccountDetailsTO>> getListOfAccounts(String accessTokenCookieString); @Override ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode); @Override ResponseEntity<ConsentAuthorizeResponse> revokeConsent(@NotNull String encryptedConsentId, @NotNull String authorisationId, String cookieString);  }