@Test void validateAuthCode() { when(auth.getBearerToken()).thenReturn(new BearerTokenTO()); when(ledgersUserMgmt.authorizeLogin(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(getLoginResponse(FINALISED)); ResponseEntity<AuthorizeResponse> result = controller.validateAuthCode(ENCRYPTED_ID, AUTH_ID, PIN, COOKIE); assertEquals(getExpectedAuthResponse(FINALISED, null), result); }
@Override public ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies) { AuthorizeResponse authResponse = new AuthorizeResponse(); authResponse.setEncryptedConsentId(scaId); authResponse.setAuthorisationId(authorisationId); try { authInterceptor.setAccessToken(auth.getBearerToken().getAccess_token()); SCALoginResponseTO authorizeResponse = ledgersUserMgmt.authorizeLogin(scaId, authorisationId, authCode).getBody(); prepareAuthResponse(authResponse, Objects.requireNonNull(authorizeResponse)); BearerTokenTO bearerToken = authorizeResponse.getBearerToken(); responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); } finally { authInterceptor.setAccessToken(null); } }
SCAController implements SCAApi { @Override public ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies) { AuthorizeResponse authResponse = new AuthorizeResponse(); authResponse.setEncryptedConsentId(scaId); authResponse.setAuthorisationId(authorisationId); try { authInterceptor.setAccessToken(auth.getBearerToken().getAccess_token()); SCALoginResponseTO authorizeResponse = ledgersUserMgmt.authorizeLogin(scaId, authorisationId, authCode).getBody(); prepareAuthResponse(authResponse, Objects.requireNonNull(authorizeResponse)); BearerTokenTO bearerToken = authorizeResponse.getBearerToken(); responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); } finally { authInterceptor.setAccessToken(null); } } }
SCAController implements SCAApi { @Override public ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies) { AuthorizeResponse authResponse = new AuthorizeResponse(); authResponse.setEncryptedConsentId(scaId); authResponse.setAuthorisationId(authorisationId); try { authInterceptor.setAccessToken(auth.getBearerToken().getAccess_token()); SCALoginResponseTO authorizeResponse = ledgersUserMgmt.authorizeLogin(scaId, authorisationId, authCode).getBody(); prepareAuthResponse(authResponse, Objects.requireNonNull(authorizeResponse)); BearerTokenTO bearerToken = authorizeResponse.getBearerToken(); responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); } finally { authInterceptor.setAccessToken(null); } }  }
SCAController implements SCAApi { @Override public ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies) { AuthorizeResponse authResponse = new AuthorizeResponse(); authResponse.setEncryptedConsentId(scaId); authResponse.setAuthorisationId(authorisationId); try { authInterceptor.setAccessToken(auth.getBearerToken().getAccess_token()); SCALoginResponseTO authorizeResponse = ledgersUserMgmt.authorizeLogin(scaId, authorisationId, authCode).getBody(); prepareAuthResponse(authResponse, Objects.requireNonNull(authorizeResponse)); BearerTokenTO bearerToken = authorizeResponse.getBearerToken(); responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); } finally { authInterceptor.setAccessToken(null); } }  @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") ResponseEntity<AuthorizeResponse> login(String login, String pin); @Override ResponseEntity<AuthorizeResponse> selectMethod(String scaId, String authorisationId, String methodId, String cookies); @Override ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies); }
SCAController implements SCAApi { @Override public ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies) { AuthorizeResponse authResponse = new AuthorizeResponse(); authResponse.setEncryptedConsentId(scaId); authResponse.setAuthorisationId(authorisationId); try { authInterceptor.setAccessToken(auth.getBearerToken().getAccess_token()); SCALoginResponseTO authorizeResponse = ledgersUserMgmt.authorizeLogin(scaId, authorisationId, authCode).getBody(); prepareAuthResponse(authResponse, Objects.requireNonNull(authorizeResponse)); BearerTokenTO bearerToken = authorizeResponse.getBearerToken(); responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); } finally { authInterceptor.setAccessToken(null); } }  @Override @ApiOperation(value = "Identifies the user by login an pin. Return sca methods information") ResponseEntity<AuthorizeResponse> login(String login, String pin); @Override ResponseEntity<AuthorizeResponse> selectMethod(String scaId, String authorisationId, String methodId, String cookies); @Override ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies);  }