Search in sources :

Example 51 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class FundsConfirmationApiController method createFundsConfirmation.

@Override
public ResponseEntity createFundsConfirmation(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBFundsConfirmation1 obFundsConfirmation, @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, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = obFundsConfirmation.getData().getConsentId();
    FRFundsConfirmationConsent consent = fundsConfirmationService.getConsent(consentId);
    return rsEndpointWrapperService.fundsConfirmationEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).consent(consent).principal(principal).filters(f -> {
        f.verifyConsentStatus();
        f.verifyConsentExpiration();
    }).execute((String tppId) -> {
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBFundsConfirmationResponse1.class, obFundsConfirmation);
    });
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) HttpHeaders(org.springframework.http.HttpHeaders) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) ApiParam(io.swagger.annotations.ApiParam) OBFundsConfirmationResponse1(uk.org.openbanking.datamodel.fund.OBFundsConfirmationResponse1) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) RequestBody(org.springframework.web.bind.annotation.RequestBody) Valid(javax.validation.Valid) Slf4j(lombok.extern.slf4j.Slf4j) HttpServletRequest(javax.servlet.http.HttpServletRequest) Principal(java.security.Principal) OBFundsConfirmation1(uk.org.openbanking.datamodel.fund.OBFundsConfirmation1) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) FundsConfirmationService(com.forgerock.openbanking.common.services.store.funds.FundsConfirmationService) Collections(java.util.Collections) FRFundsConfirmationConsent(com.forgerock.openbanking.common.model.openbanking.persistence.funds.FRFundsConfirmationConsent) HttpHeaders(org.springframework.http.HttpHeaders) FRFundsConfirmationConsent(com.forgerock.openbanking.common.model.openbanking.persistence.funds.FRFundsConfirmationConsent)

Example 52 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT 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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    LOGGER.info("Receveid a new account request");
    return RSEndpointWrapperService.accountRequestEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).filters(f -> {
        f.verifyJwsDetachedSignature(xJwsSignature, request);
        accountAccessConsentPermittedPermissionsFilter.filter(body.getData().getPermissions());
        accountAccessConsentBasicAndDetailPermissionsFilter.filter(body.getData());
    }).execute((String aispId) -> {
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-aisp_id", aispId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBReadResponse1.class, body);
    });
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) Logger(org.slf4j.Logger) OBReadResponse1(uk.org.openbanking.datamodel.account.OBReadResponse1) AccountAccessConsentBasicAndDetailPermissionsFilter(com.forgerock.openbanking.aspsp.rs.wrappper.endpoints.AccountAccessConsentBasicAndDetailPermissionsFilter) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) HttpHeaders(org.springframework.http.HttpHeaders) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) AccountAccessConsentPermittedPermissionsFilter(com.forgerock.openbanking.aspsp.rs.wrappper.endpoints.AccountAccessConsentPermittedPermissionsFilter) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) RequestBody(org.springframework.web.bind.annotation.RequestBody) Valid(javax.validation.Valid) HttpServletRequest(javax.servlet.http.HttpServletRequest) Principal(java.security.Principal) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadRequest1(uk.org.openbanking.datamodel.account.OBReadRequest1) Collections(java.util.Collections) HttpHeaders(org.springframework.http.HttpHeaders)

Example 53 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getTransactions.

@Override
public ResponseEntity<OBReadTransaction5> getTransactions(@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 = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @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, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @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("Reading transations from account ids {}, fromBookingDate {} toBookingDate {} " + "minimumPermissions {} pageNumber {} ", accountIds, fromBookingDateTime, toBookingDateTime, permissions, page);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> body = FRTransactionRepository.byAccountIdInAndBookingDateTimeBetweenWithPermissions(accountIds, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction5> transactions = body.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction5).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = body.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction5().data(new OBReadTransaction5Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) RequestParam(org.springframework.web.bind.annotation.RequestParam) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction5Data(uk.org.openbanking.datamodel.account.OBReadTransaction5Data) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) AVAILABLE_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.AVAILABLE_DATE_FORMAT) Value(org.springframework.beans.factory.annotation.Value) OBReadTransaction5(uk.org.openbanking.datamodel.account.OBReadTransaction5) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) Sort(org.springframework.data.domain.Sort) BOOKED_TIME_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.BOOKED_TIME_DATE_FORMAT) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) OBTransaction5(uk.org.openbanking.datamodel.account.OBTransaction5) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) OBReadTransaction5Data(uk.org.openbanking.datamodel.account.OBReadTransaction5Data) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) OBReadTransaction5(uk.org.openbanking.datamodel.account.OBReadTransaction5) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBTransaction5(uk.org.openbanking.datamodel.account.OBTransaction5)

