INT-375: Fix CallbackUrlExtractor interface (add an option for processing options map) (#55)

Co-authored-by: dmitriibaikov <bdv@empayre.com>
This commit is contained in:
Baikov Dmitrii 2022-11-22 03:20:55 -08:00 committed by GitHub
parent 97d85e7ee5
commit 577d4b465d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 7 deletions

View File

@ -12,7 +12,7 @@
</parent> </parent>
<artifactId>adapter-flow-lib</artifactId> <artifactId>adapter-flow-lib</artifactId>
<version>0.1.20</version> <version>0.1.21</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>adapter-flow-lib</name> <name>adapter-flow-lib</name>

View File

@ -6,8 +6,11 @@ public interface CallbackUrlExtractor {
String TERMINATION_URI = "termination_uri"; String TERMINATION_URI = "termination_uri";
@Deprecated
String extractCallbackUrl(String redirectUrl); String extractCallbackUrl(String redirectUrl);
String extractCallbackUrl(Map<String, String> adapterConfigurations, String redirectUrl);
String getSuccessRedirectUrl(Map<String, String> adapterConfigurations, String redirectUrl); String getSuccessRedirectUrl(Map<String, String> adapterConfigurations, String redirectUrl);
} }

View File

@ -48,9 +48,11 @@ public class IntentResultFactory {
ThreeDsData threeDsData = exitStateModel.getThreeDsData(); ThreeDsData threeDsData = exitStateModel.getThreeDsData();
Map<String, String> params = ThreeDsDataInitializer.initThreeDsParameters(exitStateModel); Map<String, String> params = ThreeDsDataInitializer.initThreeDsParameters(exitStateModel);
String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl(); String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl();
params.put(RedirectFields.TERM_URL.getValue(), callbackUrlExtractor.extractCallbackUrl(redirectUrl)); Map<String, String> adapterConfigurations = entryStateModel.getBaseRequestModel().getAdapterConfigurations();
params.put(RedirectFields.TERM_URL.getValue(),
callbackUrlExtractor.extractCallbackUrl(adapterConfigurations, redirectUrl));
int timerRedirectTimeoutMin = extractRedirectTimeout( int timerRedirectTimeoutMin = extractRedirectTimeout(
entryStateModel.getBaseRequestModel().getAdapterConfigurations(), adapterConfigurations,
timerProperties.getRedirectTimeoutMin()); timerProperties.getRedirectTimeoutMin());
return Intent.suspend( return Intent.suspend(
new SuspendIntent( new SuspendIntent(
@ -71,10 +73,12 @@ public class IntentResultFactory {
exitStateModel.setPollingInfo(pollingInfo); exitStateModel.setPollingInfo(pollingInfo);
String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl(); String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl();
params.put(RedirectFields.TERM_URL.getValue(), callbackUrlExtractor.extractCallbackUrl(redirectUrl)); Map<String, String> adapterConfigurations = entryStateModel.getBaseRequestModel().getAdapterConfigurations();
params.put(RedirectFields.TERM_URL.getValue(),
callbackUrlExtractor.extractCallbackUrl(adapterConfigurations, redirectUrl));
ThreeDsData threeDsData = exitStateModel.getThreeDsData(); ThreeDsData threeDsData = exitStateModel.getThreeDsData();
int timerRedirectTimeoutMin = extractRedirectTimeout( int timerRedirectTimeoutMin = extractRedirectTimeout(
entryStateModel.getBaseRequestModel().getAdapterConfigurations(), adapterConfigurations,
timerProperties.getRedirectTimeoutMin()); timerProperties.getRedirectTimeoutMin());
return Intent.suspend( return Intent.suspend(
new SuspendIntent( new SuspendIntent(

View File

@ -34,9 +34,11 @@ public class RecurrentIntentResultFactory {
ThreeDsData threeDsData = exitStateModel.getThreeDsData(); ThreeDsData threeDsData = exitStateModel.getThreeDsData();
Map<String, String> params = ThreeDsDataInitializer.initThreeDsParameters(exitStateModel); Map<String, String> params = ThreeDsDataInitializer.initThreeDsParameters(exitStateModel);
String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl(); String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl();
params.put(RedirectFields.TERM_URL.getValue(), callbackUrlExtractor.extractCallbackUrl(redirectUrl)); Map<String, String> adapterConfigurations = entryStateModel.getBaseRequestModel().getAdapterConfigurations();
params.put(RedirectFields.TERM_URL.getValue(),
callbackUrlExtractor.extractCallbackUrl(adapterConfigurations, redirectUrl));
int timerRedirectTimeoutMin = extractRedirectTimeout( int timerRedirectTimeoutMin = extractRedirectTimeout(
entryStateModel.getBaseRequestModel().getAdapterConfigurations(), adapterConfigurations,
timerProperties.getRedirectTimeoutMin()); timerProperties.getRedirectTimeoutMin());
return RecurrentTokenIntent.suspend( return RecurrentTokenIntent.suspend(
new SuspendIntent( new SuspendIntent(

View File

@ -16,6 +16,11 @@ public class CallbackUrlExtractorImpl implements CallbackUrlExtractor {
@Override @Override
public String extractCallbackUrl(String redirectUrl) { public String extractCallbackUrl(String redirectUrl) {
return extractCallbackUrl(null, redirectUrl);
}
@Override
public String extractCallbackUrl(Map<String, String> adapterConfigurations, String redirectUrl) {
return UriComponentsBuilder.fromUriString(adapterProperties.getCallbackUrl()) return UriComponentsBuilder.fromUriString(adapterProperties.getCallbackUrl())
.path(adapterProperties.getPathCallbackUrl()) .path(adapterProperties.getPathCallbackUrl())
.queryParam(TERMINATION_URI, redirectUrl).build().toUriString(); .queryParam(TERMINATION_URI, redirectUrl).build().toUriString();