Fixing issues encountered in dynamic client authentication implementation

revert-70aa11f8
prabathabey 10 years ago
parent e21c92a1ce
commit 68cefe21a5

@ -18,8 +18,6 @@
*/ */
package org.wso2.carbon.identity.oauth.extension; package org.wso2.carbon.identity.oauth.extension;
import javax.ws.rs.core.Request;
public class RegistrationProfile { public class RegistrationProfile {
private String applicationType; private String applicationType;
@ -34,6 +32,7 @@ public class RegistrationProfile {
private String userInfoEncryptedResponseEnc; private String userInfoEncryptedResponseEnc;
private String[] contacts; private String[] contacts;
private String[] requestUris; private String[] requestUris;
private String owner;
public String getApplicationType() { public String getApplicationType() {
return applicationType; return applicationType;
@ -131,4 +130,12 @@ public class RegistrationProfile {
this.requestUris = requestUris; this.requestUris = requestUris;
} }
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
} }

@ -30,7 +30,6 @@ import javax.ws.rs.core.Response;
public interface RegistrationService { public interface RegistrationService {
@POST @POST
@Path("/register")
Response register(RegistrationProfile profile); Response register(RegistrationProfile profile);
} }

@ -20,12 +20,11 @@ package org.wso2.carbon.identity.oauth.extension.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.simple.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.simple.JSONArray;
import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.impl.utils.APIUtil; 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.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; 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.base.IdentityException;
import org.wso2.carbon.identity.oauth.OAuthAdminService; import org.wso2.carbon.identity.oauth.OAuthAdminService;
import org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO; 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.MultitenantConstants;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
@ -68,19 +70,17 @@ public class ClientRegistrationServiceImpl implements RegistrationService {
private OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException { private OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException {
//OAuthApplications are created by calling to APIKeyMgtSubscriber Service
SubscriberKeyMgtClient keyMgtClient = APIUtil.getKeyManagementClient();
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
//Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. //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(); String applicationName = profile.getClientName();
if (log.isDebugEnabled()) { 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) { if (oAuthApplicationInfo.getParameter("callback_url") != null) {
JSONArray jsonArray = (JSONArray) oAuthApplicationInfo.getParameter("callback_url"); JSONArray jsonArray = (JSONArray) oAuthApplicationInfo.getParameter("callback_url");
for (Object callbackUrlObject : jsonArray) { for (Object callbackUrlObject : jsonArray) {

Loading…
Cancel
Save