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();
}
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));
}
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));
}
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));
}
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);
}
Aggregations