Package org.wso2.carbon.user.api

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


            OMElement documentElement = builder.getDocumentElement();

            realmElement = documentElement.getFirstChildWithName(new QName(
                    UserCoreConstants.RealmConfig.LOCAL_NAME_REALM));

            RealmConfiguration realmConfig = buildRealmConfiguration(realmElement);

            if (inStream != null) {
                inStream.close();
            }
            return realmConfig;
View Full Code Here


        }

    }

    public RealmConfiguration buildRealmConfiguration(OMElement realmElem) {
        RealmConfiguration realmConfig = null;
        String userStoreClass = null;
        String authorizationManagerClass = null;
        String adminRoleName = null;
        String adminUserName = null;
        String adminPassword = null;
        String everyOneRoleName = null;
        String realmClass = null;
        Map<String, String> userStoreProperties = null;
        Map<String, String> authzProperties = null;
        Map<String, String> realmProperties = null;  
        boolean passwordsExternallyManaged = false;

    realmClass = (String) realmElem.getAttributeValue(new QName(
        UserCoreConstants.RealmConfig.ATTR_NAME_CLASS));
       
        OMElement mainConfig = realmElem.getFirstChildWithName(new QName(
                UserCoreConstants.RealmConfig.LOCAL_NAME_CONFIGURATION));
        realmProperties = getChildPropertyElements(mainConfig, secretResolver);
        String dbUrl = constructDatabaseURL(realmProperties.get(JDBCRealmConstants.URL));
        realmProperties.put(JDBCRealmConstants.URL, dbUrl);
       
        OMElement adminUser = mainConfig.getFirstChildWithName(new QName(
                UserCoreConstants.RealmConfig.LOCAL_NAME_ADMIN_USER));
        adminUserName = adminUser.getFirstChildWithName(
                new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_USER_NAME)).getText();
        adminPassword = adminUser.getFirstChildWithName(
                new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_PASSWORD)).getText();
        if (secretResolver != null && secretResolver.isInitialized() &&
                secretResolver.isTokenProtected("UserManager.AdminUser.Password")) {
            adminPassword = secretResolver.resolve("UserManager.AdminUser.Password");
        }
        adminRoleName = mainConfig.getFirstChildWithName(
                new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_ADMIN_ROLE)).getText();
        everyOneRoleName = mainConfig.getFirstChildWithName(
                new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_EVERYONE_ROLE)).getText();

        OMElement usaConfig = realmElem.getFirstChildWithName(new QName(
                UserCoreConstants.RealmConfig.LOCAL_NAME_USER_STORE_MANAGER));
        userStoreClass = usaConfig.getAttributeValue(new QName(
                UserCoreConstants.RealmConfig.ATTR_NAME_CLASS));
  userStoreProperties = getChildPropertyElements(usaConfig, secretResolver);
              
        String sIsPasswordExternallyManaged = userStoreProperties
                .get(UserCoreConstants.RealmConfig.LOCAL_PASSWORDS_EXTERNALLY_MANAGED);

        if (null != sIsPasswordExternallyManaged && !sIsPasswordExternallyManaged.trim().equals("")) {
            passwordsExternallyManaged = Boolean.parseBoolean(sIsPasswordExternallyManaged);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("External password management is disabled.");
            }
        }

        OMElement authzConfig = realmElem.getFirstChildWithName(new QName(
                UserCoreConstants.RealmConfig.LOCAL_NAME_ATHZ_MANAGER));
        authorizationManagerClass = authzConfig.getAttributeValue(new QName(
                UserCoreConstants.RealmConfig.ATTR_NAME_CLASS));
        authzProperties = getChildPropertyElements(authzConfig, null);

        realmConfig = new RealmConfiguration();
        realmConfig.setRealmClassName(realmClass);
        realmConfig.setUserStoreClass(userStoreClass);
        realmConfig.setAuthorizationManagerClass(authorizationManagerClass);
        realmConfig.setAdminRoleName(adminRoleName);
        realmConfig.setAdminUserName(adminUserName);
        realmConfig.setAdminPassword(adminPassword);
        realmConfig.setEveryOneRoleName(everyOneRoleName);
        realmConfig.setUserStoreProperties(userStoreProperties);
        realmConfig.setAuthzProperties(authzProperties);
        realmConfig.setRealmProperties(realmProperties);   
        realmConfig.setPasswordsExternallyManaged(passwordsExternallyManaged);
       
        if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST) == null) {
            realmConfig.getUserStoreProperties().put(
                    UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST,
                    UserCoreConstants.RealmConfig.PROPERTY_VALUE_DEFAULT_MAX_COUNT);
        }

        if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY) == null) {
            realmConfig.getUserStoreProperties().put(
                    UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY,
                    UserCoreConstants.RealmConfig.PROPERTY_VALUE_DEFAULT_READ_ONLY);
        }
       
        return realmConfig;
