use of com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication in project openbanking-aspsp by OpenBankingToolkit.
the class ManualRegistrationApiController method getManualApplicationIfOwnedBySessionOwner.
private ManualRegistrationApplication getManualApplicationIfOwnedBySessionOwner(String applicationId, String usernameOfSessionHolder) throws OBErrorResponseException {
Optional<ManualRegistrationApplication> isApplication = manualRegistrationApplicationService.findById(applicationId);
if (isApplication.isEmpty()) {
throw new OBErrorResponseException(OBRIErrorType.MANUAL_ONBOARDING_APPLICATION_NOT_FOUND.getHttpStatus(), OBRIErrorResponseCategory.MANUAL_ONBOARDING, OBRIErrorType.MANUAL_ONBOARDING_APPLICATION_NOT_FOUND.toOBError1(applicationId));
}
ManualRegistrationApplication application = isApplication.get();
if (!sessionHolderOwnsManualRegistration(usernameOfSessionHolder, application)) {
throw new OBErrorResponseException(OBRIErrorType.MANUAL_ONBOARDING_WRONG_USER.getHttpStatus(), OBRIErrorResponseCategory.MANUAL_ONBOARDING, OBRIErrorType.MANUAL_ONBOARDING_WRONG_USER.toOBError1(applicationId));
}
return application;
}
use of com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication in project openbanking-aspsp by OpenBankingToolkit.
the class ManualRegistrationApplicationService method findBySoftwareClientId.
public Optional<ManualRegistrationApplication> findBySoftwareClientId(String softwareClientId) {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/manualRegistrationApplications/search/findBySoftwareClientId");
builder.queryParam("softwareClientId", softwareClientId);
URI uri = builder.build().encode().toUri();
log.debug("Find softwareClientId {}", softwareClientId);
try {
ResponseEntity<ManualRegistrationApplication> entity = restTemplate.exchange(uri, HttpMethod.GET, null, ManualRegistrationApplication.class);
return Optional.of(entity.getBody());
} catch (HttpClientErrorException e) {
if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
}
throw e;
}
}
use of com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication in project openbanking-aspsp by OpenBankingToolkit.
the class ManualRegistrationApplicationService method findById.
public Optional<ManualRegistrationApplication> findById(String id) {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/manualRegistrationApplications/" + id);
URI uri = builder.build().encode().toUri();
log.debug("Find id {}", id);
try {
ResponseEntity<ManualRegistrationApplication> entity = restTemplate.exchange(uri, HttpMethod.GET, null, ManualRegistrationApplication.class);
return Optional.of(entity.getBody());
} catch (HttpClientErrorException e) {
if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
}
throw e;
}
}
Aggregations