Example 54 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getAccountStatementTransactions.

@Override
public ResponseEntity<OBReadTransaction5> getAccountStatementTransactions(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "A unique identifier used to identify the statement resource.", required = true) @PathVariable("StatementId") String statementId, @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 UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @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, @RequestHeader(value = "x-ob-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    log.info("Reading transations from account id {}, statement id {}, fromBookingDate {} toBookingDate {} " + "minimumPermissions {} pageNumber {} ", accountId, statementId, fromBookingDateTime, toBookingDateTime, permissions, page);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = FRTransactionRepository.byAccountIdAndStatementIdAndBookingDateTimeBetweenWithPermissions(accountId, statementId, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction5> transactions = response.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction5).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction5().data(new OBReadTransaction5Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) RequestParam(org.springframework.web.bind.annotation.RequestParam) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction5Data(uk.org.openbanking.datamodel.account.OBReadTransaction5Data) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) AVAILABLE_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.AVAILABLE_DATE_FORMAT) Value(org.springframework.beans.factory.annotation.Value) OBReadTransaction5(uk.org.openbanking.datamodel.account.OBReadTransaction5) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) Sort(org.springframework.data.domain.Sort) BOOKED_TIME_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.BOOKED_TIME_DATE_FORMAT) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) OBTransaction5(uk.org.openbanking.datamodel.account.OBTransaction5) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) OBReadTransaction5Data(uk.org.openbanking.datamodel.account.OBReadTransaction5Data) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) OBReadTransaction5(uk.org.openbanking.datamodel.account.OBReadTransaction5) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBTransaction5(uk.org.openbanking.datamodel.account.OBTransaction5)

Example 55 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalStandingOrderConsentsApiController method createInternationalStandingOrderConsents.

@Override
public ResponseEntity<OBWriteInternationalStandingOrderConsentResponse3> createInternationalStandingOrderConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalStandingOrderConsent3 OBWriteInternationalStandingOrderConsent3Param, @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 = "Every request will be processed only once per x-idempotency-key.  The Idempotency Key will be valid for 24 hours.", required = true) @RequestHeader(value = "x-idempotency-key", required = true) String xIdempotencyKey, @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 = "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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    return rsEndpointWrapperService.paymentEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).filters(f -> {
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyJwsDetachedSignature(xJwsSignature, request);
        f.validateRisk(OBWriteInternationalStandingOrderConsent3Param.getRisk());
    }).execute((String tppId) -> {
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-client-id", tppId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalStandingOrderConsentResponse3.class, OBWriteInternationalStandingOrderConsent3Param);
    });
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) HttpHeaders(org.springframework.http.HttpHeaders) OBWriteInternationalStandingOrderConsentResponse3(uk.org.openbanking.datamodel.payment.OBWriteInternationalStandingOrderConsentResponse3) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) ApiParam(io.swagger.annotations.ApiParam) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) OBWriteInternationalStandingOrderConsent3(uk.org.openbanking.datamodel.payment.OBWriteInternationalStandingOrderConsent3) RequestBody(org.springframework.web.bind.annotation.RequestBody) Valid(javax.validation.Valid) HttpServletRequest(javax.servlet.http.HttpServletRequest) Principal(java.security.Principal) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) Collections(java.util.Collections) HttpHeaders(org.springframework.http.HttpHeaders)

Aggregations

HTTP_DATE_FORMAT (com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT)63 DateTime (org.joda.time.DateTime)63 DateTimeFormat (org.springframework.format.annotation.DateTimeFormat)63 ResponseEntity (org.springframework.http.ResponseEntity)63 Controller (org.springframework.stereotype.Controller)63 PathVariable (org.springframework.web.bind.annotation.PathVariable)63 RequestHeader (org.springframework.web.bind.annotation.RequestHeader)63 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)62 ApiParam (io.swagger.annotations.ApiParam)62 Logger (org.slf4j.Logger)50 LoggerFactory (org.slf4j.LoggerFactory)50 Collections (java.util.Collections)43 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)42 Principal (java.security.Principal)42 HttpServletRequest (javax.servlet.http.HttpServletRequest)42 Valid (javax.validation.Valid)42 HttpHeaders (org.springframework.http.HttpHeaders)42 RequestBody (org.springframework.web.bind.annotation.RequestBody)42 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)41 Autowired (org.springframework.beans.factory.annotation.Autowired)38