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

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


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


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

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

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

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

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

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

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

        return subscription;
    }

    public static Customer getCurrentCustomer(UserRegistry userRegistry) throws Exception {
        int currentTenantId = userRegistry.getTenantId();
        TenantManager tenantManger = getRealmService().getTenantManager();
        Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
        BillingEngine billingEngine =
                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
        List<Customer> customers = billingEngine.getCustomersWithName(currentTenant.getDomain());
        if (customers == null || customers.size() == 0) {
            return null;
View Full Code Here

TOP

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

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.