Search in sources :

Example 1 with RequiresPSU

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();
}
Also used : SCA(net.petafuel.styx.core.xs2a.entities.SCA) SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) AspspUrlMapper(net.petafuel.styx.api.util.AspspUrlMapper) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) RequiresPSU(net.petafuel.styx.api.filter.input.boundary.RequiresPSU) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) POST(javax.ws.rs.POST)

Aggregations

ApplicationPath (javax.ws.rs.ApplicationPath)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)1 RequiresPSU (net.petafuel.styx.api.filter.input.boundary.RequiresPSU)1 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)1 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)1 SCARequest (net.petafuel.styx.core.xs2a.contracts.SCARequest)1 SCA (net.petafuel.styx.core.xs2a.entities.SCA)1 SCARequestFactory (net.petafuel.styx.core.xs2a.factory.SCARequestFactory)1 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)1