From eeca0d4dedf45327f7f2720c26d7326b319f8062 Mon Sep 17 00:00:00 2001 From: milanperera Date: Tue, 14 Jul 2015 14:55:18 +0530 Subject: [PATCH] Refactored DCA --- .../DynamicClientRegistrationUtil.java | 44 ------------------- .../impl/RegistrationServiceImpl.java | 14 ------ 2 files changed, 58 deletions(-) diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java index 9e9fe4db40..4a64d6368d 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java @@ -35,22 +35,9 @@ import org.wso2.carbon.identity.application.mgt.ApplicationManagementService; import org.wso2.carbon.identity.base.IdentityException; import org.wso2.carbon.identity.oauth.OAuthAdminService; import org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.identity.oauth.extension.ApplicationConstants; -import org.wso2.carbon.identity.oauth.extension.OAuthApplicationInfo; -import org.wso2.carbon.identity.oauth.extension.RegistrationService; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - import org.wso2.carbon.identity.oauth.extension.profile.RegistrationProfile; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.util.Arrays; @@ -58,37 +45,6 @@ public class DynamicClientRegistrationUtil { private static final Log log = LogFactory.getLog(DynamicClientRegistrationUtil.class); - - public Response register(RegistrationProfile profile) { - try { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID); - - OAuthApplicationInfo info = this.registerApplication(profile); - return Response.status(Response.Status.ACCEPTED).entity(info.toString()).build(); - } catch (APIManagementException e) { - String msg = "Error occurred while registering client '" + profile.getClientName() + "'"; - log.error(msg, e); - return Response.serverError().entity(msg).build(); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - - public Response unregister(String applicationName, String userId, String consumerKey) { - try { - this.unregisterApplication(userId, applicationName, consumerKey); - return Response.status(Response.Status.ACCEPTED).build(); - } catch (APIManagementException e) { - String msg = "Error occurred while unregistering client '" + applicationName + "'"; - log.error(msg, e); - return Response.serverError().entity(msg).build(); - } - } - - public static OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException { OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java index 0a9078b037..2fdb539988 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java @@ -20,28 +20,14 @@ package org.wso2.carbon.identity.oauth.extension.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.impl.utils.APIUtil; -import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; -import org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig; -import org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig; -import org.wso2.carbon.identity.application.common.model.Property; -import org.wso2.carbon.identity.application.common.model.ServiceProvider; -import org.wso2.carbon.identity.application.mgt.ApplicationManagementService; -import org.wso2.carbon.identity.base.IdentityException; -import org.wso2.carbon.identity.oauth.OAuthAdminService; -import org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO; import org.wso2.carbon.identity.oauth.extension.DynamicClientRegistrationUtil; import org.wso2.carbon.identity.oauth.extension.FaultResponse; import org.wso2.carbon.identity.oauth.extension.OAuthApplicationInfo; import org.wso2.carbon.identity.oauth.extension.RegistrationService; import org.wso2.carbon.identity.oauth.extension.profile.RegistrationProfile; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE;