Package org.wso2.carbon.user.api

Examples of org.wso2.carbon.user.api.RealmConfiguration


                    String user = CurrentSession.getUser();
                    UserRealm userRealm = CurrentSession.getUserRealm();

                    boolean adminUser = false;
                    // getting the realm config to get admin role, user details
                    RealmConfiguration realmConfig;
                    try {
                        realmConfig = userRealm.getRealmConfiguration();
                    } catch (UserStoreException e) {
                        String msg = "Failed to retrieve realm configuration.";
                        log.error(msg, e);
                        throw new RegistryException(msg, e);
                    }

                    // check is the user belongs to the admin role
                    try {
                        String[] roles = userRealm.getUserStoreManager().getRoleListOfUser(user);
                        String adminRoleName = realmConfig.getAdminRoleName();
                        if (RegistryUtils.containsString(adminRoleName, roles)) {
                            adminUser = true;
                        }

                    } catch (UserStoreException e) {

                        String msg = "Failed to get roles of the current user. " +
                                "User will be considered as non-admin user.\n" + e.getMessage();
                        log.error(msg, e);
                        adminUser = false;
                    }

                    // check if the user is the admin user
                    // TODO - do we really need to do this check?  Won't this user always be in the
                    // admin role?

                    String adminUsername = realmConfig.getAdminUserName();
                    if (adminUsername.equals(user)) {
                        adminUser = true;
                    }

View Full Code Here


                String user = CurrentSession.getUser();
                UserRealm userRealm = CurrentSession.getUserRealm();

                boolean adminUser = false;
                // getting the realm config to get admin role, user details
                RealmConfiguration realmConfig;
                try {
                    realmConfig = userRealm.getRealmConfiguration();
                } catch (UserStoreException e) {
                    String msg = "Failed to retrieve realm configuration.";
                    log.error(msg, e);
                    throw new RegistryException(msg, e);
                }

                // check is the user belongs to the admin role
                try {
                    String[] roles = userRealm.getUserStoreManager().getRoleListOfUser(user);
                    String adminRoleName = realmConfig.getAdminRoleName();
                    if (RegistryUtils.containsString(adminRoleName, roles)) {
                        adminUser = true;
                    }

                } catch (UserStoreException e) {

                    String msg = "Failed to get roles of the current user. " +
                            "User will be considered as non-admin user.\n" + e.getMessage();
                    log.error(msg, e);
                    adminUser = false;
                }

                // check if the user is the admin user
                // TODO - do we really need to do this check?  Won't this user always be in the
                // admin role?

                String adminUsername = realmConfig.getAdminUserName();
                if (adminUsername.equals(user)) {
                    adminUser = true;
                }

                String[] parts = commentPath.split(RegistryConstants.URL_SEPARATOR);
