use of net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth in project styx by petafuel.
the class AccountResource method getAccountDetails.
/**
* Returns AccountDetails for a single account
*
* @param accountId the xs2a account id
* @return returns an account object
* @see AccountDetails
*/
@AcceptsPreStepAuth
@GET
@Path("/accounts/{resourceId}")
public Response getAccountDetails(@NotNull @NotBlank @HeaderParam("consentId") String consentId, @NotNull @NotBlank @PathParam("resourceId") String accountId) throws BankRequestFailedException {
xs2AFactoryInput.setConsentId(consentId);
xs2AFactoryInput.setAccountId(accountId);
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
AISRequest accountDetailsRequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().accountDetails(), xs2AFactoryInput);
accountDetailsRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(accountDetailsRequest, xs2AFactoryInput);
AccountDetails account = getXS2AStandard().getAis().getAccount(accountDetailsRequest);
account.setLinks(new AspspUrlMapper(account.getResourceId()).map(account.getLinks()));
LOG.info("Successfully fetched account details bic={}", getXS2AStandard().getAspsp().getBic());
return Response.status(200).entity(new AccountDetailResponse(account)).build();
}
use of net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth in project styx by petafuel.
the class PaymentAuthorisationResource method startPaymentAuthorisation.
/**
* If the ASPSP has not implicitly created an authorisation resource, this Endpoint can create an authorisation resource
*
* @param paymentTypeBean payment-service and payment-product
* @param paymentId id of the payment an authorisation should be started for
* @param authorisationRequest the request resource might contain an empty body or PSUData authentication
* @return returns an SCA container with further information on the Authorisation
* @throws BankRequestFailedException in case the communication between styx and aspsp was not successful
*/
@AcceptsPreStepAuth
@POST
@Path("/{paymentService}/{paymentProduct}/{paymentId}/authorisations")
public Response startPaymentAuthorisation(@BeanParam PaymentTypeBean paymentTypeBean, @NotEmpty @NotBlank @PathParam("paymentId") String paymentId, @Valid @NotNull AuthorisationRequest authorisationRequest) throws BankRequestFailedException {
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setPaymentService(paymentTypeBean.getPaymentService());
xs2AFactoryInput.setPaymentProduct(paymentTypeBean.getPaymentProduct());
xs2AFactoryInput.setPsu(getPsu());
xs2AFactoryInput.setPaymentId(paymentId);
xs2AFactoryInput.setPsuData(authorisationRequest.getPsuData());
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
SCARequest xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStart(), xs2AFactoryInput);
if (getRedirectPreferred() != null) {
xs2AAuthorisationRequest.setTppRedirectPreferred(getRedirectPreferred());
}
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
SCA paymentSCA = getXS2AStandard().getPis().startAuthorisation(xs2AAuthorisationRequest);
AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(paymentTypeBean.getPaymentService(), paymentTypeBean.getPaymentProduct(), paymentId, paymentSCA.getAuthorisationId());
paymentSCA.setLinks(aspspUrlMapper.map(paymentSCA.getLinks()));
LOG.info("Payment Authorisation started for paymentId={} scaStatus={} scaApproach={}", paymentId, paymentSCA.getScaStatus(), paymentSCA.getApproach());
return Response.status(ResponseConstant.OK).entity(paymentSCA).build();
}
use of net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth in project styx by petafuel.
the class PaymentAuthorisationResource method updatePaymentAuthorisation.
/**
* 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 paymentTypeBean
* @param paymentId
* @param authorisationId
* @param authorisationRequest
* @return
* @throws BankRequestFailedException
*/
@AcceptsPreStepAuth
@PUT
@Path("/{paymentService}/{paymentProduct}/{paymentId}/authorisations/{authorisationId}")
public Response updatePaymentAuthorisation(@BeanParam PaymentTypeBean paymentTypeBean, @NotEmpty @NotBlank @PathParam("paymentId") String paymentId, @NotEmpty @NotBlank @PathParam("authorisationId") String authorisationId, @Valid AuthorisationRequest authorisationRequest) throws BankRequestFailedException {
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setPaymentService(paymentTypeBean.getPaymentService());
xs2AFactoryInput.setPaymentProduct(paymentTypeBean.getPaymentProduct());
xs2AFactoryInput.setPaymentId(paymentId);
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 paymentSCA;
SCARequest xs2AAuthorisationRequest;
if (authorisationRequest.getPsuData() != null) {
xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaUpdateAuthentication(), xs2AFactoryInput);
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
paymentSCA = getXS2AStandard().getPis().updatePSUAuthentication(xs2AAuthorisationRequest);
} else if (authorisationRequest.getAuthenticationMethodId() != null) {
xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaUpdateAuthenticationMethod(), xs2AFactoryInput);
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
paymentSCA = getXS2AStandard().getPis().selectAuthenticationMethod(xs2AAuthorisationRequest);
} else if (authorisationRequest.getScaAuthenticationData() != null) {
xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaAuthoriseTransaction(), xs2AFactoryInput);
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
paymentSCA = getXS2AStandard().getPis().authoriseTransaction(xs2AAuthorisationRequest);
} else {
xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaUpdateIdentification(), xs2AFactoryInput);
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
paymentSCA = getXS2AStandard().getPis().updatePSUIdentification(xs2AAuthorisationRequest);
}
AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(paymentTypeBean.getPaymentService(), paymentTypeBean.getPaymentProduct(), paymentId, authorisationId);
paymentSCA.setLinks(aspspUrlMapper.map(paymentSCA.getLinks()));
LOG.info("Payment Authorisation updated for paymentId={} authorisationId={} scaStatus={} scaApproach={}", paymentId, authorisationId, paymentSCA.getScaStatus(), paymentSCA.getApproach());
return Response.status(ResponseConstant.OK).entity(paymentSCA).build();
}
use of net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth in project styx by petafuel.
the class PaymentStatusResource method getSinglePaymentStatus.
/**
* Returns the status of a payment
*
* @param paymentTypeBean payment-service and payment-product
* @param paymentId id of the target payment
* @return a PaymentStatus object
* @throws BankRequestFailedException if something went wrong between the core service and the aspsp
*/
@AcceptsPreStepAuth
@GET
@Path("/{paymentService}/{paymentProduct}/{paymentId}/status")
public Response getSinglePaymentStatus(@BeanParam PaymentTypeBean paymentTypeBean, @PathParam("paymentId") @NotEmpty @NotBlank 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);
PISRequest readPaymentStatusRequest = new PISRequestFactory().create(getXS2AStandard().getRequestClassProvider().paymentStatus(), xs2AFactoryInput);
readPaymentStatusRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(readPaymentStatusRequest, xs2AFactoryInput);
PaymentStatus status = getXS2AStandard().getPis().getPaymentStatus(readPaymentStatusRequest);
if (PersistentPayment.getByPaymentId(paymentId) == null) {
PersistentPayment.create(ThreadContext.get("requestUUID"), paymentId, (String) getContainerRequestContext().getProperty(AbstractTokenFilter.class.getName()), getXS2AStandard().getAspsp().getBic(), status.getTransactionStatus(), paymentTypeBean.getPaymentService(), paymentTypeBean.getPaymentProduct());
} else {
PersistentPayment.updateStatusByPaymentId(paymentId, status.getTransactionStatus());
}
LOG.info("Successfully read the payment status entity for bic={}, paymentId={}", getXS2AStandard().getAspsp().getBic(), paymentId);
return Response.status(200).entity(status).build();
}
Aggregations