use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException 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();
}
use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException 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();
}
use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException 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();
}
use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException in project identity-inbound-auth-oauth by wso2-extensions.
the class RegisterApiServiceImplTest method testUpdateApplicationServerException.
@Test
public void testUpdateApplicationServerException() throws Exception {
UpdateRequestDTO updateRequestDTO = new UpdateRequestDTO();
doThrow(new DCRMServerException("Server")).when(dcrmService).updateApplication(any(ApplicationUpdateRequest.class), any(String.class));
try {
registerApiService.updateApplication(updateRequestDTO, validclientId);
} catch (DCRMEndpointException e) {
Assert.assertEquals(e.getResponse().getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
use of org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException 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));
}
}
Aggregations