Search in sources :

Example 1 with FRWriteDomesticScheduledConsent

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticScheduledPaymentConsentsApiController method createDomesticScheduledPaymentConsents.

@Override
public ResponseEntity<OBWriteDomesticScheduledConsentResponse2> createDomesticScheduledPaymentConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticScheduledConsent2 obWriteDomesticScheduledConsent2, @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, @ApiParam(value = "The PISP ID") @RequestHeader(value = "x-ob-client-id", required = false) String clientId, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received: '{}'", obWriteDomesticScheduledConsent2);
    FRWriteDomesticScheduledConsent frDomesticScheduledConsent = toFRWriteDomesticScheduledConsent(obWriteDomesticScheduledConsent2);
    log.trace("Converted to: '{}'", frDomesticScheduledConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRDomesticScheduledConsent> consentByIdempotencyKey = domesticScheduledConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frDomesticScheduledConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticScheduledConsent());
        log.info("Idempotent request is valid. Returning [201 CREATED] but take no further action.");
        return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(consentByIdempotencyKey.get()));
    }
    log.debug("No consent with matching idempotency key has been found. Creating new consent...");
    FRDomesticScheduledConsent domesticScheduledConsent = FRDomesticScheduledConsent.builder().id(IntentType.PAYMENT_DOMESTIC_SCHEDULED_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticScheduledConsent(frDomesticScheduledConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", domesticScheduledConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticScheduledConsent.getId(), domesticScheduledConsent.getStatus().name()));
    domesticScheduledConsent = domesticScheduledConsentRepository.save(domesticScheduledConsent);
    log.info("Created consent id: '{}'", domesticScheduledConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(domesticScheduledConsent));
}
Also used : FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent) FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 2 with FRWriteDomesticScheduledConsent

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticScheduledPaymentConsentsApiController method createDomesticScheduledPaymentConsents.

@Override
public ResponseEntity<OBWriteDomesticScheduledConsentResponse1> createDomesticScheduledPaymentConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticScheduledConsent1 obWriteDomesticScheduledConsent1, @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, @ApiParam(value = "The PISP ID") @RequestHeader(value = "x-ob-client-id", required = false) String clientId, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received: '{}'", obWriteDomesticScheduledConsent1);
    FRWriteDomesticScheduledConsent frWriteScheduledConsent = toFRWriteDomesticScheduledConsent(obWriteDomesticScheduledConsent1);
    log.trace("Converted to: '{}'", frWriteScheduledConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRDomesticScheduledConsent> consentByIdempotencyKey = domesticScheduledConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteScheduledConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticScheduledConsent());
        log.info("Idempotent request is valid. Returning [201 CREATED] but take no further action.");
        return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(consentByIdempotencyKey.get()));
    }
    log.debug("No consent with matching idempotency key has been found. Creating new consent...");
    FRDomesticScheduledConsent domesticScheduledConsent = FRDomesticScheduledConsent.builder().id(IntentType.PAYMENT_DOMESTIC_SCHEDULED_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticScheduledConsent(frWriteScheduledConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).created(DateTime.now()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticScheduledConsent.getId(), domesticScheduledConsent.getStatus().name()));
    log.debug("Saving consent: '{}'", domesticScheduledConsent);
    domesticScheduledConsent = domesticScheduledConsentRepository.save(domesticScheduledConsent);
    log.info("Created consent id: '{}'", domesticScheduledConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(domesticScheduledConsent));
}
Also used : FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent) FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 3 with FRWriteDomesticScheduledConsent

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticScheduledPaymentConsentsApiController method createDomesticScheduledPaymentConsents.

