Search in sources :

Example 1 with DCRMClientException

use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class RegisterApiServiceImpl method updateApplication.

@Override
public Response updateApplication(UpdateRequestDTO updateRequest, String clientId) {
    ApplicationDTO applicationDTO = null;
    try {
        Application application = DCRMUtils.getOAuth2DCRMService().updateApplication(DCRMUtils.getApplicationUpdateRequest(updateRequest), clientId);
        applicationDTO = DCRMUtils.getApplicationDTOFromApplication(application);
    } catch (DCRMClientException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client error while updating application \n" + updateRequest.toString(), e);
        }
        DCRMUtils.handleErrorResponse(e, LOG);
    } catch (DCRMServerException e) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, e, true, LOG);
    } catch (Throwable throwable) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, throwable, true, LOG);
    }
    return Response.status(Response.Status.OK).entity(applicationDTO).build();
}
Also used : ApplicationDTO(org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.ApplicationDTO) DCRMClientException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException) DCRMServerException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException) Application(org.wso2.carbon.identity.oauth.dcr.bean.Application)

Example 2 with DCRMClientException

use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class RegisterApiServiceImpl method registerApplication.

@Override
public Response registerApplication(RegistrationRequestDTO registrationRequest) {
    ApplicationDTO applicationDTO = null;
    try {
        Application application = DCRMUtils.getOAuth2DCRMService().registerApplication(DCRMUtils.getApplicationRegistrationRequest(registrationRequest));
        applicationDTO = DCRMUtils.getApplicationDTOFromApplication(application);
    } catch (DCRMClientException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client error while registering application \n" + registrationRequest.toString(), e);
        }
        DCRMUtils.handleErrorResponse(e, LOG);
    } catch (DCRMServerException e) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, e, true, LOG);
    } catch (Throwable throwable) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, throwable, true, LOG);
    }
    return Response.status(Response.Status.CREATED).entity(applicationDTO).build();
}
Also used : ApplicationDTO(org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.ApplicationDTO) DCRMClientException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException) DCRMServerException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException) Application(org.wso2.carbon.identity.oauth.dcr.bean.Application)

Example 3 with DCRMClientException

use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class RegisterApiServiceImpl method getApplicationByName.

@Override
public Response getApplicationByName(String name) {
    ApplicationDTO applicationDTO = null;
    try {
        Application application = DCRMUtils.getOAuth2DCRMService().getApplicationByName(name);
        applicationDTO = DCRMUtils.getApplicationDTOFromApplication(application);
    } catch (DCRMClientException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client error while retrieving application by name : " + name, e);
        }
        DCRMUtils.handleErrorResponse(e, LOG);
    } catch (Exception e) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, e, true, LOG);
    }
    return Response.status(Response.Status.OK).entity(applicationDTO).build();
}
Also used : ApplicationDTO(org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.ApplicationDTO) DCRMClientException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException) Application(org.wso2.carbon.identity.oauth.dcr.bean.Application) DCRMClientException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException) DCRMServerException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException)

Example 4 with DCRMClientException

use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class RegisterApiServiceImpl method getApplication.

@Override
public Response getApplication(String clientId) {
    ApplicationDTO applicationDTO = null;
    try {
        Application application = DCRMUtils.getOAuth2DCRMService().getApplication(clientId);
        applicationDTO = DCRMUtils.getApplicationDTOFromApplication(application);
    } catch (DCRMClientException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client error while retrieving  application with client key:" + clientId, e);
        }
        DCRMUtils.handleErrorResponse(e, LOG);
    } catch (DCRMServerException e) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, e, true, LOG);
    } catch (Throwable throwable) {
        DCRMUtils.handleErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, throwable, true, LOG);
    }
    return Response.status(Response.Status.OK).entity(applicationDTO).build();
}
Also used : ApplicationDTO(org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.ApplicationDTO) DCRMClientException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException) DCRMServerException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException) Application(org.wso2.carbon.identity.oauth.dcr.bean.Application)

Example 5 with DCRMClientException

use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class DCRMService method validateRequestTenantDomain.

/**
 * Validates whether the tenant domain in the request matches with the application tenant domain.
 *
 * @param clientId Consumer key of application.
 * @throws DCRMException DCRMException
 */
private void validateRequestTenantDomain(String clientId) throws DCRMException {
    try {
        String tenantDomainOfApp = OAuth2Util.getTenantDomainOfOauthApp(clientId);
        OAuth2Util.validateRequestTenantDomain(tenantDomainOfApp);
    } catch (InvalidOAuthClientException e) {
        throw new DCRMClientException(DCRMConstants.ErrorMessages.TENANT_DOMAIN_MISMATCH.getErrorCode(), String.format(DCRMConstants.ErrorMessages.TENANT_DOMAIN_MISMATCH.getMessage(), clientId));
    } catch (IdentityOAuth2Exception e) {
        throw new DCRMServerException(String.format(DCRMConstants.ErrorMessages.FAILED_TO_VALIDATE_TENANT_DOMAIN.getMessage(), clientId));
    }
}
Also used : DCRMClientException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException) IdentityOAuth2Exception(org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception) DCRMServerException(org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException) InvalidOAuthClientException(org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)

Aggregations

DCRMClientException (org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException)5 DCRMServerException (org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException)5 Application (org.wso2.carbon.identity.oauth.dcr.bean.Application)4 ApplicationDTO (org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.ApplicationDTO)4 InvalidOAuthClientException (org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)1 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)1