Examples of Tenant


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

        if (userRegistry.getTenantId() != 0) {
            log.error("Security Alert! Non super tenant trying to create a tenant.");
            throw new Exception("Invalid data."); // obscure error message.
        }
        Tenant tenant = TenantMgtUtil.initializeTenant(tenantInfoBean);
        TenantPersistor persistor = TenantMgtServiceComponent.getTenantPersistor();
        // not validating the domain ownership, since created by super tenant
        persistor.persistTenant(tenant, false, tenantInfoBean.getSuccessKey(),
                                tenantInfoBean.getOriginatedService());
        TenantMgtUtil.addClaimsToUserStoreManager(tenant);
        // For the registration validation - mail for the tenant email address
        TenantMgtUtil.sendEmail(tenant, tenantInfoBean.getOriginatedService());

        // Notifies the super admin about the new tenant creation
        TenantMgtUtil.notifyTenantCreationToSuperAdmin(
                tenantInfoBean.getTenantDomain(),tenantInfoBean.getAdmin(),
                tenantInfoBean.getEmail());

        //adding the subscription entry
        try{
            boolean subscriptionAdded = TenantMgtUtil.addUsagePlan(tenantInfoBean);
            if(subscriptionAdded){
                log.debug("Subscription added successfully for the tenant: " + tenantInfoBean.getTenantDomain());
            }else{
                log.error("Could not add the subscription for tenant: " + tenantInfoBean.getTenantDomain());
            }
        }catch(Exception e){
            log.error("Error occurred while adding the subscription for tenant: " +
                    tenantInfoBean.getTenantDomain() + " " + e.getMessage(), e);   
        }


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

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

            String msg = "Error in retrieving the tenant id for the tenant domain: " +
                         tenantDomain + ".";
            log.error(msg);
            throw new Exception(msg, e);
        }
        Tenant tenant;
        try {
            tenant = (Tenant) tenantManager.getTenant(tenantId);
        } catch (UserStoreException e) {
            String msg = "Error in retrieving the tenant from the tenant manager.";
            log.error(msg);
View Full Code Here

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

        if (tenantInfoBean.getAdminPassword() != null
            && !tenantInfoBean.getAdminPassword().equals("")) {
            updatePassword = true;
        }

        Tenant tenant;
        try {
            tenant = (Tenant) tenantManager.getTenant(tenantId);
        } catch (UserStoreException e) {
            String msg = "Error in retrieving the tenant id for the tenant domain: " +
                         tenantDomain + ".";
            log.error(msg, e);
            throw new Exception(msg, e);
        }

        // filling the first and last name values
        if (tenantInfoBean.getFirstname() != null &&
            !tenantInfoBean.getFirstname().trim().equals("")) {
            try {
                CommonUtil.validateName(tenantInfoBean.getFirstname(), "First Name");
            } catch (Exception e) {
                String msg = "Invalid first name is provided.";
                log.error(msg, e);
                throw new Exception(msg, e);
            }
        }
        if (tenantInfoBean.getLastname() != null &&
            !tenantInfoBean.getLastname().trim().equals("")) {
            try {
                CommonUtil.validateName(tenantInfoBean.getLastname(), "Last Name");
            } catch (Exception e) {
                String msg = "Invalid last name is provided.";
                log.error(msg, e);
                throw new Exception(msg, e);
            }
        }
        Map<String, String> claimsMap = new HashMap<String, String>(); // map of claims
        claimsMap.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, tenantInfoBean.getFirstname());
        claimsMap.put(UserCoreConstants.ClaimTypeURIs.SURNAME, tenantInfoBean.getLastname());

        userStoreManager = TenantMgtUtil.getUserStoreManager(tenant, tenant.getId());
        userStoreManager.setUserClaimValues(tenantInfoBean.getAdmin(), claimsMap,
                                            UserCoreConstants.DEFAULT_PROFILE);

        // filling the email value
        if (tenantInfoBean.getEmail() != null && !tenantInfoBean.getEmail().equals("")) {
            // validate the email
            try {
                CommonUtil.validateEmail(tenantInfoBean.getEmail());
            } catch (Exception e) {
                String msg = "Invalid email is provided.";
                log.error(msg, e);
                throw new Exception(msg, e);
            }
            tenant.setEmail(tenantInfoBean.getEmail());
        }

        UserRealm userRealm = configSystemRegistry.getUserRealm();
        try {
            userStoreManager = userRealm.getUserStoreManager();
View Full Code Here

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

            String msg = "Tenant with the domain " + domainName + " doesn't exist.";
            log.error(msg);
            return false; // tenant doesn't exist
        }

        Tenant tenant = (Tenant) tenantManager.getTenant(tenantId);
        String email = tenant.getEmail();

        String adminNameFromUserStore = ClaimsMgtUtil.getAdminUserNameFromTenantId(
                TenantMgtServiceComponent.getRealmService(), tenantId);
        // Admin Name is included in the email, in case if the user has
        // forgotten that.
View Full Code Here

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

     */
    public static void notifyResetPassword(TenantInfoBean tenantInfoBean) throws Exception {
        TenantManager tenantManager = TenantMgtServiceComponent.getTenantManager();

        int tenantId = tenantInfoBean.getTenantId();
        Tenant tenant = (Tenant) tenantManager.getTenant(tenantId);
        String firstName = ClaimsMgtUtil.getFirstName(TenantMgtServiceComponent.getRealmService(),
                                                      tenant, tenant.getId());

        // load the mail configuration
        Map<String, String> userParams = new HashMap<String, String>();
        userParams.put("admin-name", tenantInfoBean.getAdmin());
        userParams.put("first-name", firstName);
View Full Code Here

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

public class TenantTestUtil {
    public static Tenant[] createTenant(RealmConfiguration realmConfig) throws Exception {
        Tenant[] arr = new Tenant[3];

        Tenant t1 = new Tenant();
        t1.setAdminName("admin");
        t1.setDomain("domain1");
        t1.setEmail("tenant1@domain1.com");
        t1.setRealmConfig(realmConfig);
        arr[0] = t1;

        Tenant t2 = new Tenant();
        t2.setAdminName("admin1");
        t2.setDomain("domain2");
        t2.setEmail("tenant2@domain2.com");
        t2.setRealmConfig(realmConfig);
        arr[1] = t2;

        Tenant t3 = new Tenant();
        t3.setAdminName("admin2");
        t3.setDomain("domain3");
        t3.setEmail("tenant3@domain3.com");
        t3.setRealmConfig(realmConfig);
        arr[2] = t3;

        return arr;
    }
View Full Code Here

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

        List<Tenant> tenants = new ArrayList<Tenant>();
        try {
            TenantManager tenantManager =
                    dataHolder.getRealmService().getTenantManager();
            for (ConfigurationContext tenantCfgCtx : tenantConfigContexts.values()) {
                Tenant tenant = (Tenant)tenantManager.getTenant(MultitenantUtils.getTenantId(tenantCfgCtx));
                tenants.add(tenant);
            }
        } catch (Exception e) {
            String msg = "Error occurred while getting active tenant list";
            log.error(msg, e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.