Search in sources :

Example 1 with DomesticVrpPaymentsEndpointWrapper

use of com.forgerock.openbanking.aspsp.rs.wrappper.endpoints.DomesticVrpPaymentsEndpointWrapper in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticVrpsApiController method domesticVrpPost.

@Override
public /**
 *         @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true)
 *             @RequestHeader(value = "Authorization", required = true) String authorization,
 *
 *             @ApiParam(value = "A detached JWS signature of the body of the payload.", required = true)
 *             @RequestHeader(value = "x-jws-signature", required = true) String xJwsSignature,
 *
 *             @ApiParam(value = "Default", required = true)
 *             @Valid
 *             @RequestBody OBDomesticVRPRequest obDomesticVRPRequest,
 *
 *             @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC")
 *             @RequestHeader(value = "x-fapi-auth-date", required = false) String xFapiAuthDate,
 *
 *             @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.")
 *             @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress,
 *
 *             @ApiParam(value = "An RFC4122 UID used as a correlation id.")
 *             @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId,
 *
 *             @ApiParam(value = "Indicates the user-agent that the PSU is using.")
 *             @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent,
 */
ResponseEntity<OBDomesticVRPResponse> domesticVrpPost(String authorization, String xJwsSignature, OBDomesticVRPRequest obDomesticVRPRequest, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("domesticVrpPost() Recieved OBDomesticVrpRequest {}", obDomesticVRPRequest);
    @NotNull @Valid OBDomesticVRPInitiation initiation = obDomesticVRPRequest.getData().getInitiation();
    String consentId = obDomesticVRPRequest.getData().getConsentId();
    log.debug("domesticVrpPost() consentId is {}", consentId);
    FRDomesticVRPConsent consent = vrpPaymentConsentService.getVrpPaymentConsent(consentId);
    DomesticVrpPaymentsEndpointWrapper vrpPaymentsEndpointWrapper = rsEndpointWrapperService.vrpPaymentEndpoint();
    vrpPaymentsEndpointWrapper.authorization(authorization);
    vrpPaymentsEndpointWrapper.obVersion(OBVersion.v3_1_8);
    vrpPaymentsEndpointWrapper.xFapiFinancialId(rsEndpointWrapperService.getRsConfiguration().financialId);
    vrpPaymentsEndpointWrapper.principal(principal);
    vrpPaymentsEndpointWrapper.payment(consent);
    vrpPaymentsEndpointWrapper.isAuthorizationCodeGrantType(true);
    vrpPaymentsEndpointWrapper.filters(f -> {
        f.verifyJwsDetachedSignature(xJwsSignature, request);
        f.validateRisk(obDomesticVRPRequest.getRisk());
        f.checkRequestAndConsentInitiationMatch(initiation, consent);
        f.checkRequestAndConsentRiskMatch(obDomesticVRPRequest, consent);
        f.checkControlParameters(obDomesticVRPRequest, consent);
        f.checkCreditorAccountIsInInstructionIfNotInConsent(obDomesticVRPRequest, consent);
    });
    ResponseEntity responseEntity = vrpPaymentsEndpointWrapper.execute((String tppId) -> {
        HttpHeaders additionalHeaders = new HttpHeaders();
        additionalHeaders.add("x-ob-client-id", tppId);
        return rsStoreGateway.toRsStore(request, additionalHeaders, Collections.emptyMap(), OBDomesticVRPResponse.class, obDomesticVRPRequest);
    });
    return responseEntity;
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) Valid(javax.validation.Valid) DomesticVrpPaymentsEndpointWrapper(com.forgerock.openbanking.aspsp.rs.wrappper.endpoints.DomesticVrpPaymentsEndpointWrapper) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) NotNull(javax.validation.constraints.NotNull)

Aggregations

DomesticVrpPaymentsEndpointWrapper (com.forgerock.openbanking.aspsp.rs.wrappper.endpoints.DomesticVrpPaymentsEndpointWrapper)1 FRDomesticVRPConsent (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent)1 Valid (javax.validation.Valid)1 NotNull (javax.validation.constraints.NotNull)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1