use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountAccessConsentDecisionDelegate method consentDecision.
@Override
public void consentDecision(String consentDecisionSerialised, boolean decision) throws IOException, OBErrorException {
AccountConsentDecision accountConsentDecision = objectMapper.readValue(consentDecisionSerialised, AccountConsentDecision.class);
if (decision) {
List<FRAccount> accounts = accountsService.get(accountRequest.getUserId());
List<String> accountsId = accounts.stream().map(Account::getId).collect(Collectors.toList());
if (!accountsId.containsAll(accountConsentDecision.getSharedAccounts())) {
log.error("The PSU {} is trying to share an account '{}' he doesn't own. List of his accounts '{}'", accountRequest.getUserId(), accountsId, accountConsentDecision.getSharedAccounts());
throw new OBErrorException(OBRIErrorType.RCS_CONSENT_DECISION_INVALID_ACCOUNT, accountRequest.getUserId(), accountsId, accountConsentDecision.getSharedAccounts());
}
accountRequest.setAccountIds(accountConsentDecision.getSharedAccounts());
accountRequest.setStatus(FRExternalRequestStatusCode.AUTHORISED);
accountRequest.setStatusUpdateDateTime(DateTime.now());
accountRequestStoreService.save(accountRequest);
} else {
log.debug("The account request {} has been deny", accountRequest.getId());
accountRequest.setStatus(FRExternalRequestStatusCode.REJECTED);
accountRequest.setStatusUpdateDateTime(DateTime.now());
accountRequestStoreService.save(accountRequest);
}
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccount.
@Override
public ResponseEntity<OBReadAccount6> getAccount(String accountId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
log.info("Read account {} with permission {}", accountId, permissions);
FRAccount response = frAccountRepository.byAccountId(accountId, toFRExternalPermissionsCodeList(permissions));
List<OBAccount6> obAccounts = Collections.singletonList(toOBAccount6(response.getAccount()));
return ResponseEntity.ok(new OBReadAccount6().data(new OBReadAccount6Data().account(obAccounts)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccounts.
@Override
public ResponseEntity<OBReadAccount6> getAccounts(String page, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<String> accountIds, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
log.info("Accounts from account ids {}", accountIds);
List<FRAccount> frAccounts = frAccountRepository.byAccountIds(accountIds, toFRExternalPermissionsCodeList(permissions));
List<OBAccount6> obAccounts = frAccounts.stream().map(frAccount -> toOBAccount6(frAccount.getAccount())).collect(Collectors.toList());
return ResponseEntity.ok(new OBReadAccount6().data(new OBReadAccount6Data().account(obAccounts)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccounts.
public ResponseEntity<OBReadAccount3> getAccounts(@ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") String page, @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 = "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, @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-account-ids", required = true) List<String> accountIds, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
log.info("Accounts from account ids {}", accountIds);
List<OBAccount3> accounts = frAccountRepository.byAccountIds(accountIds, toFRExternalPermissionsCodeList(permissions)).stream().map(FRAccount::getAccount).map(FRFinancialAccountConverter::toOBAccount3).collect(Collectors.toList());
return ResponseEntity.ok(new OBReadAccount3().data(new OBReadAccount3Data().account(accounts)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccounts.
@Override
public ResponseEntity<OBReadAccount5> getAccounts(String page, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<String> accountIds, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
log.info("Accounts from account ids {}", accountIds);
List<FRAccount> frAccounts = frAccountRepository.byAccountIds(accountIds, toFRExternalPermissionsCodeList(permissions));
List<OBAccount6> obAccounts = frAccounts.stream().map(frAccount -> toOBAccount6(frAccount.getAccount())).collect(Collectors.toList());
return ResponseEntity.ok(new OBReadAccount5().data(new OBReadAccount5Data().account(obAccounts)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
Aggregations