use of net.petafuel.styx.core.xs2a.entities.StrongAuthenticatableResource in project styx by petafuel.
the class STYX05 method apply.
@Override
public boolean apply(XS2AFactoryInput xs2AFactoryInput, XS2ARequest xs2ARequest, XS2AResponse xs2AResponse) throws ImplementerOptionException {
if (xs2AResponse instanceof StrongAuthenticatableResource) {
Boolean optionRequired = ioParser.getOption(IO, IOParser.Option.REQUIRED);
if (optionRequired != null && optionRequired) {
StrongAuthenticatableResource response = (StrongAuthenticatableResource) xs2AResponse;
String authorizationLink = response.getLinks().getScaRedirect().getUrl();
OAuthSession oAuthSession = OAuthSession.start(response.getxRequestId());
oAuthSession.setScope(SCAHandler.getQueryParameterValue(authorizationLink, "scope"));
oAuthSession.setAuthorizationEndpoint(getBaseUrl(authorizationLink));
boolean isSandbox = WebServer.isSandbox();
Aspsp aspsp = ioParser.getAspsp();
if (isSandbox) {
oAuthSession.setTokenEndpoint(aspsp.getSandboxUrl().getPreauthTokenEndpoint());
} else {
oAuthSession.setTokenEndpoint(aspsp.getProductionUrl().getPreauthTokenEndpoint());
}
PersistentOAuthSession.create(oAuthSession);
String generatedCodeChallenge = OAuthService.getCodeChallengeFromState(oAuthSession.getState());
String codeChallengePlaceholder = SCAHandler.getQueryParameterValue(authorizationLink, "code_challenge");
authorizationLink = authorizationLink.replace(codeChallengePlaceholder, generatedCodeChallenge) + "&state=" + oAuthSession.getState();
response.getLinks().setScaRedirect(new Links.Href(authorizationLink, LinkType.SCA_REDIRECT));
return true;
}
}
return false;
}
use of net.petafuel.styx.core.xs2a.entities.StrongAuthenticatableResource in project styx by petafuel.
the class STYX03 method apply.
@Override
public boolean apply(XS2AFactoryInput xs2AFactoryInput, XS2ARequest xs2ARequest, XS2AResponse xs2AResponse) throws ImplementerOptionException {
if (xs2AResponse instanceof StrongAuthenticatableResource) {
Boolean optionRequired = ioParser.getOption(IO, IOParser.Option.REQUIRED);
if (optionRequired != null && optionRequired) {
StrongAuthenticatableResource response = (StrongAuthenticatableResource) xs2AResponse;
String redirectLink = response.getLinks().getScaRedirect().getUrl();
OAuthSession oAuthSession = PersistentOAuthSession.getById(STYX03.getPreauthId());
String codeChallenge = OAuthService.getCodeChallengeFromState(oAuthSession.getState());
redirectLink = redirectLink.replace("{code_challenge}", codeChallenge);
response.getLinks().setScaRedirect(new Links.Href(redirectLink, LinkType.SCA_REDIRECT));
return true;
}
}
return false;
}
use of net.petafuel.styx.core.xs2a.entities.StrongAuthenticatableResource in project styx by petafuel.
the class STYX07 method apply.
@Override
public boolean apply(XS2AFactoryInput xs2AFactoryInput, XS2ARequest xs2ARequest, XS2AResponse xs2AResponse) throws ImplementerOptionException {
if (Boolean.FALSE.equals(ioParser.getOption(IO, IOParser.Option.REQUIRED))) {
return false;
}
if (!(xs2AResponse instanceof StrongAuthenticatableResource)) {
LOG.debug("Not executing, response is not StrongAuthenticatableResource");
return false;
}
StrongAuthenticatableResource scaResource = (StrongAuthenticatableResource) xs2AResponse;
ThreadManager.getInstance().queueTask(new PaymentStatusPoll(xs2AFactoryInput, ioParser.getAspsp().getBic(), scaResource.getxRequestId()));
return true;
}
Aggregations