Package org.wso2.carbon.user.core.tenant

Examples of org.wso2.carbon.user.core.tenant.Tenant


    public static Customer getCurrentBillingCustomer(int tenantId) throws RegistryException {
        // get the host name of the current domain
        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            return null;
        }
        Tenant tenant;
        try {
            tenant = (Tenant) realmService.getTenantManager().getTenant(tenantId);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            String msg = "Error in getting the realm Information.";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        if (tenant == null) {
            return null;
        }
        String customerName = tenant.getDomain();
        BillingEngine billingEngine =
                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
        Customer customer;
        try {
            if (billingEngine != null) {
View Full Code Here


import org.apache.stratos.throttling.manager.tasks.Task;
import org.apache.carbon.throttling.test.utils.BaseTestCase;

public class ThrottlingTest extends BaseTestCase {
    public void testLimitResourceSizeRules() throws Exception {
        Tenant tenant = new Tenant();
        tenant.setAdminName("admin");
        tenant.setDomain("abc1.com");
        tenant.setAdminPassword("admin");
        tenant.setEmail("admin@abc1.com");
        tenant.setActive(true);

        int tenantId = realmService.getTenantManager().addTenant(tenant);
        realmService.getTenantManager().activateTenant(tenantId);
        registry = registryService.getGovernanceUserRegistry("admin", tenantId);
View Full Code Here

        }
    }

    public void testBandwidthRules() throws Exception {

        Tenant tenant = new Tenant();
        tenant.setAdminName("admin");
        tenant.setDomain("abc2.com");
        tenant.setAdminPassword("admin");
        tenant.setEmail("admin@abc2.com");
        tenant.setActive(true);

        int tenantId = realmService.getTenantManager().addTenant(tenant);
        realmService.getTenantManager().activateTenant(tenantId);
        registry = registryService.getGovernanceUserRegistry("admin", tenantId);
View Full Code Here

        }
    }

    public void testDBVolume() throws Exception {

        Tenant tenant = new Tenant();
        tenant.setAdminName("admin");
        tenant.setDomain("abc3.com");
        tenant.setAdminPassword("admin");
        tenant.setEmail("admin@abc3.com");
        tenant.setActive(true);

        int tenantId = realmService.getTenantManager().addTenant(tenant);
        realmService.getTenantManager().activateTenant(tenantId);
        registry = registryService.getGovernanceUserRegistry("admin", tenantId);
View Full Code Here

            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);
        }
    }
View Full Code Here

            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();
    }
View Full Code Here

            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());
View Full Code Here

            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);
View Full Code Here

            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(
View Full Code Here

            throw new Exception(msg, e);
        }
        String tenantDomain = tenantInfoBean.getTenantDomain();
        TenantMgtUtil.validateDomain(tenantDomain);
        checkIsSuperTenantInvoking();
        Tenant tenant = TenantMgtUtil.initializeTenant(tenantInfoBean);
        TenantPersistor persistor = new TenantPersistor();
        // not validating the domain ownership, since created by super tenant
        int tenantId = persistor.persistTenant(tenant, false, tenantInfoBean.getSuccessKey(),
                                tenantInfoBean.getOriginatedService(),false);
        tenantInfoBean.setTenantId(tenantId);
       
        TenantMgtUtil.addClaimsToUserStoreManager(tenant);
       
        notifyTenantAddition(tenantInfoBean);
        //adding the subscription entry
        /*try {
            if (TenantMgtServiceComponent.getBillingService() != null) {
                TenantMgtServiceComponent.getBillingService().
                        addUsagePlan(tenant, tenantInfoBean.getUsagePlan());
                if (log.isDebugEnabled()) {
                    log.debug("Subscription added successfully for the tenant: " +
                            tenantInfoBean.getTenantDomain());
                }
            }
        } catch (Exception e) {
            String msg = "Error occurred while adding the subscription for tenant: " + tenantDomain;
            log.error(msg, e);
        }*/

        // For the super tenant tenant creation, tenants are always activated as they are created.
        TenantMgtUtil.activateTenantInitially(tenantInfoBean, tenantId);

        return TenantMgtUtil.prepareStringToShowThemeMgtPage(tenant.getId());
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.core.tenant.Tenant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.