@Test void aisDone_oauth2_integrated() { when(responseUtils.consentCookie(any())).thenReturn(COOKIE); when(redirectConsentService.identifyConsent(anyString(), anyString(), anyBoolean(), anyString(), any())).thenReturn(getConsentWorkflow(FINALISED, ConsentStatus.RECEIVED)); when(responseUtils.redirect(anyString(), any())).thenReturn(ResponseEntity.ok(getConsentAuthorizeResponse(true, true, false, FINALISED))); when(oauthRestClient.oauthCode(any())).thenReturn(ResponseEntity.ok(new OauthCodeResponseTO(OK_URI, "code"))); ResponseEntity<ConsentAuthorizeResponse> result = controller.aisDone(ENCRYPTED_ID, AUTH_ID, COOKIE, true, "code"); assertEquals(ResponseEntity.ok(getConsentAuthorizeResponse(true, true, false, FINALISED)), result); }
@Override public ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode) { String consentCookie = responseUtils.consentCookie(cookie); ConsentWorkflow workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, true, consentCookie, middlewareAuth.getBearerToken()); ConsentStatus consentStatus = workflow.getConsentResponse().getAccountConsent().getConsentStatus(); CmsAisConsentResponse consentResponse = workflow.getConsentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = Optional.ofNullable(consentResponse.getTppNokRedirectUri()) .filter(StringUtils::isNotBlank) .orElse(consentResponse.getTppOkRedirectUri()); String redirectURL = EnumSet.of(VALID, ConsentStatus.RECEIVED, PARTIALLY_AUTHORISED).contains(consentStatus) && isNotFailedAuthorizationList(consentResponse) ? tppOkRedirectUri : tppNokRedirectUri; return responseUtils.redirect(redirectURL, response); }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode) { String consentCookie = responseUtils.consentCookie(cookie); ConsentWorkflow workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, true, consentCookie, middlewareAuth.getBearerToken()); ConsentStatus consentStatus = workflow.getConsentResponse().getAccountConsent().getConsentStatus(); CmsAisConsentResponse consentResponse = workflow.getConsentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = Optional.ofNullable(consentResponse.getTppNokRedirectUri()) .filter(StringUtils::isNotBlank) .orElse(consentResponse.getTppOkRedirectUri()); String redirectURL = EnumSet.of(VALID, ConsentStatus.RECEIVED, PARTIALLY_AUTHORISED).contains(consentStatus) && isNotFailedAuthorizationList(consentResponse) ? tppOkRedirectUri : tppNokRedirectUri; return responseUtils.redirect(redirectURL, response); } }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode) { String consentCookie = responseUtils.consentCookie(cookie); ConsentWorkflow workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, true, consentCookie, middlewareAuth.getBearerToken()); ConsentStatus consentStatus = workflow.getConsentResponse().getAccountConsent().getConsentStatus(); CmsAisConsentResponse consentResponse = workflow.getConsentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = Optional.ofNullable(consentResponse.getTppNokRedirectUri()) .filter(StringUtils::isNotBlank) .orElse(consentResponse.getTppOkRedirectUri()); String redirectURL = EnumSet.of(VALID, ConsentStatus.RECEIVED, PARTIALLY_AUTHORISED).contains(consentStatus) && isNotFailedAuthorizationList(consentResponse) ? tppOkRedirectUri : tppNokRedirectUri; return responseUtils.redirect(redirectURL, response); }  }
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode) { String consentCookie = responseUtils.consentCookie(cookie); ConsentWorkflow workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, true, consentCookie, middlewareAuth.getBearerToken()); ConsentStatus consentStatus = workflow.getConsentResponse().getAccountConsent().getConsentStatus(); CmsAisConsentResponse consentResponse = workflow.getConsentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = Optional.ofNullable(consentResponse.getTppNokRedirectUri()) .filter(StringUtils::isNotBlank) .orElse(consentResponse.getTppOkRedirectUri()); String redirectURL = EnumSet.of(VALID, ConsentStatus.RECEIVED, PARTIALLY_AUTHORISED).contains(consentStatus) && isNotFailedAuthorizationList(consentResponse) ? tppOkRedirectUri : tppNokRedirectUri; return responseUtils.redirect(redirectURL, response); }  @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> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode) { String consentCookie = responseUtils.consentCookie(cookie); ConsentWorkflow workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, true, consentCookie, middlewareAuth.getBearerToken()); ConsentStatus consentStatus = workflow.getConsentResponse().getAccountConsent().getConsentStatus(); CmsAisConsentResponse consentResponse = workflow.getConsentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = Optional.ofNullable(consentResponse.getTppNokRedirectUri()) .filter(StringUtils::isNotBlank) .orElse(consentResponse.getTppOkRedirectUri()); String redirectURL = EnumSet.of(VALID, ConsentStatus.RECEIVED, PARTIALLY_AUTHORISED).contains(consentStatus) && isNotFailedAuthorizationList(consentResponse) ? tppOkRedirectUri : tppNokRedirectUri; return responseUtils.redirect(redirectURL, response); }  @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);  }