http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/util/TenantCoreUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/util/TenantCoreUtil.java b/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/util/TenantCoreUtil.java deleted file mode 100644 index 00e318e..0000000 --- a/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/util/TenantCoreUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.apache.stratos.tenant.mgt.core.util; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - * -*/ - - -import org.apache.stratos.tenant.mgt.core.internal.TenantMgtCoreServiceComponent; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.util.tracker.ServiceTracker; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.utils.AuthenticationObserver; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.apache.stratos.common.constants.StratosConstants; - - -/** - * Tenant Core Util class - used by any service that needs to create a tenant. - */ -public class TenantCoreUtil { - - private static final Log log = LogFactory.getLog(TenantCoreUtil.class); - - /** - * Initializes the registry for the tenant. - * - * @param tenantId - * tenant id. - */ - public static void initializeRegistry(int tenantId) { - BundleContext bundleContext = TenantMgtCoreServiceComponent.getBundleContext(); - if (bundleContext != null) { - ServiceTracker tracker = - new ServiceTracker(bundleContext, - AuthenticationObserver.class.getName(), - null); - tracker.open(); - Object[] services = tracker.getServices(); - if (services != null) { - for (Object service : services) { - ((AuthenticationObserver) service).startedAuthentication(tenantId); - } - } - tracker.close(); - } - } - - /** - * Setting the Originated - * @param tenantId - tenant Id - * @param originatedService - The Service from where the tenant registration was originated. - * @throws Exception, Registry Exception, if error in putting the originated Service resource - * to the governance registry. - */ - public static void setOriginatedService(int tenantId, - String originatedService) throws Exception { - if (originatedService != null) { - String originatedServicePath = - StratosConstants.ORIGINATED_SERVICE_PATH + - StratosConstants.PATH_SEPARATOR + - StratosConstants.ORIGINATED_SERVICE + - StratosConstants.PATH_SEPARATOR + tenantId; - try { - Resource origServiceRes = TenantMgtCoreServiceComponent. - getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID).newResource(); - origServiceRes.setContent(originatedService); - TenantMgtCoreServiceComponent.getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID). - put(originatedServicePath, origServiceRes); - } catch (RegistryException e) { - String msg = "Error in putting the originated service resource " + - "to the governance registry"; - log.error(msg, e); - throw new RegistryException(msg, e); - } - } - } - -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.email.sender/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.email.sender/pom.xml b/components/org.apache.stratos.tenant.mgt.email.sender/pom.xml deleted file mode 100644 index a1a2a23..0000000 --- a/components/org.apache.stratos.tenant.mgt.email.sender/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>org.apache.stratos</groupId> - <artifactId>stratos-components-parent</artifactId> - <version>4.1.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.tenant.mgt.email.sender</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Tenant Management Email Sender Component</name> - - <build> - - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <Private-Package> - org.apache.stratos.tenant.mgt.email.sender.internal.*, - org.apache.stratos.tenant.mgt.email.sender.util.*, - </Private-Package> - <Export-Package> - org.apache.stratos.tenant.mgt.email.sender.listener.* - </Export-Package> - <Import-Package> - !javax.xml.namespace, - javax.xml.namespace; version=0.0.0, - org.apache.stratos.email.sender.api, - *;resolution:=optional - </Import-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.apache.axis2.wso2</groupId> - <artifactId>axis2</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.17</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.email.verification</artifactId> - <version>4.2.0</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.1.1</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.email.sender</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/DataHolder.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/DataHolder.java b/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/DataHolder.java deleted file mode 100644 index b7a2a40..0000000 --- a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/DataHolder.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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.apache.stratos.tenant.mgt.email.sender.internal; - -import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.user.api.RealmConfiguration; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.user.core.tenant.TenantManager; -import org.wso2.carbon.utils.ConfigurationContextService; - -import org.apache.axis2.context.ConfigurationContext; - -import org.osgi.framework.BundleContext; - -/** - * Utility methods for the email sender component - */ -public class DataHolder { - - private static RegistryService registryService; - private static RealmService realmService; - private static ConfigurationContextService configurationContextService; - private static EmailVerifcationSubscriber emailVerificationService; - private static BundleContext bundleContext; - - public static BundleContext getBundleContext() { - return bundleContext; - } - - public static void setBundleContext(BundleContext bundleContext) { - DataHolder.bundleContext = bundleContext; - } - - public static ConfigurationContextService getConfigurationContextService() { - return configurationContextService; - } - - public static void setConfigurationContextService( - ConfigurationContextService configurationContextService) { - DataHolder.configurationContextService = configurationContextService; - } - - public static ConfigurationContext getConfigurationContext() { - return configurationContextService.getServerConfigContext(); - } - - public static synchronized void setRegistryService(RegistryService service) { - if ((registryService == null) || (service == null)) { - registryService = service; - } - } - - public static RegistryService getRegistryService() { - return registryService; - } - - public static synchronized void setRealmService(RealmService service) { - if ((realmService == null) || (service == null)){ - realmService = service; - } - } - - public static RealmService getRealmService() { - return realmService; - } - - public static TenantManager getTenantManager() { - return realmService.getTenantManager(); - } - - public static RealmConfiguration getBootstrapRealmConfiguration() { - return realmService.getBootstrapRealmConfiguration(); - } - - public static UserRegistry getGovernanceSystemRegistry(int tenantId) throws RegistryException { - return registryService.getGovernanceSystemRegistry(tenantId); - } - - public static void setEmailVerificationService(EmailVerifcationSubscriber emailService) { - if ((emailVerificationService == null) || (emailService == null)){ - emailVerificationService = emailService; - } - } - - public static EmailVerifcationSubscriber getEmailVerificationService() { - return emailVerificationService; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/TenantMgtEmailSenderServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/TenantMgtEmailSenderServiceComponent.java b/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/TenantMgtEmailSenderServiceComponent.java deleted file mode 100644 index 5226897..0000000 --- a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/internal/TenantMgtEmailSenderServiceComponent.java +++ /dev/null @@ -1,106 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF 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.apache.stratos.tenant.mgt.email.sender.internal; - -import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.apache.stratos.common.util.CommonUtil; -import org.apache.stratos.tenant.mgt.email.sender.listener.EmailSenderListener; -import org.apache.stratos.tenant.mgt.email.sender.util.TenantMgtEmailSenderUtil; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ConfigurationContextService; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.osgi.service.component.ComponentContext; - -/** - * @scr.component name="org.apache.stratos.tenant.mgt.email.sender" - * immediate="true" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1" - * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" - * policy="dynamic" bind="setRealmService" unbind="unsetRealmService" - * @scr.reference name="configuration.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" - * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService" - * @scr.reference name="emailverification.service" - * interface= "org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber" - * cardinality="1..1" policy="dynamic" - * bind="setEmailVerificationService" unbind="unsetEmailVerificationService" - */ -public class TenantMgtEmailSenderServiceComponent { - private static Log log = LogFactory.getLog(TenantMgtEmailSenderServiceComponent.class); - - protected void activate(ComponentContext context) { - try { - DataHolder.setBundleContext(context.getBundleContext()); - if (!CommonUtil.isTenantManagementEmailsDisabled()) { - TenantMgtEmailSenderUtil.init(); - EmailSenderListener emailSenderListener = new EmailSenderListener(); - context.getBundleContext().registerService( - org.apache.stratos.common.listeners.TenantMgtListener.class.getName(), - emailSenderListener, null); - log.debug("******* Tenant Management Emails are enabled ******* "); - } - log.debug("******* Tenant Registration Email Sender bundle is activated ******* "); - } catch (Throwable e) { - log.error("******* Tenant Registration Email Sender bundle failed activating ****", e); - } - } - - protected void deactivate(ComponentContext context) { - log.debug("******* Email Sender bundle is deactivated ******* "); - } - - protected void setRegistryService(RegistryService registryService) { - DataHolder.setRegistryService(registryService); - } - - protected void unsetRegistryService(RegistryService registryService) { - DataHolder.setRegistryService(null); - } - - protected void setRealmService(RealmService realmService) { - DataHolder.setRealmService(realmService); - } - - protected void unsetRealmService(RealmService realmService) { - DataHolder.setRealmService(null); - } - - protected void setConfigurationContextService(ConfigurationContextService service) { - DataHolder.setConfigurationContextService(service); - } - - protected void unsetConfigurationContextService(ConfigurationContextService service) { - DataHolder.setConfigurationContextService(null); - } - - protected void setEmailVerificationService(EmailVerifcationSubscriber emailService) { - DataHolder.setEmailVerificationService(emailService); - } - - protected void unsetEmailVerificationService(EmailVerifcationSubscriber emailService) { - DataHolder.setEmailVerificationService(null); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/listener/EmailSenderListener.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/listener/EmailSenderListener.java b/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/listener/EmailSenderListener.java deleted file mode 100644 index 9e40792..0000000 --- a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/listener/EmailSenderListener.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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.apache.stratos.tenant.mgt.email.sender.listener; - -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.exception.ApacheStratosException; -import org.apache.stratos.common.listeners.TenantMgtListener; -import org.apache.stratos.tenant.mgt.email.sender.util.TenantMgtEmailSenderUtil; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class EmailSenderListener implements TenantMgtListener { - - private static final int EXEC_ORDER = 20; - private static final Log log = LogFactory.getLog(EmailSenderListener.class); - - public void onTenantCreate(TenantInfoBean tenantInfoBean) throws ApacheStratosException { - try { - TenantMgtEmailSenderUtil.sendTenantCreationVerification(tenantInfoBean); - } catch (Exception e) { - String message = "Error sending tenant creation Mail to tenant domain " - + tenantInfoBean.getTenantDomain(); - log.error(message, e); - throw new ApacheStratosException(message, e); - } - TenantMgtEmailSenderUtil.notifyTenantCreationToSuperAdmin(tenantInfoBean); - } - - public int getListenerOrder() { - return EXEC_ORDER; - } - - public void onTenantRename(int tenantId, String oldDomainName, - String newDomainName) throws ApacheStratosException { - // Do nothing. - - } - - public void onTenantUpdate(TenantInfoBean tenantInfoBean) throws ApacheStratosException { - if ((tenantInfoBean.getAdminPassword() != null) && - (!tenantInfoBean.getAdminPassword().equals(""))) { - try { - TenantMgtEmailSenderUtil.notifyResetPassword(tenantInfoBean); - } catch (Exception e) { - String message = "Error sending tenant update Mail to tenant domain " - + tenantInfoBean.getTenantDomain(); - log.error(message, e); - throw new ApacheStratosException(message, e); - } - } - } - - public void onTenantDelete(int tenantId) { - // Do nothing - } - - public void onTenantInitialActivation(int tenantId) throws ApacheStratosException { - // send the notification message to the tenant admin - TenantMgtEmailSenderUtil.notifyTenantInitialActivation(tenantId); - } - - public void onTenantActivation(int tenantId) throws ApacheStratosException { - // Do nothing - } - - public void onTenantDeactivation(int tenantId) throws ApacheStratosException { - // Do nothing - } - - public void onSubscriptionPlanChange(int tenentId, String oldPlan, - String newPlan) throws ApacheStratosException { - // Do nothing - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/util/TenantMgtEmailSenderUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/util/TenantMgtEmailSenderUtil.java b/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/util/TenantMgtEmailSenderUtil.java deleted file mode 100644 index 6ba20c8..0000000 --- a/components/org.apache.stratos.tenant.mgt.email.sender/src/main/java/org/apache/stratos/tenant/mgt/email/sender/util/TenantMgtEmailSenderUtil.java +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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.apache.stratos.tenant.mgt.email.sender.util; - -import org.apache.stratos.tenant.mgt.email.sender.internal.DataHolder; -import org.apache.stratos.email.sender.api.EmailSender; -import org.apache.stratos.email.sender.api.EmailSenderConfiguration; -import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; -import org.wso2.carbon.email.verification.util.EmailVerifierConfig; -import org.wso2.carbon.registry.core.RegistryConstants; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.registry.core.utils.UUIDGenerator; -import org.apache.stratos.common.beans.TenantInfoBean; -import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.common.util.ClaimsMgtUtil; -import org.apache.stratos.common.util.CommonUtil; -import org.wso2.carbon.user.api.Tenant; -import org.wso2.carbon.user.core.tenant.TenantManager; -import org.wso2.carbon.utils.AuthenticationObserver; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import org.osgi.framework.BundleContext; -import org.osgi.util.tracker.ServiceTracker; - -/** - * Utility methods for the email sender component - */ -public class TenantMgtEmailSenderUtil { - - private static final Log log = LogFactory.getLog(TenantMgtEmailSenderUtil.class); - - private static EmailSender successMsgSender; - private static EmailSender tenantCreationNotifier; - private static EmailSender tenantActivationNotifier; - private static EmailSender passwordResetMsgSender; - private static EmailVerifierConfig emailVerifierConfig; - private static EmailVerifierConfig superTenantEmailVerifierConfig = null; - - public static void init() { - initTenantActivatedEmailSender(); - initSuperTenantNotificationEmailSender(); - initEmailVerificationSender(); - initPasswordResetEmailSender(); - } - - /** - * Sends validation mail to the tenant admin upon the tenant creation - * - * @param tenantInfoBean - registered tenant's details - * @throws Exception, if the sending mail failed - */ - public static void sendTenantCreationVerification( - TenantInfoBean tenantInfoBean) throws Exception { - String confirmationKey = generateConfirmationKey(tenantInfoBean, - DataHolder.getRegistryService().getConfigSystemRegistry( - MultitenantConstants.SUPER_TENANT_ID)); - - if (CommonUtil.isTenantActivationModerated()) { - requestSuperTenantModeration(tenantInfoBean, confirmationKey); - } else { - //request for verification - requestUserVerification(tenantInfoBean, confirmationKey); - } - } - - /** - * Emails the tenant admin notifying the account creation. - * - * @param tenantId tenant Id - */ - public static void notifyTenantInitialActivation(int tenantId) { - TenantManager tenantManager = DataHolder.getTenantManager(); - String firstName = ""; - String domainName = ""; - String adminName = ""; - String email = ""; - try { - Tenant tenant = tenantManager.getTenant(tenantId); - domainName = tenant.getDomain(); - firstName = ClaimsMgtUtil.getFirstName(DataHolder.getRealmService(), tenantId); - adminName = tenant.getAdminName(); - email = tenant.getEmail(); - } catch (Exception e) { - String msg = "Unable to get the tenant with the tenant domain"; - log.error(msg, e); - // just catch from here. - } - - // load the mail configuration - Map<String, String> userParams = new HashMap<String, String>(); - userParams.put("first-name", firstName); - userParams.put("user-name", adminName); - userParams.put("domain-name", domainName); - - try { - successMsgSender.sendEmail(email, userParams); - } catch (Exception e) { - // just catch from here.. - String msg = "Error in sending the notification email."; - log.error(msg, e); - } - - // send the notification message to the super tenant - notifyTenantActivationToSuperAdmin(domainName, adminName, email); - } - - /** - * Emails the super admin notifying the account creation for a new tenant. - * - * @param tenantInfoBean - tenant details - */ - public static void notifyTenantCreationToSuperAdmin(TenantInfoBean tenantInfoBean) { - String notificationEmailAddress = CommonUtil.getNotificationEmailAddress(); - - if (notificationEmailAddress.trim().equals("")) { - if (log.isDebugEnabled()) { - log.debug("No super-admin notification email address is set to notify upon a" + - " tenant registration"); - } - return; - } - - Map<String, String> userParams = initializeSuperTenantNotificationParams( - tenantInfoBean.getTenantDomain(), tenantInfoBean.getAdmin(), - tenantInfoBean.getEmail()); - - try { - tenantCreationNotifier.sendEmail(notificationEmailAddress, userParams); - } catch (Exception e) { - // just catch from here.. - String msg = "Error in sending the notification email."; - log.error(msg, e); - } - } - - public static void notifyResetPassword(TenantInfoBean tenantInfoBean) throws Exception { - int tenantId = tenantInfoBean.getTenantId(); - String firstName = ClaimsMgtUtil.getFirstName(DataHolder.getRealmService(), tenantId); - - // load the mail configuration - Map<String, String> userParams = new HashMap<String, String>(); - userParams.put("user-name", tenantInfoBean.getAdmin()); - userParams.put("first-name", firstName); - userParams.put("domain-name", tenantInfoBean.getTenantDomain()); - userParams.put("password", tenantInfoBean.getAdminPassword()); - - try { - passwordResetMsgSender.sendEmail(tenantInfoBean.getEmail(), userParams); - } catch (Exception e) { - // just catch from here.. - String msg = "Error in sending the notification email."; - log.error(msg, e); - } - } - - /** - * Emails the super admin notifying the account activation for an unactivated tenant. - * - * @param domainName tenant domain - * @param adminName tenant admin - * @param email tenant's email address - */ - private static void notifyTenantActivationToSuperAdmin(String domainName, String adminName, - String email) { - String notificationEmailAddress = CommonUtil.getNotificationEmailAddress(); - - if (notificationEmailAddress.trim().equals("")) { - if (log.isDebugEnabled()) { - log.debug("No super-admin notification email address is set to notify upon a" - + " tenant activation"); - } - return; - } - - Map<String, String> userParams = - initializeSuperTenantNotificationParams(domainName, adminName, email); - - try { - tenantActivationNotifier.sendEmail(notificationEmailAddress, userParams); - } catch (Exception e) { - // just catch from here.. - String msg = "Error in sending the notification email."; - log.error(msg, e); - } - } - - /** - * generates the confirmation key for the tenant - * - * @param tenantInfoBean - tenant details - * @param superTenantConfigSystemRegistry - * - super tenant config system registry. - * @return confirmation key - * @throws RegistryException if generation of the confirmation key failed. - */ - private static String generateConfirmationKey(TenantInfoBean tenantInfoBean, - UserRegistry superTenantConfigSystemRegistry - ) throws RegistryException { - // generating the confirmation key - String confirmationKey = UUIDGenerator.generateUUID(); - UserRegistry superTenantGovernanceSystemRegistry; - try { - superTenantGovernanceSystemRegistry = - DataHolder.getRegistryService().getGovernanceSystemRegistry( - MultitenantConstants.SUPER_TENANT_ID); - } catch (RegistryException e) { - String msg = "Exception in getting the governance system registry for the super tenant"; - log.error(msg, e); - throw new RegistryException(msg, e); - } - Resource resource; - String emailVerificationPath = StratosConstants.ADMIN_EMAIL_VERIFICATION_FLAG_PATH + - RegistryConstants.PATH_SEPARATOR + - tenantInfoBean.getTenantId(); - try { - if (superTenantGovernanceSystemRegistry.resourceExists(emailVerificationPath)) { - resource = superTenantGovernanceSystemRegistry.get(emailVerificationPath); - } else { - resource = superTenantGovernanceSystemRegistry.newResource(); - } - resource.setContent(confirmationKey); - } catch (RegistryException e) { - String msg = "Error in creating the resource or getting the resource" + - "from the email verification path"; - log.error(msg, e); - throw new RegistryException(msg, e); - } - // email is not validated yet, this prop is used to activate the tenant later. - resource.addProperty(StratosConstants.IS_EMAIL_VALIDATED, "false"); - resource.addProperty(StratosConstants.TENANT_ADMIN, tenantInfoBean.getAdmin()); - try { - superTenantGovernanceSystemRegistry.put(emailVerificationPath, resource); - } catch (RegistryException e) { - String msg = "Error in putting the resource to the super tenant registry" + - " for the email verification path"; - log.error(msg, e); - throw new RegistryException(msg, e); - } - - // Used for * as a Service impl. - // Store the cloud service from which the register req. is originated. - if (tenantInfoBean.getOriginatedService() != null) { - String originatedServicePath = - StratosConstants.ORIGINATED_SERVICE_PATH + - StratosConstants.PATH_SEPARATOR + - StratosConstants.ORIGINATED_SERVICE + - StratosConstants.PATH_SEPARATOR + tenantInfoBean.getTenantId(); - try { - Resource origServiceRes = superTenantConfigSystemRegistry.newResource(); - origServiceRes.setContent(tenantInfoBean.getOriginatedService()); - superTenantGovernanceSystemRegistry.put(originatedServicePath, origServiceRes); - } catch (RegistryException e) { - String msg = "Error in putting the originated service resource " - + "to the governance registry"; - log.error(msg, e); - throw new RegistryException(msg, e); - } - } - initializeRegistry(tenantInfoBean.getTenantId()); - if (log.isDebugEnabled()) { - log.debug("Successfully generated the confirmation key."); - } - return confirmationKey; - } - - /** - * Sends mail for the super tenant for the account moderation. Once super tenant clicks the - * link provided in the email, the tenant will be activated. - * - * @param tenantInfoBean - the tenant who registered an account - * @param confirmationKey confirmation key. - * @throws Exception if an exception is thrown from EmailVerificationSubscriber. - */ - private static void requestSuperTenantModeration(TenantInfoBean tenantInfoBean, - String confirmationKey) throws Exception { - try { - Map<String, String> dataToStore = new HashMap<String, String>(); - dataToStore.put("email", CommonUtil.getSuperAdminEmail()); - dataToStore.put("first-name", tenantInfoBean.getFirstname()); - dataToStore.put("userName", tenantInfoBean.getAdmin()); - dataToStore.put("tenantDomain", tenantInfoBean.getTenantDomain()); - dataToStore.put("confirmationKey", confirmationKey); - - DataHolder.getEmailVerificationService().requestUserVerification( - dataToStore, superTenantEmailVerifierConfig); - if (log.isDebugEnabled()) { - log.debug("Email verification for the tenant registration."); - } - } catch (Exception e) { - String msg = "Error in notifying the super tenant on the account creation for " + - "the domain: " + tenantInfoBean.getTenantDomain(); - log.error(msg); - throw new Exception(msg, e); - } - } - - /** - * request email verification from the user. - * - * @param tenantInfoBean - Tenant information - * @param confirmationKey confirmation key. - * @throws Exception if an exception is thrown from EmailVerificationSubscriber. - */ - private static void requestUserVerification(TenantInfoBean tenantInfoBean, - String confirmationKey) throws Exception { - try { - Map<String, String> dataToStore = new HashMap<String, String>(); - dataToStore.put("email", tenantInfoBean.getEmail()); - dataToStore.put("first-name", tenantInfoBean.getFirstname()); - dataToStore.put("userName", tenantInfoBean.getAdmin()); - dataToStore.put("tenantDomain", tenantInfoBean.getTenantDomain()); - dataToStore.put("confirmationKey", confirmationKey); - - EmailVerifcationSubscriber emailVerifier = DataHolder.getEmailVerificationService(); - emailVerifier.requestUserVerification(dataToStore, emailVerifierConfig); - if (log.isDebugEnabled()) { - log.debug("Email verification for the tenant registration."); - } - } catch (Exception e) { - String msg = "Error in notifying tenant of domain: " + tenantInfoBean.getTenantDomain(); - log.error(msg); - throw new Exception(msg, e); - } - } - - /** - * Initializes the registry for the tenant. - * - * @param tenantId tenant id. - */ - private static void initializeRegistry(int tenantId) { - BundleContext bundleContext = DataHolder.getBundleContext(); - if (bundleContext != null) { - ServiceTracker tracker = - new ServiceTracker(bundleContext, - AuthenticationObserver.class.getName(), - null); - tracker.open(); - Object[] services = tracker.getServices(); - if (services != null) { - for (Object service : services) { - ((AuthenticationObserver) service).startedAuthentication(tenantId); - } - } - tracker.close(); - } - } - - /** - * loads the notification configurations for the mail to super tenant for account creations - * and activations. - */ - private static void initSuperTenantNotificationEmailSender() { - // Tenant Registration Email Configurations - String tenantRegistrationEmailConfFile = - CarbonUtils.getCarbonConfigDirPath() + File.separator + - StratosConstants.EMAIL_CONFIG + File.separator + - "email-new-tenant-registration.xml"; - EmailSenderConfiguration newTenantRegistrationEmailConf = - EmailSenderConfiguration.loadEmailSenderConfiguration( - tenantRegistrationEmailConfFile); - tenantCreationNotifier = new EmailSender(newTenantRegistrationEmailConf); - - // Tenant Activation Email Configurations - String tenantActivationEmailConfFile = - CarbonUtils.getCarbonConfigDirPath() + File.separator + - StratosConstants.EMAIL_CONFIG + File.separator + - "email-new-tenant-activation.xml"; - EmailSenderConfiguration newTenantActivationEmailConf = - EmailSenderConfiguration - .loadEmailSenderConfiguration(tenantActivationEmailConfFile); - tenantActivationNotifier = new EmailSender(newTenantActivationEmailConf); - } - - /** - * loads the Email configuration files to be sent on the tenant registrations. - */ - private static void initEmailVerificationSender() { - String confXml = - CarbonUtils.getCarbonConfigDirPath() + File.separator + - StratosConstants.EMAIL_CONFIG + File.separator + "email-registration.xml"; - try { - emailVerifierConfig = org.wso2.carbon.email.verification.util.Util - .loadeMailVerificationConfig(confXml); - } catch (Exception e) { - String msg = "Email Registration Configuration file not found. " - + "Pls check the repository/conf/email folder."; - log.error(msg); - } - String superTenantConfXml = - CarbonUtils.getCarbonConfigDirPath() + File.separator + - StratosConstants.EMAIL_CONFIG + File.separator + - "email-registration-moderation.xml"; - try { - superTenantEmailVerifierConfig = org.wso2.carbon.email.verification.util.Util - .loadeMailVerificationConfig(superTenantConfXml); - } catch (Exception e) { - String msg = - "Email Moderation Configuration file not found. " - + "Pls check the repository/conf/email folder."; - log.error(msg); - } - } - - /** - * loads the Email configuration files to be sent on the tenant activations. - */ - private static void initTenantActivatedEmailSender() { - String confFilename = - CarbonUtils.getCarbonConfigDirPath() + File.separator + - StratosConstants.EMAIL_CONFIG + File.separator + - "email-registration-complete.xml"; - EmailSenderConfiguration successMsgConfig = - EmailSenderConfiguration.loadEmailSenderConfiguration(confFilename); - successMsgSender = new EmailSender(successMsgConfig); - } - - private static void initPasswordResetEmailSender() { - String passwordResetConfigFileName = CarbonUtils.getCarbonConfigDirPath()+ File.separator + - StratosConstants.EMAIL_CONFIG + File.separator + "email-password-reset.xml"; - EmailSenderConfiguration passwordResetMsgConfig = - EmailSenderConfiguration.loadEmailSenderConfiguration(passwordResetConfigFileName); - passwordResetMsgSender = new EmailSender(passwordResetMsgConfig); - } - - /** - * Initializes the super tenant notification parameters - * - * @param domainName - tenant domain - * @param adminName - tenant admin - * @param email - tenant email - * @return the parameters - */ - private static Map<String, String> initializeSuperTenantNotificationParams( - String domainName, String adminName, String email) { - TenantManager tenantManager = DataHolder.getTenantManager(); - String firstName = ""; - String lastName = ""; - try { - int tenantId = tenantManager.getTenantId(domainName); - firstName = ClaimsMgtUtil.getFirstName(DataHolder.getRealmService(), tenantId); - lastName = ClaimsMgtUtil.getLastName(DataHolder.getRealmService(), tenantId); - - } catch (Exception e) { - String msg = "Unable to get the tenant with the tenant domain"; - log.error(msg, e); - // just catch from here. - } - - // load the mail configuration - Map<String, String> userParams = new HashMap<String, String>(); - userParams.put("user-name", adminName); - userParams.put("domain-name", domainName); - userParams.put("email-address", email); - userParams.put("first-name", firstName); - userParams.put("last-name", lastName); - return userParams; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/pom.xml b/components/org.apache.stratos.tenant.mgt.ui/pom.xml deleted file mode 100644 index 0cc01cb..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/pom.xml +++ /dev/null @@ -1,121 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>org.apache.stratos</groupId> - <artifactId>stratos-components-parent</artifactId> - <version>4.1.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.tenant.mgt.ui</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - User Interface for Tenant CRUD operations</name> - - <build> - - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <Export-Package> - org.apache.stratos.tenant.mgt.ui.*, - </Export-Package> - <Import-Package> - org.apache.stratos.tenant.mgt.stub.*; version="${project.version}", - org.apache.axis2.client.*, - javax.servlet;version="${imp.pkg.version.javax.servlet}", - javax.servlet.http;version="${imp.pkg.version.javax.servlet}", - org.apache.lucene.*, - *;resolution:=optional - </Import-Package> - <DynamicImport-Package>*</DynamicImport-Package> - <Carbon-Component>UIBundle</Carbon-Component> - </instructions> - </configuration> - </plugin> - - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.common.ui</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.1.1</version> - </dependency> - <dependency> - <groupId>org.eclipse.equinox</groupId> - <artifactId>javax.servlet</artifactId> - <version>3.0.0.v201112011016</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.axis2.wso2</groupId> - <artifactId>axis2</artifactId> - </dependency> - <dependency> - <groupId>org.apache.ws.commons.axiom.wso2</groupId> - <artifactId>axiom</artifactId> - <version>${axiom.wso2.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.ui</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.tenant.mgt.stub</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.json.wso2</groupId> - <artifactId>json</artifactId> - <version>${json.wso2.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common.stub</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/PackageInfoServiceClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/PackageInfoServiceClient.java b/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/PackageInfoServiceClient.java deleted file mode 100644 index 5b6c277..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/PackageInfoServiceClient.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.stratos.tenant.mgt.ui.clients; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - * -*/ - - -import org.apache.axis2.AxisFault; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONObject; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.apache.stratos.common.packages.stub.PackageInfoServiceStub; -import org.apache.stratos.common.packages.stub.PackageInfo; - -/** - * PackageInfoService client - */ -public class PackageInfoServiceClient { - - private static Log log = LogFactory.getLog(PackageInfoServiceClient.class); - - private PackageInfoServiceStub stub; - private String epr; - - public PackageInfoServiceClient( - String cookie, String backendServerURL, ConfigurationContext configContext) - throws Exception { - - epr = backendServerURL + "PackageInfoService"; - - try { - stub = new PackageInfoServiceStub(configContext, epr); - - ServiceClient client = stub._getServiceClient(); - Options option = client.getOptions(); - option.setManageSession(true); - option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); - - } catch (AxisFault axisFault) { - String msg = "Failed to initiate PackageInfoService client. " + axisFault.getMessage(); - log.error(msg, axisFault); - throw new RegistryException(msg, axisFault); - } - } - - public PackageInfo[] getBillingPackages() throws Exception{ - - try { - return stub.getPackageInfos(); - } catch (Exception e) { - String msg = "Failed to get package information: " + e.getMessage(); - log.error(msg, e); - throw new Exception(msg,e); - } - } - - public JSONArray getBillingPackagesJsonArray() throws Exception{ - - try{ - PackageInfo[] packageInfoArray = stub.getPackageInfos(); - JSONArray jsonPackageInfoArray = new JSONArray(); - for(PackageInfo packageInfo : packageInfoArray){ - JSONObject packageInfoObj = new JSONObject(); - packageInfoObj.put("name", packageInfo.getName()); - int subscriptionCharge = packageInfo.getSubscriptionCharge(); - //TODO https://wso2.org/jira/browse/STRATOS-1819 - StringBuffer charge = new StringBuffer("$" + subscriptionCharge ); - packageInfoObj.put("subscriptionCharge", charge.toString()); - jsonPackageInfoArray.put(packageInfoObj); - } - return jsonPackageInfoArray; - }catch(Exception e){ - String msg = "Failed to get package information: " + e.getMessage(); - log.error(msg, e); - throw new Exception(msg,e); - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/TenantServiceClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/TenantServiceClient.java b/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/TenantServiceClient.java deleted file mode 100644 index 15fafcc..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/clients/TenantServiceClient.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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.apache.stratos.tenant.mgt.ui.clients; - -import org.apache.axis2.AxisFault; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.apache.stratos.tenant.mgt.stub.TenantMgtAdminServiceStub; -import org.apache.stratos.tenant.mgt.stub.beans.xsd.PaginatedTenantInfoBean; -import org.apache.stratos.tenant.mgt.stub.beans.xsd.TenantInfoBean; -import org.wso2.carbon.ui.CarbonUIUtil; -import org.wso2.carbon.utils.ServerConstants; - -import javax.servlet.ServletConfig; -import javax.servlet.http.HttpSession; - -/** - * Tenant Service Client of tenant.mgt.ui - */ -public class TenantServiceClient { - private static final Log log = LogFactory.getLog(TenantServiceClient.class); - - private TenantMgtAdminServiceStub stub; - - public TenantServiceClient(String cookie, String backendServerURL, - ConfigurationContext configContext) throws RegistryException { - - String epr = backendServerURL + "TenantMgtAdminService"; - - try { - stub = new TenantMgtAdminServiceStub(configContext, epr); - - ServiceClient client = stub._getServiceClient(); - Options option = client.getOptions(); - option.setManageSession(true); - option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); - - } catch (AxisFault axisFault) { - String msg = "Failed to initiate AddServices service client. " + axisFault.getMessage(); - log.error(msg, axisFault); - throw new RegistryException(msg, axisFault); - } - } - - public TenantServiceClient(ServletConfig config, HttpSession session) - throws RegistryException { - - String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); - String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); - ConfigurationContext configContext = (ConfigurationContext) config. - getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); - String epr = backendServerURL + "TenantMgtAdminService"; - - try { - stub = new TenantMgtAdminServiceStub(configContext, epr); - - ServiceClient client = stub._getServiceClient(); - Options option = client.getOptions(); - option.setManageSession(true); - option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); - - } catch (AxisFault axisFault) { - String msg = "Failed to initiate Add Services service client. " + axisFault.getMessage(); - log.error(msg, axisFault); - throw new RegistryException(msg, axisFault); - } - } - - public void addTenant(TenantInfoBean tenantInfoBean) throws Exception { - stub.addTenant(tenantInfoBean); - } - - public TenantInfoBean[] retrieveTenants() throws Exception { - return stub.retrieveTenants(); - } - - public PaginatedTenantInfoBean retrievePaginatedTenants(int pageNumber) throws Exception { - return stub.retrievePaginatedTenants(pageNumber); - } - - public PaginatedTenantInfoBean retrievePaginatedPartialSearchTenants(String domain,int pageNumber) throws Exception { - return stub.retrievePaginatedPartialSearchTenants(domain,pageNumber); - } - - public TenantInfoBean getTenant(String domainName) throws Exception { - return stub.getTenant(domainName); - } - - public void updateTenant(TenantInfoBean tenantInfoBean) throws Exception { - stub.updateTenant(tenantInfoBean); - } - - public void activateTenant(String domainName) throws Exception { - stub.activateTenant(domainName); - } - - public void deactivateTenant(String domainName) throws Exception { - stub.deactivateTenant(domainName); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/utils/TenantMgtUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/utils/TenantMgtUtil.java b/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/utils/TenantMgtUtil.java deleted file mode 100644 index e1c9b69..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/java/org/apache/stratos/tenant/mgt/ui/utils/TenantMgtUtil.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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.apache.stratos.tenant.mgt.ui.utils; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.tenant.mgt.stub.beans.xsd.TenantInfoBean; -import org.apache.stratos.tenant.mgt.ui.clients.TenantServiceClient; - -import javax.servlet.ServletConfig; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.util.Calendar; - -/** - * Utility methods for tenant.mgt.ui - */ -public class TenantMgtUtil { - private static final Log log = LogFactory.getLog(TenantMgtUtil.class); - - /** - * Super admin Adds a tenant - * - * @param request HttpServletRequest - * @param config ServletConfig - * @param session HttpSession - * @throws Exception , if error in adding the tenant - */ - public static void addTenantConfigBean(HttpServletRequest request, ServletConfig config, - HttpSession session) throws Exception { - TenantInfoBean tenantInfoBean = new TenantInfoBean(); - - try { - tenantInfoBean.setAdmin(request.getParameter("admin")); - tenantInfoBean.setFirstname(request.getParameter("admin-firstname")); - tenantInfoBean.setLastname(request.getParameter("admin-lastname")); - tenantInfoBean.setAdminPassword(request.getParameter("admin-password")); - tenantInfoBean.setTenantDomain(request.getParameter("domain")); - tenantInfoBean.setEmail(request.getParameter("admin-email")); - tenantInfoBean.setUsagePlan(request.getParameter("usage-plan-name")); - tenantInfoBean.setCreatedDate(Calendar.getInstance()); - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - serviceClient.addTenant(tenantInfoBean); - - } catch (Exception e) { - String msg = "Failed to add tenant config. tenant-domain: " - + tenantInfoBean.getTenantDomain() + ", " + "tenant-admin: " - + tenantInfoBean.getAdmin() + "."; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * Super admin Updates a tenant - * - * @param request HttpServletRequest - * @param config ServletConfig - * @param session HttpSession - * @throws Exception , if error in updating the tenant - */ - public static void updateTenantConfigBean(HttpServletRequest request, ServletConfig config, - HttpSession session) throws Exception { - TenantInfoBean tenantInfoBean = new TenantInfoBean(); - - try { - String tenantIdStr = request.getParameter("tenantId"); - int tenantId; - try { - tenantId = Integer.parseInt(tenantIdStr); - } catch (Exception e) { - String msg = "Error in converting tenant id: " + tenantIdStr + " to a number."; - log.error(msg); - throw new Exception(msg, e); - } - tenantInfoBean.setTenantId(tenantId); - tenantInfoBean.setAdmin(request.getParameter("admin")); - tenantInfoBean.setFirstname(request.getParameter("admin-firstname")); - tenantInfoBean.setLastname(request.getParameter("admin-lastname")); - tenantInfoBean.setAdminPassword(request.getParameter("admin-password")); - tenantInfoBean.setTenantDomain(request.getParameter("domain")); - tenantInfoBean.setEmail(request.getParameter("admin-email")); - tenantInfoBean.setUsagePlan(request.getParameter("usage-plan-name")); - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - serviceClient.updateTenant(tenantInfoBean); - //UsagePlanClient usagePlanClient = new UsagePlanClient(config, session); - //update usage plan(subscription) per tenant - //usagePlanClient.updateUsagePlan(tenantInfoBean); - } catch (Exception e) { - String msg = "Failed to update the tenant config. tenant-domain: " - + tenantInfoBean.getTenantDomain() + ", " + "tenant-admin: " - + tenantInfoBean.getAdmin() + "."; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * Super admin gets all the tenant - * - * @param request HttpServletRequest - * @param config ServletConfig - * @param session HttpSession - * @return TenantInfoBean[] - Array of tenants - * @throws Exception , if getting the tenant information failed. - */ - public static TenantInfoBean[] getTenants(HttpServletRequest request, ServletConfig config, - HttpSession session) throws Exception { - - try { - - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - return serviceClient.retrieveTenants(); - } catch (Exception e) { - String msg = "Failed to get the minimum information bean of tenants. "; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * Super admin gets a particular tenant - * - * @param request HttpServletRequest - * @param config ServletConfig - * @param session HttpSession - * @return TenantInfoBean - for a tenant - * @throws Exception , if error in getting the tenant - */ - public static TenantInfoBean getTenant(HttpServletRequest request, ServletConfig config, - HttpSession session) throws Exception { - String tenantDomain = ""; - try { - tenantDomain = request.getParameter("domain"); - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - TenantInfoBean tenantBean=serviceClient.getTenant(tenantDomain); - return tenantBean; - } catch (Exception e) { - String msg = "Failed to get existing details of the tenant:" + tenantDomain; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * Super admin activates a tenant - * - * @param request HttpServletRequest - * @param config ServletConfig - * @param session HttpSession - * @throws Exception , if failed to activate the tenant. - */ - public static void activateTenant(HttpServletRequest request, ServletConfig config, - HttpSession session) throws Exception { - String tenantDomain = ""; - try { - tenantDomain = request.getParameter("activate.domain"); - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - serviceClient.activateTenant(tenantDomain); - } catch (Exception e) { - String msg = "Failed to activate the tenant:" + tenantDomain; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * Super admin deactivates a tenant - * - * @param request HttpServletRequest - * @param config ServletConfig - * @param session HttpSession - * @throws Exception , if failed to deactivate the tenant - */ - public static void deactivateTenant(HttpServletRequest request, ServletConfig config, - HttpSession session) throws Exception { - String tenantDomain = ""; - try { - tenantDomain = request.getParameter("activate.domain"); - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - serviceClient.deactivateTenant(tenantDomain); - } catch (Exception e) { - String msg = "Failed to deactivate the tenant:" + tenantDomain; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * This is used to avoid xss attacks - * - * @param text the text - * @return the text encoding '<' and '>' elements - */ - public static String removeHtmlElements(String text) { - if (text == null) { - return null; - } - return text.replaceAll("<", "<").replaceAll(">", ">"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/META-INF/component.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/META-INF/component.xml deleted file mode 100644 index df37171..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/META-INF/component.xml +++ /dev/null @@ -1,62 +0,0 @@ -<!-- - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF 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. - --> -<component xmlns="http://products.wso2.org/carbon"> - <!-- sample menu configuration --> - <menus> - <menu> - <id>multitenancy_menu</id> - <i18n-key>multitenancy</i18n-key> - <i18n-bundle>org.apache.stratos.tenant.mgt.ui.i18n.Resources</i18n-bundle> - <parent-menu>configure_menu</parent-menu> - <link>#</link> - <region>region1</region> - <order>60</order> - <style-class>home</style-class> - <icon>../tenant-mgt/images/multi_tenancy.png</icon> - <require-super-tenant>true</require-super-tenant> - </menu> - <menu> - <id>govern_add_tenants_menu</id> - <i18n-key>govern.add_tenants.menu</i18n-key> - <i18n-bundle>org.apache.stratos.tenant.mgt.ui.i18n.Resources</i18n-bundle> - <parent-menu>multitenancy_menu</parent-menu> - <link>../tenant-mgt/add_tenant.jsp</link> - <region>region1</region> - <order>1</order> - <style-class>manage-configuration</style-class> - <icon>../tenant-mgt/images/services.gif</icon> - <require-permission>/permission/protected/manage/modify/tenants</require-permission> - <require-super-tenant>true</require-super-tenant> - </menu> - <menu> - <id>govern_view_tenants_menu</id> - <i18n-key>govern.view_tenants.menu</i18n-key> - <i18n-bundle>org.apache.stratos.tenant.mgt.ui.i18n.Resources</i18n-bundle> - <parent-menu>multitenancy_menu</parent-menu> - <link>../tenant-mgt/view_tenants.jsp</link> - <region>region1</region> - <order>2</order> - <style-class>manage</style-class> - <icon>../tenant-mgt/images/services1.gif</icon> - <require-permission>/permission/protected/manage/monitor/tenants</require-permission> - <require-super-tenant>true</require-super-tenant> - </menu> - </menus> - -</component> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/JSResources.properties ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/JSResources.properties b/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/JSResources.properties deleted file mode 100644 index 2c86769..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/JSResources.properties +++ /dev/null @@ -1,21 +0,0 @@ - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF 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. - -password.mismatched=Passwords do not match. -email.mismatched=The emails are mismatching. -current.password.should.provided=You should provide the current password in order to change the password. -password.length=Your password must be at least 6 characters long. Try again. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/Resources.properties ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/Resources.properties b/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/Resources.properties deleted file mode 100644 index db962ba..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/org/apache/stratos/tenant/mgt/ui/i18n/Resources.properties +++ /dev/null @@ -1,73 +0,0 @@ - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF 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. - -submit.tenant=Submit Tenant -domain=Domain -tenant.id=Tenant ID -activate.deactivate=Activation Status -deactivate.account.msg=This tenant is active. You can deactivate this tenant from here. -activate.account.msg=This tenant is inactive. You can activate this tenant from here. -deactivate.account.btn=Deactivate -activate.account.btn=Activate -error.deactivating.activating.tenant=Error occurred in changing the activation status of the tenant. -domain.information=Domain Information -contact.details=Contact Details -admin.username=Admin Username -current.admin.password=Current Admin Password -new.admin.password=New Admin Password -new.admin.password.repeat=New Admin Password (Repeat) -admin.password=Admin Password -admin.password.repeat=Admin Password (Repeat) -govern.add_tenants.menu=Add New Tenant -govern.view_tenants.menu=View Tenants -overview=Overview -tenants.list=Tenants List -company.organization=Company/Organization -admin.contact=Admin Contact -edit=Edit -multitenancy=Multitenancy -added.successfully=You have successfully added a new tenant with domain: -updated.successfully=You have successfully updated the tenant with domain: -update.added.tenant=Update the just added/updated tenant -update.tenant=Update Tenant -add.new.tenant=Add a new tenant -register.new.organization=Register A New Organization -view.all.tenants=View all tenants -tenant.admin=Tenant Admin -tenant.description=Tenant Description -admin.fullname=Full Name -admin.firstname=First Name -admin.lastname=Last Name -admin.address=Address -admin.email=Email -admin.telephone=Telephone -admin.im=IM -admin.url=URL -self.registration=Registry Tenant -gaas=GaaS -gaas.register.a.new.tenant=Register A New Tenant -active=Active -theme.management=Theme Management -word.verification=Word Verification -captcha.message=Type the characters you see in the picture below. -created.date=Created Date -enter.tenant.domain=Enter the Tenant Domain -accept.eula=I have read and accepted the terms in the license agreement above. -usage.plan.information= Usage Plan Information -select.usage.plan.for.tenant=Select Usage Plan For Tenant -select.package.message=According to the selected plan, resources will be allocated to you.\n You can update or downgrade your plan later \n according to your requirements. -no.tenants.available=There are no tenants available \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/activate_tenant_ajaxprocessor.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/activate_tenant_ajaxprocessor.jsp b/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/activate_tenant_ajaxprocessor.jsp deleted file mode 100644 index 9141b64..0000000 --- a/components/org.apache.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/activate_tenant_ajaxprocessor.jsp +++ /dev/null @@ -1,59 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF 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. - --%> - -<%@ page import="org.apache.stratos.tenant.mgt.ui.clients.TenantServiceClient" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<script type="text/javascript" src="../admin/js/jquery.js"></script> -<script type="text/javascript" src="../admin/js/jquery.form.js"></script> -<script type="text/javascript" src="../dialog/js/jqueryui/jquery-ui.min.js"></script> - -<%--<carbon:jsi18n--%> - <%--resourceBundle="org.apache.stratos.tenant.mgt.ui.i18n.JSResources"--%> - <%--request="<%=request%>" />--%> - -<div id="middle"> -<% - String error = "Error in updating the tenant activation status."; - String tenantDomain = ""; - Boolean activated = (Boolean)session.getAttribute("isActivatedTenant"); - - TenantServiceClient serviceClient = new TenantServiceClient(config, session); - - try { - tenantDomain = request.getParameter("activatingDomain"); - - if(activated){ - serviceClient.deactivateTenant(tenantDomain); - } else if (!activated){ - serviceClient.activateTenant(tenantDomain); - } - - response.sendRedirect("../tenant-mgt/view_tenants.jsp"); - - } catch (Exception e) { - CarbonUIMessage uiMsg = new CarbonUIMessage(CarbonUIMessage.ERROR, e.getMessage(), e); - request.setAttribute(CarbonUIMessage.ID, uiMsg); - %> - <jsp:forward page="../admin/error.jsp"/> - <% - return; - } -%> - </div>
