Search in sources :

Example 6 with ManualRegistrationApplication

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;
}
Also used : OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) ManualRegistrationApplication(com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication)

Example 7 with ManualRegistrationApplication

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;
    }
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) URI(java.net.URI) ManualRegistrationApplication(com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication)

Example 8 with ManualRegistrationApplication

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;
    }
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) URI(java.net.URI) ManualRegistrationApplication(com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication)

Aggregations

ManualRegistrationApplication (com.forgerock.openbanking.common.model.onboarding.ManualRegistrationApplication)8 OAuth2InvalidClientException (com.forgerock.openbanking.common.error.exception.oauth2.OAuth2InvalidClientException)3 Tpp (com.forgerock.openbanking.model.Tpp)3 URI (java.net.URI)3 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)3 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)2 DynamicClientRegistrationException (com.forgerock.openbanking.common.error.exception.dynamicclientregistration.DynamicClientRegistrationException)1 ManualRegistrationRequest (com.forgerock.openbanking.common.model.onboarding.ManualRegistrationRequest)1 ApiClientException (com.forgerock.openbanking.common.services.onboarding.apiclient.ApiClientException)1 ApiClientIdentity (com.forgerock.openbanking.common.services.onboarding.apiclient.ApiClientIdentity)1 RegistrationRequest (com.forgerock.openbanking.common.services.onboarding.registrationrequest.RegistrationRequest)1 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)1 OIDCRegistrationResponse (com.forgerock.openbanking.model.oidc.OIDCRegistrationResponse)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 Resources (org.springframework.hateoas.Resources)1