@Test void identifyConsent() { when(referencePolicy.fromRequest(any(), any(), any(), anyBoolean())).thenReturn(getConsentReference()); when(cmsPsuAisClient.getConsentIdByRedirectId(any(), any())).thenReturn(ResponseEntity.ok(getCmsAisConsentResponse(AisConsentRequestType.DEDICATED_ACCOUNTS, IBAN_DE))); when(consentMapper.toTo(any())).thenReturn(getAisConsentTO()); ConsentWorkflow workflow = redirectConsentService.identifyConsent(ENCRYPTED_CONSENT_ID, AUTHORIZATION_ID, false, "consentCookieString", getBearerTokenTO()); assertNotNull(workflow); assertEquals(workflow.getConsentReference(), getConsentReference()); assertNotNull(workflow.getScaResponse().getBearerToken()); }
@Override public ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken) { ConsentReference consentReference = referencePolicy.fromRequest(encryptedConsentId, authorizationId, consentCookieString, strict); CmsAisConsentResponse cmsConsentResponse = loadConsentByRedirectId(consentReference); ConsentWorkflow workflow = new ConsentWorkflow(cmsConsentResponse, consentReference); AisConsentTO aisConsentTO = consentMapper.toTo(cmsConsentResponse.getAccountConsent()); workflow.setAuthResponse(new ConsentAuthorizeResponse(aisConsentTO)); workflow.getAuthResponse().setAuthorisationId(cmsConsentResponse.getAuthorisationId()); workflow.getAuthResponse().setEncryptedConsentId(encryptedConsentId); if (bearerToken != null) { SCAConsentResponseTO scaConsentResponseTO = new SCAConsentResponseTO(); scaConsentResponseTO.setBearerToken(bearerToken); workflow.setScaResponse(scaConsentResponseTO); } return workflow; }
RedirectConsentServiceImpl implements RedirectConsentService { @Override public ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken) { ConsentReference consentReference = referencePolicy.fromRequest(encryptedConsentId, authorizationId, consentCookieString, strict); CmsAisConsentResponse cmsConsentResponse = loadConsentByRedirectId(consentReference); ConsentWorkflow workflow = new ConsentWorkflow(cmsConsentResponse, consentReference); AisConsentTO aisConsentTO = consentMapper.toTo(cmsConsentResponse.getAccountConsent()); workflow.setAuthResponse(new ConsentAuthorizeResponse(aisConsentTO)); workflow.getAuthResponse().setAuthorisationId(cmsConsentResponse.getAuthorisationId()); workflow.getAuthResponse().setEncryptedConsentId(encryptedConsentId); if (bearerToken != null) { SCAConsentResponseTO scaConsentResponseTO = new SCAConsentResponseTO(); scaConsentResponseTO.setBearerToken(bearerToken); workflow.setScaResponse(scaConsentResponseTO); } return workflow; } }
RedirectConsentServiceImpl implements RedirectConsentService { @Override public ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken) { ConsentReference consentReference = referencePolicy.fromRequest(encryptedConsentId, authorizationId, consentCookieString, strict); CmsAisConsentResponse cmsConsentResponse = loadConsentByRedirectId(consentReference); ConsentWorkflow workflow = new ConsentWorkflow(cmsConsentResponse, consentReference); AisConsentTO aisConsentTO = consentMapper.toTo(cmsConsentResponse.getAccountConsent()); workflow.setAuthResponse(new ConsentAuthorizeResponse(aisConsentTO)); workflow.getAuthResponse().setAuthorisationId(cmsConsentResponse.getAuthorisationId()); workflow.getAuthResponse().setEncryptedConsentId(encryptedConsentId); if (bearerToken != null) { SCAConsentResponseTO scaConsentResponseTO = new SCAConsentResponseTO(); scaConsentResponseTO.setBearerToken(bearerToken); workflow.setScaResponse(scaConsentResponseTO); } return workflow; }  }
RedirectConsentServiceImpl implements RedirectConsentService { @Override public ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken) { ConsentReference consentReference = referencePolicy.fromRequest(encryptedConsentId, authorizationId, consentCookieString, strict); CmsAisConsentResponse cmsConsentResponse = loadConsentByRedirectId(consentReference); ConsentWorkflow workflow = new ConsentWorkflow(cmsConsentResponse, consentReference); AisConsentTO aisConsentTO = consentMapper.toTo(cmsConsentResponse.getAccountConsent()); workflow.setAuthResponse(new ConsentAuthorizeResponse(aisConsentTO)); workflow.getAuthResponse().setAuthorisationId(cmsConsentResponse.getAuthorisationId()); workflow.getAuthResponse().setEncryptedConsentId(encryptedConsentId); if (bearerToken != null) { SCAConsentResponseTO scaConsentResponseTO = new SCAConsentResponseTO(); scaConsentResponseTO.setBearerToken(bearerToken); workflow.setScaResponse(scaConsentResponseTO); } return workflow; }  @Override void selectScaMethod(String scaMethodId, final ConsentWorkflow workflow); @Override void updateAccessByConsentType(ConsentWorkflow workflow, List<AccountDetailsTO> listOfAccounts); @Override void updateScaStatusConsentStatusConsentData(String psuId, ConsentWorkflow workflow); @Override void startConsent(final ConsentWorkflow workflow, AisConsentTO aisConsent, List<AccountDetailsTO> listOfAccounts); @Override ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken); }
RedirectConsentServiceImpl implements RedirectConsentService { @Override public ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken) { ConsentReference consentReference = referencePolicy.fromRequest(encryptedConsentId, authorizationId, consentCookieString, strict); CmsAisConsentResponse cmsConsentResponse = loadConsentByRedirectId(consentReference); ConsentWorkflow workflow = new ConsentWorkflow(cmsConsentResponse, consentReference); AisConsentTO aisConsentTO = consentMapper.toTo(cmsConsentResponse.getAccountConsent()); workflow.setAuthResponse(new ConsentAuthorizeResponse(aisConsentTO)); workflow.getAuthResponse().setAuthorisationId(cmsConsentResponse.getAuthorisationId()); workflow.getAuthResponse().setEncryptedConsentId(encryptedConsentId); if (bearerToken != null) { SCAConsentResponseTO scaConsentResponseTO = new SCAConsentResponseTO(); scaConsentResponseTO.setBearerToken(bearerToken); workflow.setScaResponse(scaConsentResponseTO); } return workflow; }  @Override void selectScaMethod(String scaMethodId, final ConsentWorkflow workflow); @Override void updateAccessByConsentType(ConsentWorkflow workflow, List<AccountDetailsTO> listOfAccounts); @Override void updateScaStatusConsentStatusConsentData(String psuId, ConsentWorkflow workflow); @Override void startConsent(final ConsentWorkflow workflow, AisConsentTO aisConsent, List<AccountDetailsTO> listOfAccounts); @Override ConsentWorkflow identifyConsent(String encryptedConsentId, String authorizationId, boolean strict, String consentCookieString, BearerTokenTO bearerToken);  }