View Full Code Here

     * This is not called on ws.api startup or by any non-Idaas servers
     */
    public RealmConfiguration getRealmConfigForTenantToCreateRealm(
            RealmConfiguration bootStrapConfig, RealmConfiguration persistedConfig, int tenantId)
            throws UserStoreException {
        RealmConfiguration realmConfig;
        try {
                realmConfig = persistedConfig;
               // now this is Idaas
                Map<String, String> realmProps = realmConfig.getRealmProperties();
                Map<String, String> bootStrapProps = bootStrapConfig.getRealmProperties();
                realmProps.put(JDBCRealmConstants.URL, bootStrapProps.get(JDBCRealmConstants.URL));
                realmProps.put(JDBCRealmConstants.DRIVER_NAME, bootStrapProps.get(
                        JDBCRealmConstants.DRIVER_NAME));
                realmProps.put(JDBCRealmConstants.USER_NAME, bootStrapProps.get(
                        JDBCRealmConstants.USER_NAME));
                realmProps.put(JDBCRealmConstants.PASSWORD, bootStrapProps.get(
                        JDBCRealmConstants.PASSWORD));
                realmConfig.setTenantId(tenantId);

                if(log.isDebugEnabled()) {
                    OMElement omElement = RealmConfigXMLProcessor.serialize(realmConfig);
                    log.debug("Creating realm from **** " + omElement.toString());
                }
View Full Code Here

     * This is not called on ws.api startup.
     */
    public RealmConfiguration getRealmConfigForTenantToCreateRealm(
            RealmConfiguration bootStrapConfig, RealmConfiguration persistedConfig, int tenantId)
            throws UserStoreException {
        RealmConfiguration realmConfig;
        try {
            if (persistedConfig.getRealmClassName().equals(WSRealm.class.getName())) {
                realmConfig = persistedConfig;
            } else {
                realmConfig = bootStrapConfig.cloneRealmConfiguration();
                realmConfig.setTenantId(tenantId);
            }
            if (log.isDebugEnabled()) {
                OMElement omElement = RealmConfigXMLProcessor.serialize(realmConfig);
                log.debug("Creating realm from **** " + omElement.toString());
            }
View Full Code Here

    }

    public RealmConfiguration getRealmConfigForTenantToCreateRealmOnTenantCreation(
            RealmConfiguration bootStrapConfig, RealmConfiguration persistedConfig, int tenantId)
            throws UserStoreException{
        RealmConfiguration realmConfig;
        try {
            realmConfig = bootStrapConfig.cloneRealmConfiguration();
            realmConfig.setRealmClassName("org.wso2.carbon.um.ws.api.WSRealm");
           
            realmConfig.setAdminPassword(UUIDGenerator.getUUID());
            Map<String, String> realmProps = realmConfig.getRealmProperties();
            realmProps.remove(JDBCRealmConstants.URL);
            realmProps.remove(JDBCRealmConstants.DRIVER_NAME);
            realmProps.remove(JDBCRealmConstants.USER_NAME);
            realmProps.remove(JDBCRealmConstants.PASSWORD);
           
            realmConfig.setTenantId(tenantId);

            if (log.isDebugEnabled()) {
                OMElement omElement = RealmConfigXMLProcessor.serialize(realmConfig);
                log.debug("Creating realm from (On tenant creation)**** " + omElement.toString());
            }
View Full Code Here

    public RealmConfiguration getRealmConfigForTenantToPersist(RealmConfiguration bootStrapConfig,
                                                               TenantMgtConfiguration tenantMgtConfig,
                                                               Tenant tenantInfo, int tenantId)
            throws UserStoreException {
        RealmConfiguration realmConfig;
        try {
            realmConfig = bootStrapConfig.cloneRealmConfiguration();
            realmConfig.setAdminUserName(tenantInfo.getAdminName());
            realmConfig.setAdminPassword(UUIDGenerator.getUUID());
            Map<String, String> realmProps = realmConfig.getRealmProperties();
            realmProps.remove(JDBCRealmConstants.URL);
            realmProps.remove(JDBCRealmConstants.DRIVER_NAME);
            realmProps.remove(JDBCRealmConstants.USER_NAME);
            realmProps.remove(JDBCRealmConstants.PASSWORD);
            realmProps.remove(WSRemoteUserMgtConstants.SERVER_URL);
            realmProps.remove(WSRemoteUserMgtConstants.USER_NAME);
            realmProps.remove(WSRemoteUserMgtConstants.PASSWORD);
            realmProps.remove(WSRemoteUserMgtConstants.SINGLE_USER_AUTHENTICATION);
            realmProps.put("MultiTenantRealmConfigBuilder", IdaasWSRealmConfigBuilder.class.getName());
            realmConfig.setTenantId(tenantId);
            if (log.isDebugEnabled()) {
                OMElement omElement = RealmConfigXMLProcessor.serialize(realmConfig);
                log.debug("Saving RealmConfiguration **** " + omElement.toString());
            }

View Full Code Here

     * @throws Exception UserStoreException
     */
    public static UserStoreManager getUserStoreManager(Tenant tenant, int tenantId)
            throws Exception {
        // get the system registry for the tenant
        RealmConfiguration realmConfig = TenantMgtServiceComponent.getBootstrapRealmConfiguration();
        TenantMgtConfiguration tenantMgtConfiguration =
                TenantMgtServiceComponent.getRealmService().getTenantMgtConfiguration();
        UserRealm userRealm;
        try {
            MultiTenantRealmConfigBuilder builder = TenantMgtServiceComponent.getRealmService().
                    getMultiTenantRealmConfigBuilder();
            RealmConfiguration realmConfigToPersist = builder.
                    getRealmConfigForTenantToPersist(realmConfig, tenantMgtConfiguration,
                                                             tenant, tenantId);
            RealmConfiguration realmConfigToCreate =
                    builder.getRealmConfigForTenantToCreateRealmOnTenantCreation(
                            realmConfig, realmConfigToPersist, tenantId);
            userRealm = TenantMgtServiceComponent.getRealmService().
                    getUserRealm(realmConfigToCreate);
        } catch (UserStoreException e) {
View Full Code Here

        TenantRegistryDataDeletionUtil.deleteTenantRegistryData(tenantId, govMgr.getDataSource().getConnection());

    }

    public static void deleteTenantUMData(int tenantId) throws Exception {
        RealmConfiguration realmConfig = TenantMgtServiceComponent.getRealmService().
                getBootstrapRealmConfiguration();
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(realmConfig.getRealmProperty(JDBCRealmConstants.DRIVER_NAME));
        dataSource.setUrl(realmConfig.getRealmProperty(JDBCRealmConstants.URL));
        dataSource.setUsername(realmConfig.getRealmProperty(JDBCRealmConstants.USER_NAME));
        dataSource.setPassword(realmConfig.getRealmProperty(JDBCRealmConstants.PASSWORD));
        dataSource.setMaxActive(Integer.parseInt(realmConfig.getRealmProperty(JDBCRealmConstants.MAX_ACTIVE)));
        dataSource.setMinIdle(Integer.parseInt(realmConfig.getRealmProperty(JDBCRealmConstants.MIN_IDLE)));
        dataSource.setMaxWait(Integer.parseInt(realmConfig.getRealmProperty(JDBCRealmConstants.MAX_WAIT)));

        TenantUMDataDeletionUtil.deleteTenantUMData(tenantId, dataSource.getConnection());
    }
View Full Code Here

            if (tenantId == -1) {
                return false;
            }

            Tenant tenant = (Tenant) tenantManager.getTenant(tenantId);
            RealmConfiguration realmConfig = tenant.getRealmConfig();
            String value = realmConfig.getUserStoreProperties().get(
                            UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP);

            if (value == null) {
                throw new TenantManagementException(
                        "This domain has been already registered as a non-Google App domain");
View Full Code Here

            MultiTenantRealmConfigBuilder builder =
                    TenantMgtServiceComponent.getRealmService().getMultiTenantRealmConfigBuilder();
            TenantMgtConfiguration tenantMgtConfiguration =
                    TenantMgtServiceComponent.getRealmService().getTenantMgtConfiguration();
            RealmConfiguration bootStrapRealmConfig =
                    TenantMgtServiceComponent.getRealmService().getBootstrapRealmConfiguration();
            RealmConfiguration realmConfigToPersist =
                    builder.getRealmConfigForTenantToPersist(bootStrapRealmConfig,
                            tenantMgtConfiguration, tenant, -1);
            realmConfigToPersist.getUserStoreProperties().put(
                    UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP, GOOGLE_APPS_IDP_NAME);
            tenant.setRealmConfig(realmConfigToPersist);
            tenant.setAdminPassword(UUIDGenerator.getUUID());

            tenantId = tenantPersistor.persistTenant(tenant);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.api.RealmConfiguration

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.