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

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


        Customer customer = invoice.getCustomer();

        try{
            TenantManager tenantManager = Util.getRealmService().getTenantManager();
            Tenant tenant = (Tenant) tenantManager.getTenant(customer.getId());
            String customerName =
                    ClaimsMgtUtil.getFirstName(Util.getRealmService(), tenant, customer.getId());
            if(customerName!=null){
                mailParameters.put("customer-name", customerName);
            }else{
View Full Code Here


import org.wso2.carbon.throttling.manager.tasks.Task;
import org.wso2.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(), tenant, tenantId));
            datatostore.put("email", contactEmail);
            datatostore.put("admin", 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());
            return true;
        } catch (Exception e) {
            // this is expected, as many users haven't given their fullnames
            // during their registration.
            String msg =
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(), tenant, 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(), tenant, 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();

        int indexOfDot = domainName.lastIndexOf(".");
        if (indexOfDot < 0) {
            String msg = "Invalid domain: " + domainName;
            log.error(msg);
View Full Code Here

        Customer customer = getCurrentCustomer(userRegistry);
        // if customer doesn't exist, we are making a one
        if (customer == null) {
            int currentTenantId = userRegistry.getTenantId();
            TenantManager tenantManger = getRealmService().getTenantManager();
            Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
            if (currentTenant == null || currentTenant.getDomain() == null) {
                String msg = "Error in getting the customer information.";
                throw new Exception(msg);
            }
            customer = new Customer();
            customer.setName(currentTenant.getDomain());
            customer.setEmail(currentTenant.getEmail());
            customer.setStartedDate(new Date());

            billingEngine.addCustomer(customer);
        }
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.