use of net.petafuel.styx.api.filter.input.boundary.RequiresPSU in project styx by petafuel.
the class ConsentAuthorisationResource method startConsentAuthorisation.
/**
* Starts a consent authorisation
*
* @param consentId of the target consent
* @return a GetConsentResponse object
* @throws BankRequestFailedException if something went wrong between the core service and the aspsp
*/
@AcceptsPreStepAuth
@POST
@RequiresPSU
@Path("/consents/{consentId}/authorisations")
public Response startConsentAuthorisation(@NotEmpty @NotBlank @PathParam("consentId") String consentId, @Valid AuthorisationRequest authorisationRequest) throws BankRequestFailedException {
consentId = Sanitizer.replaceEscSeq(consentId);
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsentId(consentId);
xs2AFactoryInput.setPsuData(authorisationRequest.getPsuData());
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
SCARequest xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStart(), xs2AFactoryInput);
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
if (getRedirectPreferred() != null) {
xs2AAuthorisationRequest.setTppRedirectPreferred(getRedirectPreferred());
}
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
SCA consentSCA = getXS2AStandard().getCs().startAuthorisation(xs2AAuthorisationRequest);
AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(consentId, consentSCA.getAuthorisationId());
consentSCA.setLinks(aspspUrlMapper.map(consentSCA.getLinks()));
LOG.info("Consent Authorisation started for consentId={} scaStatus={} scaApproach={}", consentId, consentSCA.getScaStatus(), consentSCA.getApproach());
return Response.status(ResponseConstant.CREATED).entity(consentSCA).build();
}
Aggregations