@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<SCAPaymentResponseTO> getSCA(String paymentId, String authorisationId) { try { return ResponseEntity.ok(paymentService.loadSCAForPaymentData(paymentId, authorisationId)); } catch (PaymentNotFoundMiddlewareException | SCAOperationExpiredMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<SCAPaymentResponseTO> getCancelSCA(String paymentId, String cancellationId) throws ConflictRestException{ try { return ResponseEntity.ok(paymentService.loadSCAForCancelPaymentData(paymentId, cancellationId)); } catch (PaymentNotFoundMiddlewareException | SCAOperationExpiredMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override public ResponseEntity<SCAConsentResponseTO> getSCA(String consentId, String authorisationId) throws ConflictRestException { try { return ResponseEntity.ok(middlewareAccountService.loadSCAForAisConsent(consentId, authorisationId)); } catch (SCAOperationExpiredMiddlewareException | AisConsentNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override @PreAuthorize("accountInfoById(#accountId)") public ResponseEntity<TransactionTO> getTransactionById(String accountId, String transactionId) { try { return ResponseEntity.ok(middlewareAccountService.getTransactionById(accountId, transactionId)); } catch (AccountNotFoundMiddlewareException | TransactionNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()).withDevMessage(e.getMessage()); } catch (InsufficientPermissionMiddlewareException e) { throw forbiddenRestException(e); } }
@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<TransactionStatusTO> getPaymentStatusById(String paymentId) { try { return ResponseEntity.ok(paymentService.getPaymentStatusById(paymentId)); } catch (PaymentNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override @PreAuthorize("hasAnyRole('STAFF','SYSTEM')") public ResponseEntity<UserTO> getUserById(String userId) { try { return ResponseEntity.ok(middlewareUserService.findById(userId)); } catch (UserNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override @PreAuthorize("tokenUsage('DIRECT_ACCESS')") public ResponseEntity<UserTO> getUser() { try { return ResponseEntity.ok(middlewareUserService.findById(accessToken.getSub())); } catch (UserNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<?> getPaymentById(String paymentId) { try { return ResponseEntity.ok(paymentService.getPaymentById(paymentId)); } catch (PaymentNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()).withDevMessage(e.getMessage()); } }
@Override @PreAuthorize("paymentInitById(#paymentId)") public ResponseEntity<SCAPaymentResponseTO> initiatePmtCancellation(String paymentId) { try { return ResponseEntity.ok(paymentService.initiatePaymentCancellation(paymentId)); } catch (PaymentNotFoundMiddlewareException e) { throw new NotFoundRestException(e.getMessage()); } catch (PaymentProcessingMiddlewareException e) { return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).build(); } }
@Override public ResponseEntity<SCAConsentResponseTO> selectMethod(String consentId, String authorisationId, String scaMethodId) throws ValidationRestException, ConflictRestException, NotFoundRestException { try { return ResponseEntity.ok(middlewareAccountService.selectSCAMethodForAisConsent(consentId, authorisationId, scaMethodId)); } catch (PaymentNotFoundMiddlewareException | UserScaDataNotFoundMiddlewareException | SCAOperationNotFoundMiddlewareException | AisConsentNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } catch (SCAOperationValidationMiddlewareException e) { logger.error(e.getMessage(), e); throw new ValidationRestException(e.getMessage()); } catch (SCAMethodNotSupportedMiddleException e) { logger.error(e.getMessage(), e); throw new NotAcceptableRestException(e.getMessage()); } }
@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<SCAPaymentResponseTO> selecCancelPaymentSCAtMethod(String paymentId, String cancellationId, String scaMethodId) throws ValidationRestException, ConflictRestException, NotFoundRestException { try { return ResponseEntity.ok(paymentService.selectSCAMethodForCancelPayment(paymentId, cancellationId, scaMethodId)); } catch (PaymentNotFoundMiddlewareException | UserScaDataNotFoundMiddlewareException | SCAOperationNotFoundMiddlewareException e) { throw new NotFoundRestException(e.getMessage()); } catch (SCAMethodNotSupportedMiddleException e) { throw new NotAcceptableRestException(e.getMessage()); } catch (SCAOperationValidationMiddlewareException e) { throw new ValidationRestException(e.getMessage()); } }
@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<SCAPaymentResponseTO> authorizeCancelPayment(String paymentId,String cancellationId, String authCode) throws GoneRestException,NotFoundRestException, ConflictRestException, ExpectationFailedRestException, NotAcceptableRestException { try { return ResponseEntity.ok(paymentService.authorizeCancelPayment(paymentId, cancellationId, authCode)); } catch (SCAOperationNotFoundMiddlewareException | PaymentNotFoundMiddlewareException | SCAOperationExpiredMiddlewareException e) { throw new NotFoundRestException(e.getMessage()); } catch (SCAOperationValidationMiddlewareException e) { throw new ValidationRestException(e.getMessage()); } catch (SCAOperationUsedOrStolenMiddlewareException e) { throw new NotAcceptableRestException(e.getMessage()); } } }
private RestException notFoundRestException(AccountNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); return new NotFoundRestException(e.getMessage()).withDevMessage(e.getMessage()); }
@Override public ResponseEntity<SCAConsentResponseTO> authorizeConsent(String consentId, String authorisationId, String authCode) throws ValidationRestException, NotFoundRestException, GoneRestException { try { return ResponseEntity.ok(middlewareAccountService.authorizeConsent(consentId, authorisationId, authCode)); } catch (SCAOperationNotFoundMiddlewareException | AisConsentNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } catch (SCAOperationValidationMiddlewareException e) { logger.error(e.getMessage(), e); throw new ValidationRestException(e.getMessage()); } catch (SCAOperationUsedOrStolenMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotAcceptableRestException(e.getMessage()); } catch (SCAOperationExpiredMiddlewareException e) { logger.error(e.getMessage()); throw new GoneRestException(e.getMessage()); } }
@Override @PreAuthorize("paymentInit(#payment)") public ResponseEntity<SCAPaymentResponseTO> initiatePayment(PaymentTypeTO paymentType, Object payment) throws NotFoundRestException, ForbiddenRestException, ConflictRestException{ try { return new ResponseEntity<>(paymentService.initiatePayment(payment, paymentType), HttpStatus.CREATED); } catch (AccountNotFoundMiddlewareException e) { throw new NotFoundRestException(e.getMessage()); } catch (NoAccessMiddlewareException e) { throw new ForbiddenRestException(e.getMessage()); } catch (PaymentWithIdMiddlewareException e) { throw new ConflictRestException(e.getMessage()); } }
@Override @PreAuthorize("paymentInfoById(#paymentId)") public ResponseEntity<SCAPaymentResponseTO> authorizePayment(String paymentId, String authorisationId, String authCode) throws GoneRestException,NotFoundRestException, ConflictRestException, ExpectationFailedRestException, NotAcceptableRestException { try { return ResponseEntity.ok(paymentService.authorizePayment(paymentId, authorisationId, authCode)); } catch (SCAOperationNotFoundMiddlewareException | PaymentNotFoundMiddlewareException e) { throw new NotFoundRestException(e.getMessage()); } catch (SCAOperationValidationMiddlewareException e) { throw new ValidationRestException(e.getMessage()); } catch (SCAOperationExpiredMiddlewareException e) { throw new GoneRestException(e.getMessage()); } catch (SCAOperationUsedOrStolenMiddlewareException e) { throw new NotAcceptableRestException(e.getMessage()); } }
@Override @PreAuthorize("tokenUsage('DIRECT_ACCESS')") public ResponseEntity<Void> updateUserScaData(List<ScaUserDataTO> data) { try { UserTO userTO = middlewareUserService.findById(accessToken.getSub()); UserTO user = middlewareUserService.updateScaData(userTO.getLogin(), data); URI uri = UriComponentsBuilder.fromUriString(BASE_PATH + "/" + user.getId()) .build().toUri(); return ResponseEntity.created(uri).build(); } catch (UserNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()); } }
@Override @PreAuthorize("tokenUsage('DIRECT_ACCESS') and accountInfoFor(#pisConsent)") public ResponseEntity<SCAConsentResponseTO> grantPIISConsent(AisConsentTO pisConsent) { try { return ResponseEntity.ok(middlewareAccountService.grantAisConsent(pisConsent)); } catch (InsufficientPermissionMiddlewareException e) { logger.error(e.getMessage(), e); throw new ForbiddenRestException(e.getMessage()).withDevMessage(e.getMessage()); } catch (AccountNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()).withDevMessage(e.getMessage()); } } }
@Override public ResponseEntity<SCALoginResponseTO> authoriseForConsent(String login, String pin, String consentId, String authorisationId, OpTypeTO opType) { try { return ResponseEntity.ok(onlineBankingService.authoriseForConsent(login, pin, consentId, authorisationId, opType)); } catch (UserNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()).withDevMessage(e.getMessage()); } catch (InsufficientPermissionMiddlewareException e) { logger.error(e.getMessage(), e); throw new ForbiddenRestException(e.getMessage()).withDevMessage(e.getMessage()); } }
/** * Authorize returns a bearer token that can be reused by the consuming application. * * @param login * @param pin * @return */ @Override public ResponseEntity<SCALoginResponseTO> authorise(String login, String pin, UserRoleTO role) { try { return ResponseEntity.ok(onlineBankingService.authorise(login, pin, role)); } catch (UserNotFoundMiddlewareException e) { logger.error(e.getMessage(), e); throw new NotFoundRestException(e.getMessage()).withDevMessage(e.getMessage()); } catch (InsufficientPermissionMiddlewareException e) { logger.error(e.getMessage(), e); throw new ForbiddenRestException(e.getMessage()).withDevMessage(e.getMessage()); } }