Search in sources :

Example 46 with ConsentStatusEntry

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));
}
Also used : Tpp(com.forgerock.openbanking.model.Tpp) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledConsent) FRWriteInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 47 with ConsentStatusEntry

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));
}
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 48 with ConsentStatusEntry

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));
}
Also used : FRWriteDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderConsent) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 49 with ConsentStatusEntry

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));
}
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 50 with ConsentStatusEntry

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));
}
Also used : FRWriteDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderConsent) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Aggregations

ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)54 Tpp (com.forgerock.openbanking.model.Tpp)39 ResponseEntity (org.springframework.http.ResponseEntity)10 FRWriteDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderConsent)6 FRWriteInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrderConsent)6 FRDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent)6 FRInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent)6 FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderConsent)6 FRWriteInternationalStandingOrderConsentConverter.toFRWriteInternationalStandingOrderConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalStandingOrderConsentConverter.toFRWriteInternationalStandingOrderConsent)6 FRWriteDomesticConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsent)5 FRWriteDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduledConsent)5 FRWriteInternationalConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent)5 FRWriteInternationalScheduledConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledConsent)5 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)5 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)5 FRInternationalConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent)5 FRInternationalScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)5 FRWriteDomesticConsentConverter.toFRWriteDomesticConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticConsentConverter.toFRWriteDomesticConsent)5 FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConsentConverter.toFRWriteDomesticScheduledConsent)5 FRWriteInternationalConsentConverter.toFRWriteInternationalConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent)5