You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/07/12 09:51:42 UTC

[03/14] adding org.apache.stratos.account.mgt and org.apache.stratos.account.mgt.ui to components

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/AccountMgtService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/AccountMgtService.java b/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/AccountMgtService.java
new file mode 100644
index 0000000..14058d2
--- /dev/null
+++ b/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/AccountMgtService.java
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2005-2010, 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.apache.stratos.account.mgt.services;
+
+import org.wso2.carbon.core.AbstractAdmin;
+import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber;
+import org.wso2.carbon.registry.core.RegistryConstants;
+import org.wso2.carbon.registry.core.Resource;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.wso2.carbon.registry.core.utils.UUIDGenerator;
+import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
+import org.wso2.carbon.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.stratos.common.util.ClaimsMgtUtil;
+import org.wso2.carbon.stratos.common.util.CommonUtil;
+import org.wso2.carbon.tenant.mgt.util.TenantMgtUtil;
+import org.wso2.carbon.user.core.UserCoreConstants;
+import org.wso2.carbon.user.core.UserStoreException;
+import org.wso2.carbon.user.core.UserStoreManager;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.core.tenant.Tenant;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.account.mgt.beans.AccountInfoBean;
+import org.apache.stratos.account.mgt.util.Util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Account Management Service Class
+ */
+public class AccountMgtService extends AbstractAdmin {
+    private static final Log log = LogFactory.getLog(AccountMgtService.class);
+
+    /**
+     * Updates the contact email.
+     *
+     * @param contactEmail email
+     * @throws Exception, if update contact failed.
+     */
+    public void updateContact(String contactEmail) throws Exception {
+        EmailVerifcationSubscriber emailverifier = Util.getEmailVerificationService();
+
+        TenantManager tenantManager = Util.getTenantManager();
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+
+        Tenant tenant;
+        try {
+            tenant = (Tenant) tenantManager.getTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg = "Error in retrieving the tenant information for the tenant id: " +
+                    tenantId + ".";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+
+        // generating the confirmation key
+        String confirmationKey = UUIDGenerator.generateUUID();
+        UserRegistry superTenantSystemRegistry =
+                Util.getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
+        Resource resource;
+        String emailVerificationPath = StratosConstants.ADMIN_EMAIL_VERIFICATION_FLAG_PATH +
+                RegistryConstants.PATH_SEPARATOR + tenantId;
+        if (superTenantSystemRegistry.resourceExists(emailVerificationPath)) {
+            resource = superTenantSystemRegistry.get(emailVerificationPath);
+        } else {
+            resource = superTenantSystemRegistry.newResource();
+        }
+        resource.setContent(confirmationKey);
+        superTenantSystemRegistry.put(emailVerificationPath, resource);
+
+        try {
+            Map<String, String> datatostore = new HashMap<String, String>();
+            datatostore.put("first-name",
+                    ClaimsMgtUtil.getFirstName(Util.getRealmService(), tenantId));
+            datatostore.put("email", contactEmail);
+            datatostore.put("userName", tenant.getAdminName());
+            datatostore.put("tenantDomain", tenant.getDomain());
+            datatostore.put("confirmationKey", confirmationKey);
+            emailverifier.requestUserVerification(datatostore, Util.getEmailVerifierConfig());
+        } catch (Exception e) {
+            String msg = "Error in adding tenant, tenant domain: " + tenant.getDomain() + ".";
+            log.error(msg);
+            throw new Exception(msg, e);
+        }
+    }
+
+    /**
+     * gets the contact of the tenant admin
+     *
+     * @throws Exception, if getting the contact email address failed.
+     * @return, the contact email address
+     */
+    public String getContact() throws Exception {
+        TenantManager tenantManager = Util.getTenantManager();
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+        // get the tenant information from the tenant manager
+        Tenant tenant;
+        try {
+            tenant = (Tenant) tenantManager.getTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg = "Error in retrieving the tenant information for the tenant id: " +
+                    tenantId + ".";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        return tenant.getEmail();
+    }
+
+    /**
+     * Updates the fullname information
+     *
+     * @param accountInfoBean profile information stored in AccountInfoBean
+     * @return true, if updated successfully.
+     * @throws Exception UserStoreException.
+     */
+    public boolean updateFullname(AccountInfoBean accountInfoBean) throws Exception {
+        TenantManager tenantManager = Util.getTenantManager();
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+        // get the tenant information from the tenant manager
+        Tenant tenant;
+        try {
+            tenant = (Tenant) tenantManager.getTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg = "Error in retrieving the tenant information for the tenant id: " +
+                    tenantId + ".";
+            log.info(msg, e);
+            throw new Exception(msg, e);
+        }
+        RealmService realmService = Util.getRealmService();
+        try {
+            Map<String, String> claimsMap = new HashMap<String, String>();
+            claimsMap.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME,
+                    accountInfoBean.getFirstname());
+            claimsMap.put(UserCoreConstants.ClaimTypeURIs.SURNAME, accountInfoBean.getLastname());
+            UserStoreManager userStoreManager =
+                    (UserStoreManager) realmService.getTenantUserRealm(tenantId)
+                            .getUserStoreManager();
+            userStoreManager.setUserClaimValues(
+                    ClaimsMgtUtil.getAdminUserNameFromTenantId(realmService, tenantId),
+                    claimsMap, UserCoreConstants.DEFAULT_PROFILE);
+            log.info("FirstName: " + accountInfoBean.getFirstname() +
+                    " has been updated to the tenant admin " +
+                    ClaimsMgtUtil.getAdminUserNameFromTenantId(realmService, tenantId) + " of " +
+                    tenant.getDomain());
+            
+            //Notify tenant update to all listeners
+            TenantInfoBean tenantInfoBean = new TenantInfoBean();
+            tenantInfoBean.setTenantId(tenantId);
+            tenantInfoBean.setFirstname(accountInfoBean.getFirstname());
+            tenantInfoBean.setLastname(accountInfoBean.getLastname());
+            Util.alertTenantUpdate(tenantInfoBean);
+            
+            return true;
+        } catch (Exception e) {
+            // this is expected, as many users haven't given their fullnames
+            // during their registration.
+            String msg =
+                    "Error in updating the firstname: " + accountInfoBean.getFirstname() +
+                            " for the tenant admin: " +
+                            ClaimsMgtUtil.getAdminUserNameFromTenantId(realmService, tenantId);
+            log.info(msg);
+            throw new Exception(msg, e);
+        }
+    }
+
+    /**
+     * gets the profile information - saved as claims -
+     * currently saved claims are first name and last name - hence the profile so far is a fullname.
+     *
+     * @return AccountInfoBean - Currently depicts the fullname as an object.
+     * @throws Exception, UserStoreException
+     */
+    public AccountInfoBean getFullname() throws Exception {
+
+        String firstname = "", lastname = "";
+        TenantManager tenantManager = Util.getTenantManager();
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+        // get the tenant information from the tenant manager
+        Tenant tenant;
+        try {
+            tenant = (Tenant) tenantManager.getTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg = "Error in retrieving the tenant information for the tenant id: " +
+                    tenantId + ".";
+            log.info(msg, e);
+            throw new Exception(msg, e);
+        }
+
+        // getting the other parameters from the claims.
+        try {
+            firstname = ClaimsMgtUtil.getFirstName(Util.getRealmService(), tenantId);
+
+        } catch (Exception e) {
+            String msg = "Error in retrieving the firstname for the admin of the domain " +
+                    tenant.getDomain();
+            log.info(msg);
+        }
+        try {
+            lastname = ClaimsMgtUtil.getLastName(Util.getRealmService(), tenantId);
+        } catch (Exception e) {
+            // this is expected, as many users haven't given their lastnames
+            // during their registration.
+            String msg = "Error in retrieving the Lastname for the admin of the domain " +
+                    tenant.getDomain();
+            log.info(msg);
+        }
+
+        AccountInfoBean accountInfoBean = new AccountInfoBean();
+        accountInfoBean.setFirstname(firstname);
+        accountInfoBean.setLastname(lastname);
+        return accountInfoBean;
+    }
+
+
+    /**
+     * deactivates the tenant
+     *
+     * @throws Exception, if deactivating the tenant failed.
+     */
+    public void deactivate() throws Exception {
+        // The one who have a proper permission will be able to deactivate the tenant.
+        TenantManager tenantManager = Util.getTenantManager();
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+        try {
+            tenantManager.deactivateTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg = "Error in deactivating the tenant id: " + tenantId + ".";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+
+        //Notify tenant deactivation to Listeners
+        Util.alertTenantDeactivation(tenantId);
+    }
+
+    /**
+     * checks whether the domain is validated.
+     *
+     * @return true, if the domain has been validated.
+     * @throws Exception, if the domain validation failed.
+     */
+    public boolean isDomainValidated() throws Exception {
+        // first we will get the current domain name
+        TenantManager tenantManager = Util.getTenantManager();
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+        // get the tenant information from the tenant manager
+        Tenant tenant;
+        try {
+            tenant = (Tenant) tenantManager.getTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg = "Error in retrieving the tenant information for the tenant id: " +
+                    tenantId + ".";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        String domainName = tenant.getDomain();
+        TenantMgtUtil.validateDomain(domainName);
+
+        String domainValidationPath = StratosConstants.TENANT_DOMAIN_VERIFICATION_FLAG_PATH +
+                RegistryConstants.PATH_SEPARATOR + tenantId;
+        UserRegistry superTenantRegistry = Util.getGovernanceSystemRegistry(
+                MultitenantConstants.SUPER_TENANT_ID);
+        if (superTenantRegistry.resourceExists(domainValidationPath)) {
+            Resource validationFlagR = superTenantRegistry.get(domainValidationPath);
+            return "true".equals(validationFlagR.getProperty(domainName));
+        }
+        return false;
+    }
+
+    /**
+     * If the domain validation has been completed.
+     *
+     * @param validatedDomain the domain being validated.
+     * @param successKey      success key
+     * @return true, if the domain has been validated successfully.
+     * @throws Exception, if the domain validation failed.
+     */
+    public boolean finishedDomainValidation(
+            String validatedDomain, String successKey) throws Exception {
+        // create a flag on domain validation, so that we can move the content
+        // of the current domain name to the new validated domain name
+        if (!CommonUtil.validateDomainFromSuccessKey(Util.getGovernanceSystemRegistry(
+                MultitenantConstants.SUPER_TENANT_ID), validatedDomain, successKey)) {
+            String msg = "Domain: " + validatedDomain + " is not validated against successKey: " +
+                    successKey + ".";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+
+        // we keep an entry about domain validation here.
+
+        // first we will get the current domain name
+        UserRegistry registry = (UserRegistry) getGovernanceRegistry();
+        if (registry == null) {
+            // we can't continue without having a valid registry in the session
+            String msg = "Error in retrieving the registry for the login tenant.";
+            log.error(msg);
+            throw new Exception(msg);
+        }
+        int tenantId = registry.getTenantId();
+
+        // keep the domain validation path.
+
+        String domainValidationPath = StratosConstants.TENANT_DOMAIN_VERIFICATION_FLAG_PATH +
+                RegistryConstants.PATH_SEPARATOR + tenantId;
+        UserRegistry superTenantRegistry =
+                Util.getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
+        Resource validationFlagR = superTenantRegistry.newResource();
+        validationFlagR.setProperty(validatedDomain, "true");
+        superTenantRegistry.put(domainValidationPath, validationFlagR);
+
+        return true;
+    }
+
+    /**
+     * Check whether the domain is available.
+     *
+     * @param domainName domain name
+     * @return true, if the domain is available to register.
+     * @throws Exception, if the domain validation failed.
+     */
+    public boolean checkDomainAvailability(String domainName) throws Exception {
+        TenantManager tenantManager = Util.getTenantManager();
+        int tenantId = tenantManager.getTenantId(domainName);
+        return tenantId < 0;
+    }
+
+    /**
+     * check whether the email has been validated.
+     *
+     * @throws Exception, if the validation failed.
+     * @return, true if already validated.
+     */
+    public boolean isEmailValidated() throws Exception {
+        UserRegistry userRegistry = (UserRegistry) getGovernanceRegistry();
+        if (userRegistry.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no email validation step required for super tenant
+            return true;
+        }
+
+        String email = getContact();
+        UserRegistry superTenantSystemRegistry =
+                Util.getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
+        String emailVerificationPath = StratosConstants.ADMIN_EMAIL_VERIFICATION_FLAG_PATH +
+                RegistryConstants.PATH_SEPARATOR +
+                userRegistry.getTenantId();
+        if (!superTenantSystemRegistry.resourceExists(emailVerificationPath)) {
+            // the confirmation key should exist,otherwise fail registration
+            return false;
+        }
+        Resource resource = superTenantSystemRegistry.get(emailVerificationPath);
+
+        return "true".equals(resource.getProperty(email));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/EmailValidationService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/EmailValidationService.java b/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/EmailValidationService.java
new file mode 100644
index 0000000..b8fb75e
--- /dev/null
+++ b/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/services/EmailValidationService.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.account.mgt.services;
+
+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.stratos.common.beans.TenantInfoBean;
+import org.wso2.carbon.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.stratos.common.util.CommonUtil;
+import org.wso2.carbon.user.api.Tenant;
+import org.wso2.carbon.user.core.UserStoreException;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.account.mgt.internal.AccountMgtServiceComponent;
+import org.apache.stratos.account.mgt.util.Util;
+
+/**
+ * Email Validation Service
+ */
+public class EmailValidationService {
+    private static final Log log = LogFactory.getLog(EmailValidationService.class);
+
+    /**
+     * Proceed updating the contact email address
+     *
+     * @param domain          tenant domain
+     * @param email           email address
+     * @param confirmationKey confirmation key.
+     * @throws Exception, RegistryException.
+     */
+    public void proceedUpdateContact(String domain, String email, String confirmationKey)
+            throws Exception {
+
+        TenantManager tenantManager = Util.getTenantManager();
+        int tenantId;
+
+        try {
+            tenantId = tenantManager.getTenantId(domain);
+        } catch (UserStoreException e) {
+            String msg = "Error in adding tenant, tenant domain: " + domain + ".";
+            log.error(msg);
+            throw new RegistryException(msg, e);
+        }
+
+        UserRegistry superTenantSystemRegistry = Util.getGovernanceSystemRegistry(
+                MultitenantConstants.SUPER_TENANT_ID);
+        String emailVerificationPath =
+                StratosConstants.ADMIN_EMAIL_VERIFICATION_FLAG_PATH +
+                RegistryConstants.PATH_SEPARATOR + tenantId;
+        if (!superTenantSystemRegistry.resourceExists(emailVerificationPath)) {
+            // the confirmation key should exist,otherwise fail registraion
+            String msg = "The confirmationKey doesn't exist in service.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+        Resource resource = superTenantSystemRegistry.get(emailVerificationPath);
+        String actualConfirmationKey = null;
+        Object content = resource.getContent();
+        if (content instanceof String) {
+            actualConfirmationKey = (String) content;
+        } else if (content instanceof byte[]) {
+            actualConfirmationKey = new String((byte[]) content);
+        }
+
+        if (actualConfirmationKey == null || !actualConfirmationKey.equals(confirmationKey)) {
+            // validation will fail.
+            String msg = "The email confirmation key is not matching";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+
+        resource.setProperty(email, "true");
+
+        // now we will really update the tenant email
+        Tenant tenant;
+        try {
+            tenant = tenantManager.getTenant(tenantId);
+        } catch (UserStoreException e) {
+            String msg =
+                    "Error in retrieving the tenant information for the tenant id: " + tenantId +
+                    ".";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+
+        // If TenantActivation is moderated, the mail address associated with the validation link
+        // would not be the tenant email. Otherwise, the validation mail would be the tenant email.
+        if (!CommonUtil.isTenantActivationModerated()) {
+            tenant.setEmail(email);
+        }
+
+        try {
+            tenantManager.updateTenant(tenant);
+        } catch (UserStoreException e) {
+            String msg =
+                    "Error in updating the tenant information for the tenant id: " + tenantId + ".";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+
+        // activate the tenant on successful validation of the email, if it is not already activated.
+        if ("false".equals(resource.getProperty(StratosConstants.IS_EMAIL_VALIDATED))) {
+            tenantManager.activateTenant(tenantId);
+            // set the registry flag
+            resource.editPropertyValue(StratosConstants.IS_EMAIL_VALIDATED, "false", "true");
+
+            if (log.isDebugEnabled()) {
+                log.debug("Tenant : " + tenantId + " is activated after validating the " +
+                          "email of the tenant admin.");
+            }
+            
+            //Notify all the listeners that tenant has been activated for the first time
+            Util.alertTenantInitialActivation(tenantId);
+
+            //Activating the usage plan
+            try{
+                AccountMgtServiceComponent.getBillingService().activateUsagePlan(domain);
+            }catch(Exception e){
+                log.error("Error occurred while activating the usage plan for tenant: " + domain
+                        + " tenant Id: " + tenantId, e);
+            }
+
+        }
+        
+        //This is considered an update. Hence notify the update to all listeners
+        TenantInfoBean tenantInfoBean = new TenantInfoBean();
+        tenantInfoBean.setTenantId(tenantId);
+        tenantInfoBean.setTenantDomain(domain);
+        tenantInfoBean.setEmail(email);
+        Util.alertTenantUpdate(tenantInfoBean);
+
+        // update the registry
+        superTenantSystemRegistry.put(emailVerificationPath, resource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/util/Util.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/util/Util.java b/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/util/Util.java
new file mode 100644
index 0000000..1d03a3c
--- /dev/null
+++ b/components/org.apache.stratos.account.mgt/src/main/java/org/apache/stratos/account/mgt/util/Util.java
@@ -0,0 +1,173 @@
+/*
+ *  Copyright (c) 2005-2008, 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.apache.stratos.account.mgt.util;
+
+import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber;
+import org.wso2.carbon.email.verification.util.EmailVerifierConfig;
+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.stratos.common.beans.TenantInfoBean;
+import org.wso2.carbon.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.stratos.common.exception.StratosException;
+import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Util methods for AccountMgt
+ */
+public class Util {
+
+    private static final Log log = LogFactory.getLog(Util.class);
+
+    private static RegistryService registryService;
+    private static RealmService realmService;
+    private static EmailVerifcationSubscriber emailVerificationService = null;
+    private static EmailVerifierConfig emailVerfierConfig = null;
+    private static List<TenantMgtListener> tenantMgtListeners = new ArrayList<TenantMgtListener>();
+
+    public static synchronized void setRegistryService(RegistryService service) {
+        if (registryService == null) {
+            registryService = service;
+        }
+    }
+
+    
+    public static RealmService getRealmService() {
+        return realmService;
+    }
+
+
+    public static RegistryService getRegistryService() {
+        return registryService;
+    }
+
+    public static synchronized void setEmailVerificationService(EmailVerifcationSubscriber service) {
+        if (emailVerificationService == null) {
+            emailVerificationService = service;
+        }
+    }
+
+    public static EmailVerifcationSubscriber getEmailVerificationService() {
+        return emailVerificationService;
+    }
+
+
+    public static synchronized void setRealmService(RealmService service) {
+        if (realmService == null) {
+            realmService = service;
+        }
+    }
+
+
+    public static TenantManager getTenantManager() {
+        return realmService.getTenantManager();
+    }
+
+    public static UserRegistry getGovernanceSystemRegistry(int tenantId) throws RegistryException {
+        return registryService.getGovernanceSystemRegistry(tenantId);
+    }
+
+    public static HttpSession getRequestSession() throws RegistryException {
+        MessageContext messageContext = MessageContext.getCurrentMessageContext();
+        if (messageContext == null) {
+            String msg = "Could not get the user's session. Message context not found.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+
+        HttpServletRequest request =
+                (HttpServletRequest) messageContext.getProperty("transport.http.servletRequest");
+
+        return request.getSession();
+    }
+
+    public static void loadEmailVerificationConfig() {
+        String configXml = CarbonUtils.getCarbonConfigDirPath()+ File.separator
+                           + StratosConstants.EMAIL_CONFIG +File.separator +"email-update.xml";
+        emailVerfierConfig = org.wso2.carbon.email.verification.util.Util.loadeMailVerificationConfig(configXml);
+    }
+
+    public static EmailVerifierConfig getEmailVerifierConfig() {
+        return emailVerfierConfig;
+    }
+
+    public static void addTenantMgtListenerService(TenantMgtListener tenantMgtListener) {
+        tenantMgtListeners.add(tenantMgtListener);
+        sortTenantMgtListeners();
+    }
+
+    public static void removeTenantMgtListenerService(TenantMgtListener tenantMgtListener) {
+        tenantMgtListeners.remove(tenantMgtListener);
+        sortTenantMgtListeners();
+    }
+    
+    private static void sortTenantMgtListeners() {
+        Collections.sort(tenantMgtListeners, new Comparator<TenantMgtListener>() {
+            public int compare(TenantMgtListener o1, TenantMgtListener o2) {
+                return o1.getListenerOrder() - o2.getListenerOrder();
+            }
+        });
+    }
+    
+    public static void alertTenantRenames(int tenantId, String oldName, 
+                                          String newName) throws StratosException {
+
+        for (TenantMgtListener tenantMgtLister : tenantMgtListeners) {
+            tenantMgtLister.onTenantRename(tenantId, oldName, newName);
+        }
+    }
+    
+    public static void alertTenantDeactivation(int tenantId) throws StratosException {
+
+        for (TenantMgtListener tenantMgtLister : tenantMgtListeners) {
+            tenantMgtLister.onTenantDeactivation(tenantId);
+        }
+    }
+    
+    public static void alertTenantInitialActivation(int tenantId) throws StratosException {
+
+        for (TenantMgtListener tenantMgtLister : tenantMgtListeners) {
+            tenantMgtLister.onTenantInitialActivation(tenantId);
+        }
+    }
+    
+    public static void alertTenantUpdate(TenantInfoBean tenantInfoBean) throws StratosException {
+
+        for (TenantMgtListener tenantMgtLister : tenantMgtListeners) {
+            tenantMgtLister.onTenantUpdate(tenantInfoBean);
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..e399648
--- /dev/null
+++ b/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/component.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+  ~
+  ~  Licensed 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">
+    <ManagementPermissions>
+        <ManagementPermission>
+            <DisplayName>Configure</DisplayName>
+            <ResourceId>/permission/admin/configure</ResourceId>
+        </ManagementPermission>
+        <ManagementPermission>
+            <DisplayName>Account</DisplayName>
+            <ResourceId>/permission/admin/configure/account</ResourceId>
+        </ManagementPermission>
+    </ManagementPermissions>
+</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..a5deded
--- /dev/null
+++ b/components/org.apache.stratos.account.mgt/src/main/resources/META-INF/services.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright 2006 The Apache Software Foundation.
+ !
+ ! Licensed 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.
+ !-->
+<serviceGroup>
+
+    <service name="AccountMgtService" scope="transportsession">
+        <transports>
+            <transport>https</transport>
+        </transports>
+        <parameter name="ServiceClass" locked="false">
+            org.apache.stratos.account.mgt.services.AccountMgtService
+        </parameter>
+
+        <operation name="updateContact">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="getContact">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="updateFullname">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="getFullname">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="deactivate">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="isDomainValidated">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="finishedDomainValidation">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="checkDomainAvailability">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+
+        <operation name="isEmailValidated">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/configure/account</parameter>
+        </operation>
+        <parameter name="adminService" locked="true">true</parameter>
+    </service>
+
+    <service name="EmailValidationService" scope="transportsession">
+        <transports>
+            <transport>https</transport>
+        </transports>
+        <parameter name="ServiceClass" locked="false">
+            org.apache.stratos.account.mgt.services.EmailValidationService
+        </parameter>
+
+        <operation name="proceedUpdateContact">
+        </operation>
+    </service>
+
+    <parameter name="hiddenService" locked="true">true</parameter>
+
+</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/pom.xml b/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/pom.xml
deleted file mode 100644
index 15619fc..0000000
--- a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.wso2.carbon</groupId>
-        <artifactId>account-mgt-parent</artifactId>
-        <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelorg.apache.stratos.account.mgt.uiwso2.carbon.account.mgt.ui</artifactId>
-    <version>2.1.0</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Account Managment - User Interface</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.wso2.carbon.account.mgt.ui.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.tenant.mgt.stub.*; version="${carbon.platform.package.import.version.range}",
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.wso2.carbon.account.mgt.stub.*; version="${carbon.platform.package.import.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                        <Carbon-Component>UIBundle</Carbon-Component>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.account.mgt.stub</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.tenant.mgt.stub</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.json.wso2</groupId>
-          <artifactId>json</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common.stub</artifactId>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java b/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java
deleted file mode 100644
index 7f944df..0000000
--- a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, 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.account.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.account.mgt.stub.beans.xsd.AccountInfoBean;
-import org.wso2.carbon.account.mgt.stub.services.AccountMgtServiceStub;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class AccountMgtClient {
-    private static final Log log = LogFactory.getLog(AccountMgtClient.class);
-
-    private AccountMgtServiceStub stub;
-    private String epr;
-
-    public AccountMgtClient(String cookie, String backendServerURL,
-            ConfigurationContext configContext) throws RegistryException {
-
-        epr = backendServerURL + "AccountMgtService";
-
-        try {
-            stub = new AccountMgtServiceStub(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 AccountMgt service client.";
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public AccountMgtClient(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);
-        epr = backendServerURL + "AccountMgtService";
-
-        try {
-            stub = new AccountMgtServiceStub(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 AccountMgt service client.";
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public void updateContact(String contactEmail) throws RegistryException {
-        try {
-            stub.updateContact(contactEmail);
-        } catch (Exception e) {
-            String msg = "Failed to update contact.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public String getContact() throws RegistryException {
-        try {
-            return stub.getContact();
-        } catch (Exception e) {
-            String msg = "Failed to get contact.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-   public boolean updateFullname(AccountInfoBean fullname) throws RegistryException {
-        try {
-            return stub.updateFullname(fullname);
-        } catch (Exception e) {
-            String msg = "Failed to update Fullname.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public AccountInfoBean getFullname() throws RegistryException {
-        try {
-            return stub.getFullname();
-        } catch (Exception e) {
-            String msg = "Failed to get administrator full name.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public void deactivate() throws RegistryException {
-        try {
-            stub.deactivate();
-        } catch (Exception e) {
-            String msg = "Failed to deactivate.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public boolean isDomainValidated() throws RegistryException {
-        try {
-            return stub.isDomainValidated();
-        } catch (Exception e) {
-            String msg = "Failed to check the domain validation.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public boolean finishedDomainValidation(String validatedDomain, String successKey)
-            throws RegistryException {
-        try {
-            return stub.finishedDomainValidation(validatedDomain, successKey);
-        } catch (Exception e) {
-            String msg = "Failed to finish the domain validation.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public boolean checkDomainAvailability(String domainName) throws RegistryException {
-        try {
-            return stub.checkDomainAvailability(domainName);
-        } catch (Exception e) {
-            String msg = "Failed to finish the domain availability.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public boolean isEmailValidated() throws RegistryException {
-        try {
-            return stub.isEmailValidated();
-        } catch (Exception e) {
-            String msg = "Failed to check the email validation.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java b/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java
deleted file mode 100644
index 20aeb8d..0000000
--- a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, 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.account.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.account.mgt.stub.services.EmailValidationServiceStub;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class EmailValidationClient {
-     private static final Log log = LogFactory.getLog(EmailValidationClient.class);
-
-    private EmailValidationServiceStub stub;
-    private String epr;
-
-    public EmailValidationClient(
-            String cookie, String backendServerURL, ConfigurationContext configContext)
-            throws RegistryException {
-
-        epr = backendServerURL + "EmailValidationService";
-
-        try {
-            stub = new EmailValidationServiceStub(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 EmailValidationService service client.";
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public EmailValidationClient(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);
-        epr = backendServerURL + "EmailValidationService";
-
-        try {
-            stub = new EmailValidationServiceStub(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 EmailValidationService service client.";
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public void proceedUpdateContact(String domain, String email, String confirmationKey) throws RegistryException {
-        try {
-            stub.proceedUpdateContact(domain, email, confirmationKey);
-        } catch (Exception e) {
-            String msg = "Failed to proceed update contacts.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java b/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java
deleted file mode 100644
index adc1576..0000000
--- a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*<!--
-~ Copyright (c) 2005-2010, 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.account.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.json.JSONArray;
-import org.json.JSONObject;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.stratos.common.packages.stub.PackageInfoServiceStub;
-import org.wso2.carbon.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/incubator-stratos/blob/e841de9d/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java b/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java
deleted file mode 100644
index f5970ca..0000000
--- a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, 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.account.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.account.mgt.stub.services.BillingDataAccessServiceStub;
-import org.wso2.carbon.account.mgt.stub.services.beans.xsd.Subscription;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class UsagePlanClient {
-    private BillingDataAccessServiceStub stub;
-    private static final Log log = LogFactory.getLog(UsagePlanClient.class);
-
-    public UsagePlanClient(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 + "BillingDataAccessService";
-
-        try {
-            stub = new BillingDataAccessServiceStub(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 boolean updateUsagePlan(String usagePlanName) {
-        try {
-            stub.changeSubscriptionByTenant(usagePlanName);
-        } catch (Exception e) {
-            return false;
-        }
-        return true;
-    }
-
-    public String getUsagePlanName(String tenantDomain) throws Exception{
-        Subscription subscription;
-        try {
-            subscription=stub.getActiveSubscriptionOfCustomerByTenant();
-            if(subscription!=null){
-                return subscription.getSubscriptionPlan();
-            } else {
-                return "";
-            }
-        } catch (Exception e) {
-            String msg = "Error occurred while getting the usage plan for tenant: " + tenantDomain;
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-    }
-
-    public boolean deactivateActiveUsagePlan(String tenantDomain){
-        log.info("Deactivating tenant domain: " + tenantDomain);
-        boolean deactivated = false;
-        try{
-            deactivated = stub.deactivateActiveSubscriptionByTenant();
-            if(deactivated){
-                log.info("Active subscription deactivated after deactivating the tenant: " + tenantDomain);
-            }
-        }catch (Exception e){
-            log.error("Error occurred while deactivating active subscription of: " +
-                        tenantDomain + " " + e.getMessage(), e);
-        }
-
-        return deactivated;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e841de9d/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java b/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java
deleted file mode 100644
index 6c263ae..0000000
--- a/components/stratos/account-mgt/org.apache.stratos.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, 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.account.mgt.ui.utils;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.account.mgt.stub.beans.xsd.AccountInfoBean;
-import org.wso2.carbon.account.mgt.ui.clients.AccountMgtClient;
-import org.wso2.carbon.account.mgt.ui.clients.UsagePlanClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.StringReader;
-import java.util.Iterator;
-
-public class Util {
-    private static final Log log = LogFactory.getLog(Util.class);
-    
-    public static HttpServletRequest readIntermediateData(HttpServletRequest request,String data){
-        try{
-            XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(data));
-            StAXOMBuilder builder = new StAXOMBuilder(parser);
-            OMElement documentElement =  builder.getDocumentElement();
-            Iterator it = documentElement.getChildElements();
-            while(it.hasNext()){
-                OMElement element = (OMElement)it.next();
-                if ("admin".equals(element.getLocalName())) {
-                    request.setAttribute("admin",element.getText());
-                } else if ("email".equals(element.getLocalName())) {
-                    request.setAttribute("email",element.getText());
-                } else if ("tenantDomain".equals(element.getLocalName())
-                           && request.getAttribute("tenantDomain") == null) {
-                    request.setAttribute("tenantDomain",element.getText());
-                } else if ("confirmationKey".equals(element.getLocalName())) {
-                    request.setAttribute("confirmationKey",element.getText());
-                }
-            }
-        }catch(Exception e){
-            log.error("Error parsing xml",e);
-        }
-        return request;
-    }
-
-    public static boolean updateFullname(
-            HttpServletRequest request,
-            ServletConfig config,
-            HttpSession session) throws Exception {
-
-        AccountInfoBean accountInfoBean = new AccountInfoBean();
-        String firstname = "", lastname = "";
-        try {
-            firstname = request.getParameter("firstname");
-            lastname = request.getParameter("lastname");
-            accountInfoBean.setFirstname(firstname);
-            accountInfoBean.setLastname(lastname);
-            AccountMgtClient client = new AccountMgtClient(config, session);
-            return client.updateFullname(accountInfoBean);
-        } catch (Exception e) {
-            String msg = "Failed to update tenant with firstname: " + firstname;
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-    }
-    public static String getUsagePlanName(ServletConfig config,
-                                           HttpSession session) throws Exception {
-        try{
-            String tenantDomain=(String)session.getAttribute("tenantDomain");
-            UsagePlanClient client=new UsagePlanClient(config, session);
-            return client.getUsagePlanName(tenantDomain);         
-        }
-        catch (Exception e){
-            String msg = "Failed to get usage plan for tenant";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-    }
-
-    public static boolean updateUsagePlan( HttpServletRequest request, ServletConfig config,
-                                           HttpSession session) throws Exception {
-        boolean updated = false;
-        String tenantDomain="";
-        try{
-            tenantDomain=(String)session.getAttribute("tenantDomain");
-            String usagePlanName=(String)request.getParameter("selectedUsagePlan");
-            UsagePlanClient client=new UsagePlanClient(config, session);
-            updated = client.updateUsagePlan(usagePlanName);
-        }
-       catch (Exception e){
-            String msg = "Failed to update the usage plan for tenant: " + tenantDomain;
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        return updated;
-    }
-    
-}