Search in sources :

Example 1 with SCARequestFactory

use of net.petafuel.styx.core.xs2a.factory.SCARequestFactory 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)

Example 2 with SCARequestFactory

use of net.petafuel.styx.core.xs2a.factory.SCARequestFactory in project styx by petafuel.

the class ConsentAuthorisationResource method getScaStatus.

@AcceptsPreStepAuth
@GET
@Path("/consents/{consentId}/authorisations/{authorisationId}")
public Response getScaStatus(@NotEmpty @NotBlank @PathParam("consentId") String consentId, @NotEmpty @NotBlank @PathParam("authorisationId") String authorisationId) throws BankRequestFailedException {
    consentId = Sanitizer.replaceEscSeq(consentId);
    authorisationId = Sanitizer.replaceEscSeq(authorisationId);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setConsentId(consentId);
    xs2AFactoryInput.setAuthorisationId(authorisationId);
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCARequest getAuthorisationStatusRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStatus(), xs2AFactoryInput);
    getAuthorisationStatusRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(getAuthorisationStatusRequest, xs2AFactoryInput);
    SCA.Status authorisationStatus = getXS2AStandard().getCs().getSCAStatus(getAuthorisationStatusRequest);
    AuthorisationStatusResponse response = new AuthorisationStatusResponse();
    response.setScaStatus(authorisationStatus.getValue());
    LOG.info("Consent Authorisation Status requested for consentId={} authorisationId={} scaStatus={}", consentId, authorisationId, authorisationStatus.getValue());
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : SCA(net.petafuel.styx.core.xs2a.entities.SCA) SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) GET(javax.ws.rs.GET)

Example 3 with SCARequestFactory

use of net.petafuel.styx.core.xs2a.factory.SCARequestFactory in project styx by petafuel.

the class PaymentAuthorisationResource method getScaStatus.

/**
 * PIS - Get authorisation SCA status
 *
 * @param paymentTypeBean
 * @param paymentId
 * @param authorisationId
 * @return
 * @throws BankRequestFailedException
 */
@AcceptsPreStepAuth
@GET
@Path("/{paymentService}/{paymentProduct}/{paymentId}/authorisations/{authorisationId}")
public Response getScaStatus(@BeanParam PaymentTypeBean paymentTypeBean, @NotEmpty @NotBlank @PathParam("paymentId") String paymentId, @NotEmpty @NotBlank @PathParam("authorisationId") String authorisationId) throws BankRequestFailedException {
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPaymentService(paymentTypeBean.getPaymentService());
    xs2AFactoryInput.setPaymentProduct(paymentTypeBean.getPaymentProduct());
    xs2AFactoryInput.setPaymentId(paymentId);
    xs2AFactoryInput.setAuthorisationId(authorisationId);
    xs2AFactoryInput.setPsu(getPsu());
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCARequest getAuthorisationStatusRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStatus(), xs2AFactoryInput);
    getAuthorisationStatusRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(getAuthorisationStatusRequest, xs2AFactoryInput);
    SCA.Status authorisationStatus = getXS2AStandard().getPis().getSCAStatus(getAuthorisationStatusRequest);
    AuthorisationStatusResponse response = new AuthorisationStatusResponse();
    response.setScaStatus(authorisationStatus.getValue());
    LOG.info("Successfully fetched Authorisation status for payment={}, authorisationId={}", paymentId, authorisationId);
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : SCA(net.petafuel.styx.core.xs2a.entities.SCA) SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 4 with SCARequestFactory

use of net.petafuel.styx.core.xs2a.factory.SCARequestFactory in project styx by petafuel.

the class PaymentAuthorisationResource method getAuthorisationIds.

/**
 * PIS - Fetch multiple SCAs for a payment
 *
 * @param paymentTypeBean
 * @param paymentId
 * @return
 * @throws BankRequestFailedException
 */
@AcceptsPreStepAuth
@GET
@Path("/{paymentService}/{paymentProduct}/{paymentId}/authorisations")
public Response getAuthorisationIds(@BeanParam PaymentTypeBean paymentTypeBean, @NotEmpty @NotBlank @PathParam("paymentId") String paymentId) throws BankRequestFailedException {
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPaymentService(paymentTypeBean.getPaymentService());
    xs2AFactoryInput.setPaymentProduct(paymentTypeBean.getPaymentProduct());
    xs2AFactoryInput.setPaymentId(paymentId);
    xs2AFactoryInput.setPsu(getPsu());
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCARequest getAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaRetrieval(), xs2AFactoryInput);
    getAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(getAuthorisationRequest, xs2AFactoryInput);
    List<String> authorisationIds = getXS2AStandard().getPis().getAuthorisations(getAuthorisationRequest);
    AuthorisationIdsResponse response = new AuthorisationIdsResponse();
    response.setAuthorisationIds(authorisationIds);
    LOG.info("Successfully fetched Authorisation ids for payment={}", paymentId);
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) AuthorisationIdsResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationIdsResponse) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 5 with SCARequestFactory

