Search in sources :

Example 1 with FRWriteInternationalConsent

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

the class InternationalPaymentConsentsApiController method createInternationalPaymentConsents.

public ResponseEntity<OBWriteInternationalConsentResponse6> createInternationalPaymentConsents(OBWriteInternationalConsent5 obWriteInternationalConsent5, 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: '{}'", obWriteInternationalConsent5);
    FRWriteInternationalConsent frWriteInternationalConsent = toFRWriteInternationalConsent(obWriteInternationalConsent5);
    log.trace("Converted to: '{}'", frWriteInternationalConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRInternationalConsent> consentByIdempotencyKey = internationalConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteInternationalConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getInternationalConsent());
        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.");
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    FRInternationalConsent internationalConsent = FRInternationalConsent.builder().id(IntentType.PAYMENT_INTERNATIONAL_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).internationalConsent(frWriteInternationalConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", internationalConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(internationalConsent.getId(), internationalConsent.getStatus().name()));
    internationalConsent = internationalConsentRepository.save(internationalConsent);
    log.info("Created consent id: '{}'", internationalConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(internationalConsent));
}
Also used : FRWriteInternationalConsentConverter.toFRWriteInternationalConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent) FRWriteInternationalConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 2 with FRWriteInternationalConsent

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

the class InternationalPaymentConsentsApiController method createInternationalPaymentConsents.

@Override
public ResponseEntity<OBWriteInternationalConsentResponse2> createInternationalPaymentConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalConsent2 obWriteInternationalConsent2, @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: '{}'", obWriteInternationalConsent2);
    FRWriteInternationalConsent frConsent = toFRWriteInternationalConsent(obWriteInternationalConsent2);
    log.trace("Converted to: '{}'", frConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRInternationalConsent> consentByIdempotencyKey = internationalConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getInternationalConsent());
        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.");
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    FRInternationalConsent internationalConsent = FRInternationalConsent.builder().id(IntentType.PAYMENT_INTERNATIONAL_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).internationalConsent(frConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", internationalConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(internationalConsent.getId(), internationalConsent.getStatus().name()));
    internationalConsent = internationalConsentRepository.save(internationalConsent);
    log.info("Created consent id: '{}'", internationalConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(internationalConsent));
}
Also used : FRWriteInternationalConsentConverter.toFRWriteInternationalConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent) FRWriteInternationalConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 3 with FRWriteInternationalConsent

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

the class InternationalPaymentConsentsApiController method createInternationalPaymentConsents.

@Override
public ResponseEntity<OBWriteInternationalConsentResponse1> createInternationalPaymentConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalConsent1 obWriteInternationalConsent1, @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: '{}'", obWriteInternationalConsent1);
    FRWriteInternationalConsent frInternationalConsent = toFRWriteInternationalConsent(obWriteInternationalConsent1);
    log.trace("Converted to: '{}'", frInternationalConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRInternationalConsent> consentByIdempotencyKey = internationalConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frInternationalConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getInternationalConsent());
        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.");
    FRInternationalConsent internationalConsent = FRInternationalConsent.builder().id(IntentType.PAYMENT_INTERNATIONAL_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).internationalConsent(frInternationalConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).created(DateTime.now()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", internationalConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(internationalConsent.getId(), internationalConsent.getStatus().name()));
    internationalConsent = internationalConsentRepository.save(internationalConsent);
    log.info("Created consent id: '{}'", internationalConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(internationalConsent));
}
Also used : FRWriteInternationalConsentConverter.toFRWriteInternationalConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent) FRWriteInternationalConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 4 with FRWriteInternationalConsent

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

the class InternationalPaymentConsentsApiController method createInternationalPaymentConsents.

@Override
public ResponseEntity<OBWriteInternationalConsentResponse5> createInternationalPaymentConsents(OBWriteInternationalConsent5 obWriteInternationalConsent5, 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: '{}'", obWriteInternationalConsent5);
    FRWriteInternationalConsent frWriteInternationalConsent = toFRWriteInternationalConsent(obWriteInternationalConsent5);
    log.trace("Converted to: '{}'", frWriteInternationalConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRInternationalConsent> consentByIdempotencyKey = internationalConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteInternationalConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getInternationalConsent());
        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.");
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    FRInternationalConsent internationalConsent = FRInternationalConsent.builder().id(IntentType.PAYMENT_INTERNATIONAL_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).internationalConsent(frWriteInternationalConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", internationalConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(internationalConsent.getId(), internationalConsent.getStatus().name()));
    internationalConsent = internationalConsentRepository.save(internationalConsent);
    log.info("Created consent id: '{}'", internationalConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(internationalConsent));
}
Also used : FRWriteInternationalConsentConverter.toFRWriteInternationalConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent) FRWriteInternationalConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Example 5 with FRWriteInternationalConsent

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

the class InternationalPaymentConsentsApiController method createInternationalPaymentConsents.

public ResponseEntity<OBWriteInternationalConsentResponse4> createInternationalPaymentConsents(OBWriteInternationalConsent4 obWriteInternationalConsent4, 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: '{}'", obWriteInternationalConsent4);
    FRWriteInternationalConsent frWriteInternationalConsent = toFRWriteInternationalConsent(obWriteInternationalConsent4);
    log.trace("Converted to: '{}'", frWriteInternationalConsent);
    final Tpp tpp = tppRepository.findByClientId(clientId);
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    Optional<FRInternationalConsent> consentByIdempotencyKey = internationalConsentRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
    if (consentByIdempotencyKey.isPresent()) {
        validateIdempotencyRequest(xIdempotencyKey, frWriteInternationalConsent, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getInternationalConsent());
        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.");
    log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
    FRInternationalConsent internationalConsent = FRInternationalConsent.builder().id(IntentType.PAYMENT_INTERNATIONAL_CONSENT.generateIntentId()).status(ConsentStatusCode.AWAITINGAUTHORISATION).internationalConsent(frWriteInternationalConsent).pispId(tpp.getId()).pispName(tpp.getOfficialName()).statusUpdate(DateTime.now()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    log.debug("Saving consent: '{}'", internationalConsent);
    consentMetricService.sendConsentActivity(new ConsentStatusEntry(internationalConsent.getId(), internationalConsent.getStatus().name()));
    internationalConsent = internationalConsentRepository.save(internationalConsent);
    log.info("Created consent id: '{}'", internationalConsent.getId());
    return ResponseEntity.status(HttpStatus.CREATED).body(packageResponse(internationalConsent));
}
Also used : FRWriteInternationalConsentConverter.toFRWriteInternationalConsent(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent) FRWriteInternationalConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent) Tpp(com.forgerock.openbanking.model.Tpp) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) ConsentStatusEntry(com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)

Aggregations

ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)5 FRWriteInternationalConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalConsent)5 FRInternationalConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent)5 FRWriteInternationalConsentConverter.toFRWriteInternationalConsent (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConsentConverter.toFRWriteInternationalConsent)5 Tpp (com.forgerock.openbanking.model.Tpp)5