public ResponseEntity<OBWriteDomesticScheduledConsentResponse3> createDomesticScheduledPaymentConsents(OBWriteDomesticScheduledConsent3 obWriteDomesticScheduledConsent3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String clientId, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received: '{}'", obWriteDomesticScheduledConsent3);
    FRWriteDomesticScheduledConsent frWriteDomesticScheduledConsent = toFRWriteDomesticScheduledConsent(obWriteDomesticScheduledConsent3);
    log.trace("Converted to: '{}'", frWriteDomesticScheduledConsent);
    Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRDomesticScheduledConsent> consentByIdempotencyKey = domesticScheduledConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteDomesticScheduledConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticScheduledConsent());
        log.info("Idempotent request is valid. Returning [201 CREATED] but take no further action.");
        return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(consentByIdempotencyKey.get()));
    }
    log.debug("No consent with matching idempotency key has been found. Creating new consent...");
    FRDomesticScheduledConsent domesticScheduledConsent = FRDomesticScheduledConsent.builder().id(IntentType.PAYMENT_DOMESTIC_SCHEDULED_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticScheduledConsent(frWriteDomesticScheduledConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", domesticScheduledConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticScheduledConsent.getId(), domesticScheduledConsent.getStatus().name()));
    domesticScheduledConsent = domesticScheduledConsentRepository.save(domesticScheduledConsent);
    log.info("Created consent id: '{}'", domesticScheduledConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(domesticScheduledConsent));
}
Also used : FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent) FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 4 with FRWriteDomesticScheduledConsent

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticScheduledPaymentConsentsApiController method createDomesticScheduledPaymentConsents.

@Override
public ResponseEntity<OBWriteDomesticScheduledConsentResponse4> createDomesticScheduledPaymentConsents(OBWriteDomesticScheduledConsent4 obWriteDomesticScheduledConsent4, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String clientId, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received: '{}'", obWriteDomesticScheduledConsent4);
    FRWriteDomesticScheduledConsent frWriteDomesticScheduledConsent = toFRWriteDomesticScheduledConsent(obWriteDomesticScheduledConsent4);
    log.trace("Converted to: '{}'", frWriteDomesticScheduledConsent);
    Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRDomesticScheduledConsent> consentByIdempotencyKey = domesticScheduledConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteDomesticScheduledConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticScheduledConsent());
        log.info("Idempotent request is valid. Returning [201 CREATED] but take no further action.");
        return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(consentByIdempotencyKey.get()));
    }
    log.debug("No consent with matching idempotency key has been found. Creating new consent...");
    FRDomesticScheduledConsent domesticScheduledConsent = FRDomesticScheduledConsent.builder().id(IntentType.PAYMENT_DOMESTIC_SCHEDULED_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticScheduledConsent(frWriteDomesticScheduledConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", domesticScheduledConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticScheduledConsent.getId(), domesticScheduledConsent.getStatus().name()));
    domesticScheduledConsent = domesticScheduledConsentRepository.save(domesticScheduledConsent);
    log.info("Created consent id: '{}'", domesticScheduledConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(domesticScheduledConsent));
}
Also used : FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent) FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 5 with FRWriteDomesticScheduledConsent

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticScheduledPaymentConsentsApiController method createDomesticScheduledPaymentConsents.

public ResponseEntity<OBWriteDomesticScheduledConsentResponse5> createDomesticScheduledPaymentConsents(OBWriteDomesticScheduledConsent4 obWriteDomesticScheduledConsent4, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String clientId, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received: '{}'", obWriteDomesticScheduledConsent4);
    FRWriteDomesticScheduledConsent frWriteDomesticScheduledConsent = toFRWriteDomesticScheduledConsent(obWriteDomesticScheduledConsent4);
    log.trace("Converted to: '{}'", frWriteDomesticScheduledConsent);
    Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRDomesticScheduledConsent> consentByIdempotencyKey = domesticScheduledConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteDomesticScheduledConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticScheduledConsent());
        log.info("Idempotent request is valid. Returning [201 CREATED] but take no further action.");
        return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(consentByIdempotencyKey.get()));
    }
    log.debug("No consent with matching idempotency key has been found. Creating new consent...");
    FRDomesticScheduledConsent domesticScheduledConsent = FRDomesticScheduledConsent.builder().id(IntentType.PAYMENT_DOMESTIC_SCHEDULED_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticScheduledConsent(frWriteDomesticScheduledConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", domesticScheduledConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticScheduledConsent.getId(), domesticScheduledConsent.getStatus().name()));
    domesticScheduledConsent = domesticScheduledConsentRepository.save(domesticScheduledConsent);
    log.info("Created consent id: '{}'", domesticScheduledConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(domesticScheduledConsent));
}
Also used : FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent) FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Aggregations

ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)5 FRWriteDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent)5 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)5 FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent)5 Tpp (com.forgerock.openbanking.model.Tpp)5