use of net.petafuel.styx.core.xs2a.factory.SCARequestFactory in project styx by petafuel.

the class ConsentAuthorisationResource method updateConsentAuthorisation.

/**
 * This endpoint covers 4 use cases
 * Empty authorisationRequest -> PSU Identification, the PSU-* Headers are transmitted to the aspsp
 * PSUData -> PSU Authentication, login the PSU with pin/password on the ASPSP interface
 * authenticationMethodId -> SCAMethod Selection, if there are multiple SCAMethods for the PSU to choose from
 * scaAuthenticationData -> if the PSU has received a TAN for the SCA process we can forward it to the ASPSP
 *
 * @param consentId
 * @param authorisationId
 * @param authorisationRequest
 * @return
 * @throws BankRequestFailedException
 */
@AcceptsPreStepAuth
@PUT
@Path("/consents/{consentId}/authorisations/{authorisationId}")
public Response updateConsentAuthorisation(@NotEmpty @NotBlank @PathParam("consentId") String consentId, @NotEmpty @NotBlank @PathParam("authorisationId") String authorisationId, @Valid AuthorisationRequest authorisationRequest) throws BankRequestFailedException {
    consentId = Sanitizer.replaceEscSeq(consentId);
    authorisationId = Sanitizer.replaceEscSeq(authorisationId);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setConsentId(consentId);
    xs2AFactoryInput.setPsu(getPsu());
    xs2AFactoryInput.setAuthorisationId(authorisationId);
    xs2AFactoryInput.setPsuData(authorisationRequest.getPsuData());
    xs2AFactoryInput.setAuthorisationMethodId(authorisationRequest.getAuthenticationMethodId());
    xs2AFactoryInput.setScaAuthenticationData(authorisationRequest.getScaAuthenticationData());
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCA consentSCA;
    SCARequest xs2AAuthorisationRequest;
    if (authorisationRequest.getPsuData() != null) {
        xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaUpdateAuthentication(), xs2AFactoryInput);
        xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
        ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
        consentSCA = getXS2AStandard().getCs().updatePSUAuthentication(xs2AAuthorisationRequest);
    } else if (authorisationRequest.getAuthenticationMethodId() != null) {
        xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaUpdateAuthenticationMethod(), xs2AFactoryInput);
        xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
        ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
        consentSCA = getXS2AStandard().getCs().selectAuthenticationMethod(xs2AAuthorisationRequest);
    } else if (authorisationRequest.getScaAuthenticationData() != null) {
        xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaAuthoriseTransaction(), xs2AFactoryInput);
        xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
        ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
        consentSCA = getXS2AStandard().getCs().authoriseTransaction(xs2AAuthorisationRequest);
    } else {
        xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaUpdateIdentification(), xs2AFactoryInput);
        xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
        ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
        consentSCA = getXS2AStandard().getCs().updatePSUIdentification(xs2AAuthorisationRequest);
    }
    AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(consentId, authorisationId);
    consentSCA.setLinks(aspspUrlMapper.map(consentSCA.getLinks()));
    LOG.info("Consent Authorisation updated for consentId={} authorisationId={} scaStatus={} scaApproach={}", consentId, authorisationId, consentSCA.getScaStatus(), consentSCA.getApproach());
    return Response.status(ResponseConstant.OK).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) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) PUT(javax.ws.rs.PUT)

Aggregations

Path (javax.ws.rs.Path)7 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)7 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)7 SCARequest (net.petafuel.styx.core.xs2a.contracts.SCARequest)7 SCARequestFactory (net.petafuel.styx.core.xs2a.factory.SCARequestFactory)7 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)7 SCA (net.petafuel.styx.core.xs2a.entities.SCA)6 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)4 ApplicationPath (javax.ws.rs.ApplicationPath)3 GET (javax.ws.rs.GET)3 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2 AuthorisationStatusResponse (net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse)2 RequiresPSU (net.petafuel.styx.api.filter.input.boundary.RequiresPSU)1 AuthorisationIdsResponse (net.petafuel.styx.api.v1.payment.entity.AuthorisationIdsResponse)1