From bce52e54a3aa8e73fa16337dac919ec21c979536 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 1 Oct 2015 19:24:48 +0530 Subject: [PATCH 1/2] Upgrading dependency versions to their respective latests --- .../publisher/APIPublisherServiceImpl.java | 14 ++- .../dynamic-client-web/pom.xml | 14 ++- .../pom.xml | 2 +- .../DynamicClientRegistrationService.java | 62 +++++----- .../DynamicClientRegistrationUtil.java | 67 +++++++++++ .../impl/DynamicClientRegistrationImpl.java | 112 ++++++++---------- .../registration/internal/DataHolder.java | 48 ++++++++ ...icClientRegistrationServiceComponent.java} | 31 +++-- ...uthenticatorFrameworkServiceComponent.java | 1 - pom.xml | 26 ++-- 10 files changed, 252 insertions(+), 125 deletions(-) create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DataHolder.java rename components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/{DynamicClientRegistrationBundleActivator.java => DynamicClientRegistrationServiceComponent.java} (54%) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 47757b4cf8..6d1eb4c3a9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.APIProvider; +import org.wso2.carbon.apimgt.api.FaultGatewaysException; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIIdentifier; import org.wso2.carbon.apimgt.impl.APIManagerFactory; @@ -48,10 +49,15 @@ public class APIPublisherServiceImpl implements APIPublisherService { log.info("Successfully published API '" + api.getId().getApiName() + "' with context '" + api.getContext() + "' and version '" + api.getId().getVersion() + "'"); } else { - provider.updateAPI(api); - log.info("An API already exists with the name '" + api.getId().getApiName() + "', context '" + - api.getContext() + "' and version '" + api.getId().getVersion() + - "'. Thus, the API config is updated"); + try { + provider.updateAPI(api); + log.info("An API already exists with the name '" + api.getId().getApiName() + "', context '" + + api.getContext() + "' and version '" + api.getId().getVersion() + + "'. Thus, the API config is updated"); + } catch (FaultGatewaysException e) { + throw new APIManagementException("Error occurred while updating API " + api.getId().getApiName() + + "' with context '" + api.getContext() + "' and version '" + api.getId().getVersion() + "'"); + } } } else { throw new APIManagementException("API provider configured for the given API configuration is null. " + diff --git a/components/dynamic-client-registration/dynamic-client-web/pom.xml b/components/dynamic-client-registration/dynamic-client-web/pom.xml index 927f8e1f77..066b6207a3 100644 --- a/components/dynamic-client-registration/dynamic-client-web/pom.xml +++ b/components/dynamic-client-registration/dynamic-client-web/pom.xml @@ -67,30 +67,31 @@ org.apache.cxf cxf-rt-frontend-jaxws + provided org.apache.cxf cxf-rt-frontend-jaxrs + provided org.apache.cxf cxf-rt-transports-http + provided org.apache.cxf cxf-rt-bindings-soap - 2.6.1 compile org.apache.cxf cxf-rt-bindings-http - 2.5.11 + provided org.apache.cxf cxf-rt-rs-extension-providers - 2.6.1 compile @@ -102,10 +103,12 @@ slf4j-api + provided org.testng testng + provided @@ -143,6 +146,11 @@ org.codehaus.jackson jackson-jaxrs + + com.google.code.gson + gson + provided + diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml index e1aa38e3f6..563b5370f8 100644 --- a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml @@ -47,7 +47,7 @@ ${project.artifactId} ${carbon.device.mgt.version} Dynamic Client Registration Bundle - org.wso2.carbon.dynamic.client.registration.internal.DynamicClientRegistrationBundleActivator + org.wso2.carbon.dynamic.client.registration.internal.DynamicClientRegistrationServiceComponent org.wso2.carbon.dynamic.client.registration.internal !org.wso2.carbon.dynamic.client.registration.internal, diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java index e6aea31a71..7346ac1f69 100644 --- a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java @@ -25,37 +25,39 @@ import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; */ public interface DynamicClientRegistrationService { - /** - * This method will register a new OAuth application using the data provided by - * RegistrationProfile. - * - * @param profile - RegistrationProfile of the OAuth application to be created. - * @return OAuthApplicationInfo object which holds the necessary data of created OAuth app. - * @throws DynamicClientRegistrationException - */ - public OAuthApplicationInfo registerOAuthApplication(RegistrationProfile profile) throws - DynamicClientRegistrationException; + /** + * This method will register a new OAuth application using the data provided by + * RegistrationProfile. + * + * @param profile - RegistrationProfile of the OAuth application to be created. + * @return OAuthApplicationInfo object which holds the necessary data of created OAuth app. + * @throws DynamicClientRegistrationException + * + */ + public OAuthApplicationInfo registerOAuthApplication( + RegistrationProfile profile) throws DynamicClientRegistrationException; - /** - * This method will unregister a created OAuth application. - * - * @param userName - Username of the owner - * @param applicationName - OAuth application name - * @param consumerKey - ConsumerKey of the OAuth application - * @return The status of the operation - * @throws DynamicClientRegistrationException - */ - public boolean unregisterOAuthApplication(String userName, String applicationName, - String consumerKey) throws DynamicClientRegistrationException; + /** + * This method will unregister a created OAuth application. + * + * @param userName - Username of the owner + * @param applicationName - OAuth application name + * @param consumerKey - ConsumerKey of the OAuth application + * @return The status of the operation + * @throws DynamicClientRegistrationException + * + */ + public boolean unregisterOAuthApplication(String userName, String applicationName, + String consumerKey) throws DynamicClientRegistrationException; - /** - * This method will check the existence of an OAuth application provided application-name. - * - * @param applicationName - OAuth application name - * @return The status of the operation - * @throws DynamicClientRegistrationException - */ - public boolean isOAuthApplicationExists(String applicationName) - throws DynamicClientRegistrationException; + /** + * This method will check the existence of an OAuth application provided application-name. + * + * @param applicationName - OAuth application name + * @return The status of the operation + * @throws DynamicClientRegistrationException + * + */ + public boolean isOAuthApplicationExists(String applicationName) throws DynamicClientRegistrationException; } diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java new file mode 100644 index 0000000000..471db5facc --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.wso2.carbon.dynamic.client.registration; + +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.dynamic.client.registration.internal.DataHolder; +import org.wso2.carbon.user.api.TenantManager; +import org.wso2.carbon.user.api.UserStoreException; + +public class DynamicClientRegistrationUtil { + + public static String getTenantDomain() throws DynamicClientRegistrationException { + CarbonContext ctx = CarbonContext.getThreadLocalCarbonContext(); + String tenantDomain = ctx.getTenantDomain(); + if (tenantDomain != null && !tenantDomain.isEmpty()) { + return tenantDomain; + } + int tenantId = ctx.getTenantId(); + if (tenantId == MultitenantConstants.INVALID_TENANT_ID) { + throw new IllegalStateException("Invalid tenant Id found. This might likely have caused by improper " + + "handling of multi-tenancy"); + } + TenantManager tenantManager = DataHolder.getInstance().getTenantManager(); + try { + return tenantManager.getDomain(tenantId); + } catch (UserStoreException e) { + throw new DynamicClientRegistrationException("Error occurred while retrieving tenant domain from " + + "the tenant id derived out of the underlying carbon context", e); + } + } + + public static void validateUsername(String username) { + if (username == null || username.isEmpty()) { + throw new IllegalArgumentException("Username cannot be null or empty"); + } + } + + public static void validateApplicationName(String applicationName) { + if (applicationName == null || applicationName.isEmpty()) { + throw new IllegalArgumentException("Application name cannot be null or empty"); + } + } + + public static void validateConsumerKey(String consumerKey) { + if (consumerKey == null || consumerKey.isEmpty()) { + throw new IllegalArgumentException("Consumer Key cannot be null or empty"); + } + } + +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java index 599619cfc1..28e9600aa6 100644 --- a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java @@ -15,7 +15,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.wso2.carbon.dynamic.client.registration.impl; import org.apache.commons.logging.Log; @@ -24,10 +23,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.dynamic.client.registration.ApplicationConstants; -import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException; -import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; -import org.wso2.carbon.dynamic.client.registration.OAuthApplicationInfo; +import org.wso2.carbon.dynamic.client.registration.*; import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; import org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig; @@ -36,6 +32,7 @@ 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.IdentityOAuthAdminException; import org.wso2.carbon.identity.oauth.OAuthAdminService; import org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @@ -89,16 +86,16 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS if (jsonObject.has(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS)) { oAuthApplicationInfo .addParameter(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS, - jsonObject - .get(ApplicationConstants.ClientMetadata. - OAUTH_REDIRECT_URIS)); + jsonObject + .get(ApplicationConstants.ClientMetadata. + OAUTH_REDIRECT_URIS)); } if (jsonObject.has(ApplicationConstants.ClientMetadata.OAUTH_CLIENT_GRANT)) { oAuthApplicationInfo.addParameter(ApplicationConstants.ClientMetadata. - OAUTH_CLIENT_GRANT, jsonObject - .get(ApplicationConstants.ClientMetadata. - OAUTH_CLIENT_GRANT)); + OAUTH_CLIENT_GRANT, jsonObject + .get(ApplicationConstants.ClientMetadata. + OAUTH_CLIENT_GRANT)); } } catch (JSONException e) { throw new DynamicClientRegistrationException( @@ -148,11 +145,11 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS if (appMgtService == null) { throw new IllegalStateException( "Error occurred while retrieving Application Management" + - "Service"); + "Service"); } - appMgtService.createApplication(serviceProvider); + appMgtService.createApplication(serviceProvider, tenantDomain, userName); - ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName); + ServiceProvider createdServiceProvider = appMgtService.getServiceProvider(applicationName, tenantDomain); if (createdServiceProvider == null) { throw new DynamicClientRegistrationException( "Couldn't create Service Provider Application " + applicationName); @@ -162,22 +159,21 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS // Then Create OAuthApp OAuthAdminService oAuthAdminService = new OAuthAdminService(); - OAuthConsumerAppDTO oAuthConsumerAppDTO = new OAuthConsumerAppDTO(); - oAuthConsumerAppDTO.setApplicationName(applicationName); - oAuthConsumerAppDTO.setCallbackUrl(callbackUrl); - oAuthConsumerAppDTO.setGrantTypes(grantType); + OAuthConsumerAppDTO oAuthConsumerApp = new OAuthConsumerAppDTO(); + oAuthConsumerApp.setApplicationName(applicationName); + oAuthConsumerApp.setCallbackUrl(callbackUrl); + oAuthConsumerApp.setGrantTypes(grantType); if (log.isDebugEnabled()) { log.debug("Creating OAuth App " + applicationName); } - oAuthAdminService.registerOAuthApplicationData(oAuthConsumerAppDTO); + oAuthAdminService.registerOAuthApplicationData(oAuthConsumerApp); if (log.isDebugEnabled()) { log.debug("Created OAuth App " + applicationName); } OAuthConsumerAppDTO createdApp = - oAuthAdminService.getOAuthApplicationDataByAppName(oAuthConsumerAppDTO - .getApplicationName()); + oAuthAdminService.getOAuthApplicationDataByAppName(oAuthConsumerApp.getApplicationName()); if (log.isDebugEnabled()) { log.debug("Retrieved Details for OAuth App " + createdApp.getApplicationName()); } @@ -192,12 +188,12 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS inboundAuthenticationRequestConfig.setInboundAuthKey(createdApp.getOauthConsumerKey()); inboundAuthenticationRequestConfig.setInboundAuthType("oauth2"); if (createdApp.getOauthConsumerSecret() != null && !createdApp. - getOauthConsumerSecret() - .isEmpty()) { + getOauthConsumerSecret() + .isEmpty()) { Property property = new Property(); property.setName("oauthConsumerSecret"); property.setValue(createdApp.getOauthConsumerSecret()); - Property[] properties = { property }; + Property[] properties = {property}; inboundAuthenticationRequestConfig.setProperties(properties); } @@ -207,7 +203,7 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS createdServiceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig); // Update the Service Provider app to add OAuthApp as an Inbound Authentication Config - appMgtService.updateApplication(createdServiceProvider); + appMgtService.updateApplication(createdServiceProvider, tenantDomain, userName); OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); oAuthApplicationInfo.setClientId(createdApp.getOauthConsumerKey()); @@ -236,8 +232,11 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS @Override public boolean unregisterOAuthApplication(String userId, String applicationName, - String consumerKey) - throws DynamicClientRegistrationException { + String consumerKey) throws DynamicClientRegistrationException { + DynamicClientRegistrationUtil.validateUsername(userId); + DynamicClientRegistrationUtil.validateApplicationName(applicationName); + DynamicClientRegistrationUtil.validateConsumerKey(consumerKey); + boolean status = false; String tenantDomain = MultitenantUtils.getTenantDomain(userId); String baseUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); @@ -247,44 +246,37 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName); - if (userId == null || userId.isEmpty()) { + OAuthAdminService oAuthAdminService; + OAuthConsumerAppDTO oAuthConsumerApp; + try { + oAuthAdminService = new OAuthAdminService(); + oAuthConsumerApp = oAuthAdminService.getOAuthApplicationData(consumerKey); + } catch (IdentityOAuthAdminException e) { + throw new DynamicClientRegistrationException("Error occurred while retrieving application data", e); + } + + if (oAuthConsumerApp == null) { throw new DynamicClientRegistrationException( - "Error occurred while unregistering Application: userId cannot " + - "be null/empty"); + "No OAuth Consumer Application is associated with the given consumer key: " + consumerKey); } - try { - OAuthAdminService oAuthAdminService = new OAuthAdminService(); - OAuthConsumerAppDTO oAuthConsumerAppDTO = - oAuthAdminService.getOAuthApplicationData(consumerKey); - if (oAuthConsumerAppDTO == null) { - throw new DynamicClientRegistrationException( - "Couldn't retrieve OAuth Consumer Application associated with the " + - "given consumer key: " + consumerKey); - } + try { oAuthAdminService.removeOAuthApplicationData(consumerKey); ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); - - if (appMgtService == null) { - throw new IllegalStateException( - "Error occurred while retrieving Application Management" + - "Service"); - } - ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName); - + ServiceProvider createdServiceProvider = appMgtService.getServiceProvider(applicationName, tenantDomain); if (createdServiceProvider == null) { throw new DynamicClientRegistrationException( "Couldn't retrieve Service Provider Application " + applicationName); } - appMgtService.deleteApplication(applicationName); + appMgtService.deleteApplication(applicationName, tenantDomain, userName); status = true; } catch (IdentityApplicationManagementException e) { throw new DynamicClientRegistrationException( - "Error occurred while removing ServiceProvider for app " + applicationName, e); - } catch (Exception e) { - throw new DynamicClientRegistrationException( - "Error occurred while removing OAuthApp " + applicationName, e); + "Error occurred while removing ServiceProvider for application '" + applicationName + "'", e); + } catch (IdentityOAuthAdminException e) { + throw new DynamicClientRegistrationException("Error occurred while removing application '" + + applicationName + "'", e); } finally { PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(baseUser); @@ -293,23 +285,17 @@ public class DynamicClientRegistrationImpl implements DynamicClientRegistrationS } @Override - public boolean isOAuthApplicationExists(String applicationName) - throws DynamicClientRegistrationException { - ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); - if (appMgtService == null) { - throw new IllegalStateException( - "Error occurred while retrieving Application Management" + - "Service"); - } + public boolean isOAuthApplicationExists(String applicationName) throws DynamicClientRegistrationException { try { - if (appMgtService.getApplication(applicationName) != null) { + if (ApplicationManagementService.getInstance().getServiceProvider(applicationName, + CarbonContext.getThreadLocalCarbonContext().getTenantDomain()) != null) { return true; } } catch (IdentityApplicationManagementException e) { throw new DynamicClientRegistrationException( - "Error occurred while retrieving information of OAuthApp " + applicationName, - e); + "Error occurred while retrieving information of OAuthApp " + applicationName, e); } return false; } + } diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DataHolder.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DataHolder.java new file mode 100644 index 0000000000..4fa278a359 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DataHolder.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.wso2.carbon.dynamic.client.registration.internal; + +import org.wso2.carbon.user.api.TenantManager; +import org.wso2.carbon.user.core.service.RealmService; + +public class DataHolder { + + private RealmService realmService; + private static DataHolder thisInstance = new DataHolder(); + + private DataHolder() {} + + public static DataHolder getInstance() { + return thisInstance; + } + + public void setRealmService(RealmService realmService) { + this.realmService = realmService; + } + + public RealmService getRealmService() { + return realmService; + } + + public TenantManager getTenantManager() { + return realmService.getTenantManager(); + } + + +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java similarity index 54% rename from components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java rename to components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java index e3ae13e4df..72417e9f14 100644 --- a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java @@ -20,25 +20,30 @@ package org.wso2.carbon.dynamic.client.registration.internal; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; import org.wso2.carbon.dynamic.client.registration.impl.DynamicClientRegistrationImpl; /** - * BundleActivator class of DynamicClientRegistration component. + * @scr.component name="org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationServiceComponent" + * immediate="true" + * @scr.reference name="user.realmservice.default" + * interface="org.wso2.carbon.user.core.service.RealmService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" */ -public class DynamicClientRegistrationBundleActivator implements BundleActivator{ +public class DynamicClientRegistrationServiceComponent { - @Override - public void start(BundleContext bundleContext) throws Exception { - DynamicClientRegistrationService dynamicClientRegistrationService = - new DynamicClientRegistrationImpl(); - bundleContext.registerService(DynamicClientRegistrationService.class.getName(), - dynamicClientRegistrationService, null); - } + protected void activate(ComponentContext componentContext) { + BundleContext bundleContext = componentContext.getBundleContext(); + bundleContext.registerService(DynamicClientRegistrationService.class.getName(), + new DynamicClientRegistrationImpl(), null); + } - @Override - public void stop(BundleContext bundleContext) throws Exception { - - } + protected void deactivate(ComponentContext componentContext) { + //do nothing + } } diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java index 1479e7991d..95f3dffab9 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java @@ -37,7 +37,6 @@ import org.wso2.carbon.webapp.authenticator.framework.config.WebappAuthenticator import java.util.ArrayList; import java.util.List; - /** * @scr.component name="org.wso2.carbon.webapp.authenticator" immediate="true" * @scr.reference name="user.realmservice.default" diff --git a/pom.xml b/pom.xml index ce2f4a193f..b9ea2c5d22 100644 --- a/pom.xml +++ b/pom.xml @@ -37,14 +37,14 @@ components/device-mgt - components/apimgt-extensions + components/apimgt-extensions components/policy-mgt components/certificate-mgt components/webapp-authenticator-framework components/dynamic-client-registration features/device-mgt features/apimgt-extensions - features/policy-mgt + features/policy-mgt features/webapp-authenticator-framework features/certificate-mgt features/dynamic-client-registration @@ -1001,6 +1001,11 @@ json ${json.wso2.version} + + com.google.code.gson + gson + ${google.gson.version} + @@ -1206,7 +1211,7 @@ 1.5.4 - 0.10.0 + 0.10.2 1.3.0 1.3.0 1.3.0 @@ -1230,19 +1235,19 @@ 7.0.34.wso2v2 - 4.4.0 + 4.5.2 - 4.4.0 + 4.6.0-M2 - 4.4.0 + 4.4.1 - 4.4.1 + 4.4.8 - 4.4.1 + 4.5.8 1.2.11-wso2v5 @@ -1253,13 +1258,13 @@ 0.9.2-SNAPSHOT - 4.4.0 + 4.4.7 1.4.0.wso2v1 2.4.0.wso2v1 2.6.0.wso2v1 - 1.4.0 + 4.3.0-SNAPSHOT 2.6.1 @@ -1281,6 +1286,7 @@ 2.26.1.wso2v3 2.0.0.wso2v1 + 2.3.1 From df652fbbc4ea239d41e8cff86b50ca9cc8a59318 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Tue, 6 Oct 2015 20:27:51 +0530 Subject: [PATCH 2/2] Upgrading carbon-multitenancy version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c72d68ede3..98a54542ae 100644 --- a/pom.xml +++ b/pom.xml @@ -1246,7 +1246,7 @@ 4.6.0-M2 - 4.4.1 + 4.5.0-m1 4.4.8