View Full Code Here

        if (userRealm != null) {
            return userRealm;
        }
        try {
          if (tenantManager.getTenant(tenantId) != null) {
              RealmConfiguration tenantRealmConfig = (RealmConfiguration) tenantManager.getTenant(
                          tenantId).getRealmConfig();
                  userRealm = initializeRealm(tenantRealmConfig, tenantId);
                  synchronized (this) {
                      userRealmMap.put(Integer.valueOf(tenantId), (UserRealm) userRealm);
                  }
View Full Code Here

        synchronized (loadlock) {
            if (isEmailUserName == null) {
                try {
                    if (realmService != null) {
                        UserRealm realm = (UserRealm)realmService.getBootstrapRealm();
                        RealmConfiguration realmConfig = realm.getRealmConfiguration();

                        if (isCrossTenantUniqueUserName == null) {
                            String isUnique = realmConfig
                                    .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USERNAME_UNIQUE);
                            if ("true".equals(isUnique)) {
                                isCrossTenantUniqueUserName = true;
                            } else {
                                isCrossTenantUniqueUserName = false;
                            }
                        }

                        if (isEmailUserName == null) {
                            String isEmail = realmConfig
                                    .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_IS_EMAIL_USERNAME);
                            if ("true".equals(isEmail)) {
                                isEmailUserName = true;
                            } else {
                                isEmailUserName = false;
                            }
                        }

                        if (domainCalculation == null) {
                            domainCalculation = realmConfig
                                    .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_CALCULATION);
                            if (domainCalculation == null) {
                                domainCalculation = UserCoreConstants.RealmConfig.PROPERTY_VALUE_DOMAIN_CALCULATION_DEFAULT;
                            }
                        }
View Full Code Here

                    new RealmUnawareRegistryCoreServiceComponent();
            comp.setRealmService(ctx.getRealmService());
            comp.registerBuiltInHandlers(embeddedRegistryService);
           
            // get the realm config to retrieve admin username, password
            RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
            registry = embeddedRegistryService.getUserRegistry(
                realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
        } catch (RegistryException e) {
                fail("Failed to initialize the registry. Caused by: " + e.getMessage());
        }
    }
View Full Code Here

        if (!isDomainAvailable) {
            throw new Exception("Domain is not available to register");
        }

        RealmService realmService = TenantMgtCoreServiceComponent.getRealmService();
        RealmConfiguration realmConfig = realmService.getBootstrapRealmConfiguration();
        TenantMgtConfiguration tenantMgtConfiguration = realmService.getTenantMgtConfiguration();
        MultiTenantRealmConfigBuilder builder =
                                                TenantMgtCoreServiceComponent.getRealmService()
                                                                             .
                                                                              getMultiTenantRealmConfigBuilder();
        RealmConfiguration realmConfigToPersist =
                builder.getRealmConfigForTenantToPersist(realmConfig, tenantMgtConfiguration,
                                                         tenant,
                                                         -1);
        tenant.setRealmConfig(realmConfigToPersist);
        tenantId = addTenant(tenant);
View Full Code Here

     */
    private void validateAdminUserName(Tenant tenant) throws Exception {
        UserRealm tenantZeroUserRealm =
                                        TenantMgtCoreServiceComponent.getRealmService().
                                                                      getBootstrapRealm();
        RealmConfiguration realmConfig =
                                         TenantMgtCoreServiceComponent.getBootstrapRealmConfiguration();
        String uniqueAcrossTenants =
                                     realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USERNAME_UNIQUE);
        if ("true".equals(uniqueAcrossTenants)) {
            try {
                if (tenantZeroUserRealm.getUserStoreManager().isExistingUser(tenant.getAdminName())) {
                    throw new Exception("User name : " + tenant.getAdminName() +
                                        " exists in the system. " +
View Full Code Here

            return;
        }

        try {
            AuthorizationManager accessControlAdmin = userRealm.getAuthorizationManager();
            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);
            }

            String everyoneRole = realmConfig.getEveryOneRoleName();

            accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.GET);
            accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.PUT);
            accessControlAdmin.denyRole(everyoneRole, path, ActionConstants.DELETE);
            accessControlAdmin.denyRole(everyoneRole, path, AccessControlConstants.AUTHORIZE);
View Full Code Here

        creator.createRegistryDatabase();

        realm = new DefaultRealm();
        InputStream inStream = this.getClass().getClassLoader().getResource(
                PersonManagerImplTest.JDBC_TEST_USERMGT_XML).openStream();
        RealmConfiguration realmConfig = TestRealmConfigBuilder
                .buildRealmConfigWithJDBCConnectionUrl(inStream, TEST_URL);
        realm.init(realmConfig, ClaimTestUtil.getClaimTestData(), ClaimTestUtil
                .getProfileTestData(), 0);

    }
View Full Code Here

    public static final String JDBC_URL_PROPERTY_NAME = "url";

    public static RealmConfiguration buildRealmConfigWithJDBCConnectionUrl(InputStream inStream,
            String connectionUrl) throws UserStoreException {
        RealmConfigXMLProcessor builder = new RealmConfigXMLProcessor();
        RealmConfiguration realmConfig = builder.buildRealmConfiguration(inStream);
        Map<String, String> map = realmConfig.getRealmProperties();
        map.put(JDBC_URL_PROPERTY_NAME, connectionUrl);
        return realmConfig;
    }
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.