Search in sources :

Example 6 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class AccountsApiEndpointWrapperTest method verifyAccountId_matches.

@Test
public void verifyAccountId_matches() throws Exception {
    // Given
    String accountId = "12345";
    wrapper.accountRequest = new FRAccountRequest();
    wrapper.accountRequest.setAccountIds(Collections.singletonList(accountId));
    // Then
    assertThatCode(() -> {
        wrapper.accountId(accountId).verifyAccountId();
    }).doesNotThrowAnyException();
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) Test(org.junit.Test)

Example 7 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class AccountsApiControllerIT method mockAccountPermissions.

private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
    FRAccountRequest value = new FRAccountRequest();
    value.setAisp(tpp);
    value.setAccountIds(Collections.singletonList("100000123"));
    value.setAccountRequest(FRReadResponse.builder().data(FRReadDataResponse.builder().permissions(permissions).status(FRExternalRequestStatusCode.AUTHORISED).build()).build());
    given(accountRequestStore.get(any())).willReturn(Optional.of(value));
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest)

Example 8 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiControllerIT method mockAccountPermissions.

private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
    FRAccountRequest value = new FRAccountRequest();
    Tpp tpp = new Tpp();
    tpp.setClientId("test-tpp");
    value.setAisp(tpp);
    value.setAccountIds(Collections.singletonList("100000123"));
    value.setAccountRequest(FRReadResponse.builder().data(FRReadDataResponse.builder().permissions(permissions).transactionFromDateTime(CONSENT_FROM).transactionToDateTime(CONSENT_TO).status(FRExternalRequestStatusCode.AUTHORISED).build()).build());
    given(accountRequestStore.get(any())).willReturn(Optional.of(value));
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) Tpp(com.forgerock.openbanking.model.Tpp)

Example 9 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiControllerIT method mockAccountPermissions.

private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
    FRAccountRequest value = new FRAccountRequest();
    value.setAisp(tpp);
    value.setAccountIds(Collections.singletonList("100000123"));
    value.setAccountRequest(FRReadResponse.builder().data(FRReadDataResponse.builder().permissions(permissions).transactionFromDateTime(CONSENT_FROM).transactionToDateTime(CONSENT_TO).status(FRExternalRequestStatusCode.AUTHORISED).build()).build());
    given(accountRequestStore.get(any())).willReturn(Optional.of(value));
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest)

Example 10 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class AccountRequestsApiController method createAccountRequest.

@Override
public ResponseEntity<OBReadResponse1> createAccountRequest(@ApiParam(value = "Create an Account Request", required = true) @Valid @RequestBody OBReadRequest1 body, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "Header containing a detached JWS signature of the body of the payload.", required = true) @RequestHeader(value = "x-jws-signature", required = false) String xJwsSignature, @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-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @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, @ApiParam(value = "The AISP ID") @RequestHeader(value = "x-ob-aisp_id", required = false) String aispId, HttpServletRequest request) throws OBErrorResponseException {
    LOGGER.info("Received a new account request");
    String accountRequestId = IntentType.ACCOUNT_REQUEST.generateIntentId();
    LOGGER.info("Create a new account request ID {}", accountRequestId);
    OBReadResponse1 response = new OBReadResponse1().data(new OBReadDataResponse1().accountRequestId(accountRequestId).status(OBExternalRequestStatus1Code.AWAITINGAUTHORISATION).creationDateTime(DateTime.now()).permissions(body.getData().getPermissions()).expirationDateTime(body.getData().getExpirationDateTime()).transactionFromDateTime(body.getData().getTransactionFromDateTime()).transactionToDateTime(body.getData().getTransactionToDateTime())).risk(body.getRisk());
    FRAccountRequest accountRequest = new FRAccountRequest();
    accountRequest.setId(accountRequestId);
    accountRequest.setAccountRequestId(accountRequestId);
    accountRequest.setAccountRequest(toFRReadResponse(response));
    accountRequest.setAisp(tppRepository.findByClientId(aispId));
    accountRequest.setObVersion(VersionPathExtractor.getVersionFromPath(request));
    accountRequest = frAccountRequestRepository.save(accountRequest);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(accountRequest.getId(), accountRequest.getStatus().name()));
    LOGGER.debug("Account request created {}", accountRequest.getAccountRequest());
    return ResponseEntity.status(HttpStatus.CREATED).body(response);
}
Also used : FRReadResponseConverter.toOBReadResponse1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRReadResponseConverter.toOBReadResponse1) OBReadResponse1(uk.org.openbanking.datamodel.account.OBReadResponse1) FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) OBReadDataResponse1(uk.org.openbanking.datamodel.account.OBReadDataResponse1) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Aggregations

FRAccountRequest (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest)16 Test (org.junit.Test)6 Tpp (com.forgerock.openbanking.model.Tpp)4 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)3 X509Authentication (com.forgerock.spring.security.multiauth.model.authentication.X509Authentication)3 Authentication (org.springframework.security.core.Authentication)3 ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)2 FRReadResponseConverter.toOBReadResponse1 (com.forgerock.openbanking.common.services.openbanking.converter.account.FRReadResponseConverter.toOBReadResponse1)1 URI (java.net.URI)1 Optional (java.util.Optional)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1 OBReadDataResponse1 (uk.org.openbanking.datamodel.account.OBReadDataResponse1)1 OBReadResponse1 (uk.org.openbanking.datamodel.account.OBReadResponse1)1