use of com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalScheduledPaymentConsentsApiController method createInternationalScheduledPaymentConsents.
@Override
public ResponseEntity<OBWriteInternationalScheduledConsentResponse5> createInternationalScheduledPaymentConsents(OBWriteInternationalScheduledConsent5 obWriteInternationalScheduledConsent5, 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: '{}'", obWriteInternationalScheduledConsent5);
FRWriteInternationalScheduledConsent frScheduledConsent = toFRWriteInternationalScheduledConsent(obWriteInternationalScheduledConsent5);
log.trace("Converted to: '{}'", frScheduledConsent);
Tpp tpp = tppRepository.findByClientId(clientId);
log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
Optional<FRInternationalScheduledConsent> consentByIdempotencyKey = internationalScheduledConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
if (consentByIdempotencyKey.isPresent()) {
validateIdempotencyRequest(xIdempotencyKey, frScheduledConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getInternationalScheduledConsent());
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.");
FRInternationalScheduledConsent internationalScheduledConsent = FRInternationalScheduledConsent.builder().id(IntentType.PAYMENT_INTERNATIONAL_SCHEDULED_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).internationalScheduledConsent(frScheduledConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
log.debug("Saving consent: '{}'", internationalScheduledConsent);
consentMetricService.sendConsentActivity(new ConsentStatusEntry(internationalScheduledConsent.getId(), internationalScheduledConsent.getStatus().name()));
internationalScheduledConsent = internationalScheduledConsentRepository.save(internationalScheduledConsent);
log.info("Created consent id: '{}'", internationalScheduledConsent.getId());
return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(internationalScheduledConsent));
}
use of com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry 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));
}
use of com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrderConsentsApiController method createDomesticStandingOrderConsents.
@Override
public ResponseEntity<OBWriteDomesticStandingOrderConsentResponse5> createDomesticStandingOrderConsents(OBWriteDomesticStandingOrderConsent5 obWriteDomesticStandingOrderConsent5, 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: '{}'", obWriteDomesticStandingOrderConsent5);
FRWriteDomesticStandingOrderConsent frStandingOrderConsent = toFRWriteDomesticStandingOrderConsent(obWriteDomesticStandingOrderConsent5);
log.trace("Converted to: '{}'", frStandingOrderConsent);
Tpp tpp = tppRepository.findByClientId(clientId);
log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
Optional<FRDomesticStandingOrderConsent> consentByIdempotencyKey = domesticStandingOrderConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
if (consentByIdempotencyKey.isPresent()) {
validateIdempotencyRequest(xIdempotencyKey, frStandingOrderConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticStandingOrderConsent());
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...");
FRDomesticStandingOrderConsent domesticStandingOrderConsent = FRDomesticStandingOrderConsent.builder().id(IntentType.PAYMENT_DOMESTIC_STANDING_ORDERS_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticStandingOrderConsent(frStandingOrderConsent).statusUpdate(DateTime.now()).pispId(tpp.getId()).pispName(tpp.getOfficialName()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
log.debug("Saving consent: '{}'", domesticStandingOrderConsent);
consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticStandingOrderConsent.getId(), domesticStandingOrderConsent.getStatus().name()));
domesticStandingOrderConsent = domesticStandingOrderConsentRepository.save(domesticStandingOrderConsent);
log.info("Created consent id: '{}'", domesticStandingOrderConsent.getId());
return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(domesticStandingOrderConsent));
}
use of com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry 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));
}
use of com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrderConsentsApiController method createDomesticStandingOrderConsents.
public ResponseEntity<OBWriteDomesticStandingOrderConsentResponse6> createDomesticStandingOrderConsents(OBWriteDomesticStandingOrderConsent5 obWriteDomesticStandingOrderConsent5, 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: '{}'", obWriteDomesticStandingOrderConsent5);
FRWriteDomesticStandingOrderConsent frStandingOrderConsent = toFRWriteDomesticStandingOrderConsent(obWriteDomesticStandingOrderConsent5);
log.trace("Converted to: '{}'", frStandingOrderConsent);
Tpp tpp = tppRepository.findByClientId(clientId);
log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
Optional<FRDomesticStandingOrderConsent> consentByIdempotencyKey = domesticStandingOrderConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
if (consentByIdempotencyKey.isPresent()) {
validateIdempotencyRequest(xIdempotencyKey, frStandingOrderConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getDomesticStandingOrderConsent());
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...");
FRDomesticStandingOrderConsent domesticStandingOrderConsent = FRDomesticStandingOrderConsent.builder().id(IntentType.PAYMENT_DOMESTIC_STANDING_ORDERS_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticStandingOrderConsent(frStandingOrderConsent).statusUpdate(DateTime.now()).pispId(tpp.getId()).pispName(tpp.getOfficialName()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
log.debug("Saving consent: '{}'", domesticStandingOrderConsent);
consentMetricService.sendConsentActivity(new ConsentStatusEntry(domesticStandingOrderConsent.getId(), domesticStandingOrderConsent.getStatus().name()));
domesticStandingOrderConsent = domesticStandingOrderConsentRepository.save(domesticStandingOrderConsent);
log.info("Created consent id: '{}'", domesticStandingOrderConsent.getId());
return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(domesticStandingOrderConsent));
}
Aggregations