Search in sources :

Example 1 with OBVersion

use of com.forgerock.openbanking.common.model.version.OBVersion in project openbanking-aspsp by OpenBankingToolkit.

the class ApiVersionMatcherTest method shouldGetVersionGiven3_1_4.

@Test
public void shouldGetVersionGiven3_1_4() {
    // Given
    String requestUri = "v3.1.4/pisp";
    // When
    OBVersion version = ApiVersionUtils.getOBVersion(requestUri);
    // Then
    assertThat(version).isEqualTo(OBVersion.v3_1_4);
}
Also used : OBVersion(com.forgerock.openbanking.common.model.version.OBVersion) Test(org.junit.Test)

Example 2 with OBVersion

use of com.forgerock.openbanking.common.model.version.OBVersion in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticVrpConsentsApiController method domesticVrpConsentsFundsConfirmation.

@Override
public ResponseEntity domesticVrpConsentsFundsConfirmation(String consentId, String authorization, String xJwsSignature, OBVRPFundsConfirmationRequest obVRPFundsConfirmationRequest, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Request to get a VRP funds confirmation, consentId '{}'", consentId);
    if (!consentId.equals(obVRPFundsConfirmationRequest.getData().getConsentId())) {
        log.error("The consent ID '{}' path parameter does not match with the consent ID '{}' requested to confirm the funds.", consentId, obVRPFundsConfirmationRequest.getData().getConsentId());
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("The consent ID '" + consentId + "' path parameter does not match with the consent ID '" + obVRPFundsConfirmationRequest.getData().getConsentId() + "' requested to confirm the funds.");
    }
    log.debug("(domesticVrpConsentsFundsConfirmation) Request mode test: '{}'", StringUtils.hasLength(request.getHeader(OpenBankingHttpHeaders.X_OB_MODE_TEST)));
    return rsEndpointWrapperService.vrpPaymentEndpoint().authorization(authorization).xFapiFinancialId(xFapiInteractionId).principal(principal).isAuthorizationCodeGrantType(true).obVersion(OBVersion.v3_1_8).filters(f -> {
        f.verifyJwsDetachedSignature(xJwsSignature, request);
    }).execute((String tppId) -> {
        HttpHeaders additionalHeaders = new HttpHeaders();
        return rsStoreGateway.toRsStore(request, additionalHeaders, Collections.emptyMap(), OBVRPFundsConfirmationResponse.class, obVRPFundsConfirmationRequest);
    });
}
Also used : OBVersion(com.forgerock.openbanking.common.model.version.OBVersion) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) HttpHeaders(org.springframework.http.HttpHeaders) OBDomesticVRPConsentRequest(uk.org.openbanking.datamodel.vrp.OBDomesticVRPConsentRequest) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) Autowired(org.springframework.beans.factory.annotation.Autowired) OBVRPFundsConfirmationResponse(uk.org.openbanking.datamodel.vrp.OBVRPFundsConfirmationResponse) Controller(org.springframework.stereotype.Controller) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) HttpServletRequest(javax.servlet.http.HttpServletRequest) Principal(java.security.Principal) OpenBankingHttpHeaders(com.forgerock.openbanking.common.constants.OpenBankingHttpHeaders) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) ResponseEntity(org.springframework.http.ResponseEntity) OBDomesticVRPConsentResponse(uk.org.openbanking.datamodel.vrp.OBDomesticVRPConsentResponse) Collections(java.util.Collections) StringUtils(org.springframework.util.StringUtils) OBVRPFundsConfirmationRequest(uk.org.openbanking.datamodel.vrp.OBVRPFundsConfirmationRequest) HttpHeaders(org.springframework.http.HttpHeaders) OpenBankingHttpHeaders(com.forgerock.openbanking.common.constants.OpenBankingHttpHeaders)

Example 3 with OBVersion

use of com.forgerock.openbanking.common.model.version.OBVersion in project openbanking-aspsp by OpenBankingToolkit.

the class ApiVersionUtils method getOBVersion.

/**
 * Find and Provides the version of the API supported by this instance if it contained in the passed parameter.
 * @param s
 *         parameter passed to find the version supported.
 * @return The {@link OBVersion} matching.
 */
public static OBVersion getOBVersion(String s) {
    Matcher matcher = VERSION_PATTERN.matcher(format(s));
    if (!matcher.find()) {
        throw new IllegalArgumentException("Unable to determine version from passed parameter: " + s);
    }
    OBVersion version = OBVersion.fromString(matcher.group());
    if (version == null) {
        log.debug("Unknown version value from: {}", s);
        throw new IllegalArgumentException("Unknown version value from: " + s);
    }
    return version;
}
Also used : Matcher(java.util.regex.Matcher) OBVersion(com.forgerock.openbanking.common.model.version.OBVersion)

Example 4 with OBVersion

use of com.forgerock.openbanking.common.model.version.OBVersion in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticVrpConsentsApiController method domesticVrpConsentsPost.

@Override
public ResponseEntity domesticVrpConsentsPost(String authorization, String xIdempotencyKey, String xJwsSignature, OBDomesticVRPConsentRequest obDomesticVRPConsentRequest, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Request to create a VRP consent received, interactionId '{}'", xFapiInteractionId);
    return rsEndpointWrapperService.vrpPaymentEndpoint().authorization(authorization).xFapiFinancialId(xFapiInteractionId).principal(principal).obVersion(OBVersion.v3_1_8).filters(f -> {
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyJwsDetachedSignature(xJwsSignature, request);
    }).execute((String tppId) -> {
        HttpHeaders additionalHeaders = new HttpHeaders();
        additionalHeaders.add("x-ob-client-id", tppId);
        return rsStoreGateway.toRsStore(request, additionalHeaders, Collections.emptyMap(), OBDomesticVRPConsentResponse.class, obDomesticVRPConsentRequest);
    });
}
Also used : OBVersion(com.forgerock.openbanking.common.model.version.OBVersion) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) HttpHeaders(org.springframework.http.HttpHeaders) OBDomesticVRPConsentRequest(uk.org.openbanking.datamodel.vrp.OBDomesticVRPConsentRequest) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) Autowired(org.springframework.beans.factory.annotation.Autowired) OBVRPFundsConfirmationResponse(uk.org.openbanking.datamodel.vrp.OBVRPFundsConfirmationResponse) Controller(org.springframework.stereotype.Controller) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) HttpServletRequest(javax.servlet.http.HttpServletRequest) Principal(java.security.Principal) OpenBankingHttpHeaders(com.forgerock.openbanking.common.constants.OpenBankingHttpHeaders) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) ResponseEntity(org.springframework.http.ResponseEntity) OBDomesticVRPConsentResponse(uk.org.openbanking.datamodel.vrp.OBDomesticVRPConsentResponse) Collections(java.util.Collections) StringUtils(org.springframework.util.StringUtils) OBVRPFundsConfirmationRequest(uk.org.openbanking.datamodel.vrp.OBVRPFundsConfirmationRequest) HttpHeaders(org.springframework.http.HttpHeaders) OpenBankingHttpHeaders(com.forgerock.openbanking.common.constants.OpenBankingHttpHeaders)

Example 5 with OBVersion

use of com.forgerock.openbanking.common.model.version.OBVersion in project openbanking-aspsp by OpenBankingToolkit.

the class ApiVersionMatcherTest method shouldGetVersionGiven3_1_3.

@Test
public void shouldGetVersionGiven3_1_3() {
    // Given
    String requestUri = "/open-banking/v3.1.3";
    // When
    OBVersion version = ApiVersionUtils.getOBVersion(requestUri);
    // Then
    assertThat(version).isEqualTo(OBVersion.v3_1_3);
}
Also used : OBVersion(com.forgerock.openbanking.common.model.version.OBVersion) Test(org.junit.Test)

Aggregations

OBVersion (com.forgerock.openbanking.common.model.version.OBVersion)7 Test (org.junit.Test)4 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)2 OpenBankingHttpHeaders (com.forgerock.openbanking.common.constants.OpenBankingHttpHeaders)2 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)2 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)2 Principal (java.security.Principal)2 Collections (java.util.Collections)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 HttpHeaders (org.springframework.http.HttpHeaders)2 HttpStatus (org.springframework.http.HttpStatus)2 ResponseEntity (org.springframework.http.ResponseEntity)2 Controller (org.springframework.stereotype.Controller)2 StringUtils (org.springframework.util.StringUtils)2 OBDomesticVRPConsentRequest (uk.org.openbanking.datamodel.vrp.OBDomesticVRPConsentRequest)2 OBDomesticVRPConsentResponse (uk.org.openbanking.datamodel.vrp.OBDomesticVRPConsentResponse)2 OBVRPFundsConfirmationRequest (uk.org.openbanking.datamodel.vrp.OBVRPFundsConfirmationRequest)2 OBVRPFundsConfirmationResponse (uk.org.openbanking.datamodel.vrp.OBVRPFundsConfirmationResponse)2