From 68cefe21a5c2244e84ce6e8a7edbd27a534f4387 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 28 May 2015 15:20:00 +0530 Subject: [PATCH] Fixing issues encountered in dynamic client authentication implementation --- .../oauth/extension/RegistrationProfile.java | 11 +++++++++-- .../oauth/extension/RegistrationService.java | 1 - .../impl/ClientRegistrationServiceImpl.java | 16 ++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationProfile.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationProfile.java index eb2b653ed6..fad85d0f79 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationProfile.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationProfile.java @@ -18,8 +18,6 @@ */ package org.wso2.carbon.identity.oauth.extension; -import javax.ws.rs.core.Request; - public class RegistrationProfile { private String applicationType; @@ -34,6 +32,7 @@ public class RegistrationProfile { private String userInfoEncryptedResponseEnc; private String[] contacts; private String[] requestUris; + private String owner; public String getApplicationType() { return applicationType; @@ -131,4 +130,12 @@ public class RegistrationProfile { this.requestUris = requestUris; } + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + } diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java index 9f2a0edd71..88028bbd0f 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java @@ -30,7 +30,6 @@ import javax.ws.rs.core.Response; public interface RegistrationService { @POST - @Path("/register") Response register(RegistrationProfile profile); } \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ClientRegistrationServiceImpl.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ClientRegistrationServiceImpl.java index 5b180823c8..5fdd77cf91 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ClientRegistrationServiceImpl.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ClientRegistrationServiceImpl.java @@ -20,12 +20,11 @@ package org.wso2.carbon.identity.oauth.extension.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.json.simple.JSONArray; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.impl.utils.APIUtil; -import org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; @@ -37,7 +36,10 @@ 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.*; +import org.wso2.carbon.identity.oauth.extension.ApplicationConstants; +import org.wso2.carbon.identity.oauth.extension.OAuthApplicationInfo; +import org.wso2.carbon.identity.oauth.extension.RegistrationProfile; +import org.wso2.carbon.identity.oauth.extension.RegistrationService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @@ -68,19 +70,17 @@ public class ClientRegistrationServiceImpl implements RegistrationService { private OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException { - //OAuthApplications are created by calling to APIKeyMgtSubscriber Service - SubscriberKeyMgtClient keyMgtClient = APIUtil.getKeyManagementClient(); OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); //Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. - String userId = (String) oAuthApplicationInfo.getParameter(ApplicationConstants.OAUTH_CLIENT_USERNAME); + String userId = profile.getOwner(); String applicationName = profile.getClientName(); if (log.isDebugEnabled()) { - log.debug("Trying to create OAuth application :" + applicationName); + log.debug("Trying to create OAuth application: '" + applicationName + "'"); } - String callBackURL = ""; + String callBackURL = null; if (oAuthApplicationInfo.getParameter("callback_url") != null) { JSONArray jsonArray = (JSONArray) oAuthApplicationInfo.getParameter("callback_url"); for (Object callbackUrlObject : jsonArray) {