当前位置: 首页>>代码示例>>Java>>正文


Java RealmConfiguration.getUserStoreProperty方法代码示例

本文整理汇总了Java中org.wso2.carbon.user.api.RealmConfiguration.getUserStoreProperty方法的典型用法代码示例。如果您正苦于以下问题:Java RealmConfiguration.getUserStoreProperty方法的具体用法?Java RealmConfiguration.getUserStoreProperty怎么用?Java RealmConfiguration.getUserStoreProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.user.api.RealmConfiguration的用法示例。


在下文中一共展示了RealmConfiguration.getUserStoreProperty方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPasswordConformanceRegularExpression

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
/**
 * Gets the regular expression which defines the format of the service principle, password.
 *
 * @return Regular expression.
 * @throws DirectoryServerManagerException If unable to get RealmConfiguration.
 */
public String getPasswordConformanceRegularExpression() throws DirectoryServerManagerException {

    try {
        RealmConfiguration userStoreConfigurations = this.getUserRealm().getRealmConfiguration();
        if (userStoreConfigurations != null) {
            String passwordRegEx = userStoreConfigurations.getUserStoreProperty(
                    LDAPServerManagerConstants.SERVICE_PASSWORD_REGEX_PROPERTY);
            if (passwordRegEx == null) {
                return LDAPServerManagerConstants.DEFAULT_PASSWORD_REGULAR_EXPRESSION;
            } else {
                log.info("Service password format is " + passwordRegEx);
                return passwordRegEx;
            }
        }
    } catch (UserStoreException e) {
        log.error("Unable to retrieve service password format.", e);
        throw new DirectoryServerManagerException("Unable to retrieve service password format.", e);
    }

    return LDAPServerManagerConstants.DEFAULT_PASSWORD_REGULAR_EXPRESSION;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:DirectoryServerManager.java

示例2: getServiceNameConformanceRegularExpression

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
/**
 * Gets the regular expression which defines the format of the service principle.
 * Current we use following like format,
 * ftp/localhost
 *
 * @return Service principle name format as a regular expression.
 * @throws DirectoryServerManagerException If unable to retrieve RealmConfiguration.
 */
public String getServiceNameConformanceRegularExpression() throws DirectoryServerManagerException {

    try {
        RealmConfiguration userStoreConfigurations = this.getUserRealm().getRealmConfiguration();
        if (userStoreConfigurations != null) {
            String serviceNameRegEx = userStoreConfigurations.getUserStoreProperty(
                    LDAPServerManagerConstants.SERVICE_PRINCIPLE_NAME_REGEX_PROPERTY);
            if (serviceNameRegEx == null) {
                return LDAPServerManagerConstants.DEFAULT_SERVICE_NAME_REGULAR_EXPRESSION;
            } else {
                log.info("Service name format is " + serviceNameRegEx);
                return serviceNameRegEx;
            }
        }
    } catch (UserStoreException e) {
        log.error("Unable to retrieve service name format.", e);
        throw new DirectoryServerManagerException("Unable to retrieve service name format.", e);
    }

    return LDAPServerManagerConstants.DEFAULT_SERVICE_NAME_REGULAR_EXPRESSION;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:DirectoryServerManager.java

示例3: getDBConnection

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
private Connection getDBConnection(RealmConfiguration realmConfiguration) throws SQLException, UserStoreException {

        Connection dbConnection = null;
        DataSource dataSource = DatabaseUtil.createUserStoreDataSource(realmConfiguration);

        if (dataSource != null) {
            dbConnection = DatabaseUtil.getDBConnection(dataSource);
        }

        //if primary user store, DB connection can be same as realm data source.
        if (dbConnection == null && realmConfiguration.isPrimary()) {
            dbConnection = IdentityDatabaseUtil.getUserDBConnection();
        } else if (dbConnection == null) {
            throw new UserStoreException("Could not create a database connection to " +
                    realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME));
        } else {
            // db connection is present
        }
        dbConnection.setAutoCommit(false);
        dbConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
        return dbConnection;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:JDBCUserStoreCountRetriever.java

示例4: getCounterInstanceForDomain

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
/**
 * Create an instance of the given count retriever class
 *
 * @param domain
 * @return
 * @throws UserStoreCounterException
 */
public static UserStoreCountRetriever getCounterInstanceForDomain(String domain) throws UserStoreCounterException {
    if (StringUtils.isEmpty(domain)) {
        domain = IdentityUtil.getPrimaryDomainName();
    }

    RealmConfiguration realmConfiguration = getUserStoreList().get(domain);
    if (realmConfiguration != null && realmConfiguration.getUserStoreProperty(countRetrieverClass) != null) {
        String retrieverType = realmConfiguration.getUserStoreProperty(countRetrieverClass);
        UserStoreCountRetriever userStoreCountRetriever = UserStoreCountDataHolder.getInstance()
                .getCountRetrieverFactories().get(retrieverType).buildCountRetriever(realmConfiguration);
        if (userStoreCountRetriever == null) {
            throw new UserStoreCounterException(
                    "Could not create an instance of class: " + retrieverType + " for " +
                            "the domain: " + domain);
        }
        return userStoreCountRetriever;
    } else {
        return null;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:UserStoreCountUtils.java

示例5: isUserStoreEnabled

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
public static boolean isUserStoreEnabled(String domain) throws UserStoreCounterException {

        RealmConfiguration realmConfiguration;
        boolean isEnabled = false;
        try {
            realmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration();

            do {
                String userStoreDomain = realmConfiguration.
                        getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);

                if (domain.equals(userStoreDomain)) {
                    isEnabled = !Boolean.valueOf(realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.
                            USER_STORE_DISABLED));
                    break;
                }
                realmConfiguration = realmConfiguration.getSecondaryRealmConfig();
            } while (realmConfiguration != null);

        } catch (UserStoreException e) {
            throw new UserStoreCounterException("Error occurred while getting Secondary Realm Configuration", e);
        }
        return isEnabled;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:UserStoreCountUtils.java

示例6: getMultiAttributeSeparator

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
private String getMultiAttributeSeparator(String authenticatedUser, int tenantId) {
    String claimSeparator = null;
    String userDomain = IdentityUtil.extractDomainFromName(authenticatedUser);

    try {
        RealmConfiguration realmConfiguration = null;
        RealmService realmService = OAuthComponentServiceHolder.getRealmService();

        if (realmService != null && tenantId != MultitenantConstants.INVALID_TENANT_ID) {
            UserStoreManager userStoreManager = (UserStoreManager) realmService.getTenantUserRealm(tenantId)
                    .getUserStoreManager();
            realmConfiguration = userStoreManager.getSecondaryUserStoreManager(userDomain).getRealmConfiguration();
        }

        if (realmConfiguration != null) {
            claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
            if (claimSeparator != null && !claimSeparator.trim().isEmpty()) {
                return claimSeparator;
            }
        }
    } catch (UserStoreException e) {
        log.error("Error occurred while getting the realm configuration, User store properties might not be " +
                  "returned", e);
    }
    return null;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:27,代码来源:JWTTokenGenerator.java

示例7: addMultiAttributeSperatorToRequestedClaims

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
private void addMultiAttributeSperatorToRequestedClaims(AuthenticatedUser authenticatedUser,
                                                        org.wso2.carbon.user.core.UserStoreManager userStore,
                                                        Map<String, String> spRequestedClaims) {
    if (!spRequestedClaims.isEmpty()) {
        RealmConfiguration realmConfiguration = userStore.getRealmConfiguration();

        String claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants
                .MULTI_ATTRIBUTE_SEPARATOR);
        if (StringUtils.isNotBlank(claimSeparator)) {
            spRequestedClaims.put(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR, claimSeparator);
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:14,代码来源:DefaultClaimHandler.java

示例8: getPrimaryDomainName

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
public static String getPrimaryDomainName() {
    RealmConfiguration realmConfiguration = IdentityTenantUtil.getRealmService().getBootstrapRealmConfiguration();
    if (realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME) != null) {
        return realmConfiguration.getUserStoreProperty(
                UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME).toUpperCase();
    } else {
        return UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:10,代码来源:IdentityUtil.java

示例9: getUserStoreList

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
/**
 * Get the available list of user store domains
 *
 * @return
 * @throws UserStoreCounterException
 */
public static Map<String, RealmConfiguration> getUserStoreList() throws UserStoreCounterException {
    String domain;
    RealmConfiguration realmConfiguration;
    Map<String, RealmConfiguration> userStoreList = new HashMap<>();

    try {
        realmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration();
        domain = IdentityUtil.getPrimaryDomainName();
        userStoreList.put(domain, realmConfiguration);

        while (realmConfiguration != null) {
            realmConfiguration = realmConfiguration.getSecondaryRealmConfig();
            if (realmConfiguration != null) {
                domain = realmConfiguration
                        .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
                userStoreList.put(domain, realmConfiguration);
            } else {
                break;
            }
        }

    } catch (UserStoreException e) {
        throw new UserStoreCounterException("Error while listing user stores for count functionality", e);
    }

    return userStoreList;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:UserStoreCountUtils.java

示例10: getPrimaryDomainName

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
public static String getPrimaryDomainName() {
    RealmConfiguration realmConfiguration = IdentityTenantUtil.getRealmService().getBootstrapRealmConfiguration();
    if(realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME) != null){
        return realmConfiguration.getUserStoreProperty(
                UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME).toUpperCase();
    } else {
        return UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:10,代码来源:IdentityUtil.java

示例11: CarbonRemoteUserStoreManger

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
/**
 * @param realmConfig
 * @param properties
 * @throws Exception
 */
public CarbonRemoteUserStoreManger(RealmConfiguration realmConfig, Map properties)
        throws Exception {

    ConfigurationContext configurationContext = ConfigurationContextFactory
            .createDefaultConfigurationContext();

    Map<String, TransportOutDescription> transportsOut = configurationContext
            .getAxisConfiguration().getTransportsOut();
    for (TransportOutDescription transportOutDescription : transportsOut.values()) {
        transportOutDescription.getSender().init(configurationContext, transportOutDescription);
    }

    String[] serverUrls = realmConfig.getUserStoreProperty(SERVER_URLS).split(",");

    for (int i = 0; i < serverUrls.length; i++) {
        remoteUserStore = new WSUserStoreManager(
                realmConfig.getUserStoreProperty(REMOTE_USER_NAME),
                realmConfig.getUserStoreProperty(PASSWORD), serverUrls[i],
                configurationContext);

        if (log.isDebugEnabled()) {
            log.debug("Remote Servers for User Management : " + serverUrls[i]);
        }

        remoteServers.put(serverUrls[i], remoteUserStore);
    }

    this.realmConfig = realmConfig;
    domainName = realmConfig.getUserStoreProperty(UserStoreConfigConstants.DOMAIN_NAME);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:36,代码来源:CarbonRemoteUserStoreManger.java

示例12: retrieveAllNunNullUserClaimValues

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
private Map<String, String> retrieveAllNunNullUserClaimValues(AuthenticatedUser authenticatedUser,
        ClaimManager claimManager, ApplicationConfig appConfig,
        org.wso2.carbon.user.core.UserStoreManager userStore) throws FrameworkException {

    String tenantDomain = authenticatedUser.getTenantDomain();
    String tenantAwareUserName = authenticatedUser.getUserName();

    Map<String, String> allLocalClaims = new HashMap<>();
    try {

        org.wso2.carbon.user.api.ClaimMapping[] claimMappings = claimManager
                .getAllClaimMappings(ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT);
        List<String> localClaimURIs = new ArrayList<>();
        for (org.wso2.carbon.user.api.ClaimMapping mapping : claimMappings) {
            String claimURI = mapping.getClaim().getClaimUri();
            localClaimURIs.add(claimURI);
        }
        allLocalClaims = userStore.getUserClaimValues(tenantAwareUserName,
                localClaimURIs.toArray(new String[localClaimURIs.size()]), null);

        if (allLocalClaims != null) {
            for (Map.Entry<String, String> entry : allLocalClaims.entrySet()) {
                //set local2sp role mappings
                if (FrameworkConstants.LOCAL_ROLE_CLAIM_URI.equals(entry.getKey())) {
                    RealmConfiguration realmConfiguration = userStore.getRealmConfiguration();
                    String claimSeparator = realmConfiguration
                            .getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
                    if (StringUtils.isBlank(claimSeparator)) {
                        claimSeparator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
                    }
                    String roleClaim = entry.getValue();
                    List<String> rolesList = new LinkedList<>(Arrays.asList(roleClaim.split(claimSeparator)));
                    roleClaim = getServiceProviderMappedUserRoles(appConfig, rolesList, claimSeparator);
                    entry.setValue(roleClaim);
                }
            }
        } else {
            return new HashMap<>();
        }
    } catch (UserStoreException e) {
        if (e.getMessage().contains("UserNotFound")) {
            if (log.isDebugEnabled()) {
                log.debug("User " + tenantAwareUserName + " not found in user store");
            }
        } else {
            throw new FrameworkException("Error occurred while getting all user claims for " +
                    authenticatedUser + " in " + tenantDomain, e);
        }
    }
    return allLocalClaims;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:52,代码来源:DefaultClaimHandler.java

示例13: checkRolesPermissions

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
private String[] checkRolesPermissions(String[] roles) throws UserStoreException,
        MultipleCredentialsUserAdminException {
    RealmConfiguration realmConfig = realm.getRealmConfiguration();
    if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP) != null) {
        throw new MultipleCredentialsUserAdminException(
                "Please contact your external Identity Provider to add users");
    }

    if (roles != null) {
        String loggedInUserName = getLoggedInUser();
        Arrays.sort(roles);
        boolean isRoleHasAdminPermission = false;
        for (String role : roles) {
            isRoleHasAdminPermission =
                    realm.getAuthorizationManager()
                            .isRoleAuthorized(role, "/permission",
                                    UserMgtConstants.EXECUTE_ACTION);
            if (!isRoleHasAdminPermission) {
                isRoleHasAdminPermission =
                        realm.getAuthorizationManager()
                                .isRoleAuthorized(role,
                                        "/permission/admin",
                                        UserMgtConstants.EXECUTE_ACTION);
            }

            if (isRoleHasAdminPermission) {
                break;
            }
        }

        if ((Arrays.binarySearch(roles, realmConfig.getAdminRoleName()) > -1 || isRoleHasAdminPermission) &&
                !realmConfig.getAdminUserName().equals(loggedInUserName)) {
            log.warn("An attempt to assign user to Admin permission role by user : " +
                    loggedInUserName);
            throw new UserStoreException("Can not assign user to Admin permission role");
        }
        boolean isContained = false;
        String[] temp = new String[roles.length + 1];
        for (int i = 0; i < roles.length; i++) {
            temp[i] = roles[i];
            if (roles[i].equals(realmConfig.getEveryOneRoleName())) {
                isContained = true;
                break;
            }
        }

        if (!isContained) {
            temp[roles.length] = realmConfig.getEveryOneRoleName();
            roles = temp;
        }
    }
    return roles;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:54,代码来源:MultipleCredentialsUserProxy.java

示例14: CassandraUserStoreManager

import org.wso2.carbon.user.api.RealmConfiguration; //导入方法依赖的package包/类
public CassandraUserStoreManager(RealmConfiguration realmConfig, int tenantId) throws UserStoreException {
    this.realmConfig = realmConfig;
    Util.setRealmConfig(realmConfig);
    this.tenantIdString = Integer.toString(tenantId);
    this.tenantId = tenantId;

    // Set groups read/write configuration
    if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.READ_GROUPS_ENABLED) != null) {
        readGroupsEnabled = Boolean.parseBoolean(realmConfig
                .getUserStoreProperty(UserCoreConstants.RealmConfig.READ_GROUPS_ENABLED));
    }

    if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.WRITE_GROUPS_ENABLED) != null) {
        writeGroupsEnabled = Boolean.parseBoolean(realmConfig
                .getUserStoreProperty(UserCoreConstants.RealmConfig.WRITE_GROUPS_ENABLED));
    } else {
        if (!isReadOnly()) {
            writeGroupsEnabled = true;
        }
    }
    if (writeGroupsEnabled) {
        readGroupsEnabled = true;
    }

    /*
     * Initialize user roles cache as implemented in AbstractUserStoreManager
     */
    initUserRolesCache();

    Map<String, String> credentials = new HashMap<String, String>();
    credentials.put(CFConstants.USERNAME_PROPERTY,
            realmConfig.getUserStoreProperty(CFConstants.USERNAME_XML_ATTRIB));
    credentials.put(CFConstants.PASSWORD_PROPERTY,
            realmConfig.getUserStoreProperty(CFConstants.PASSWORD_XML_ATTRIB));

    CassandraHostConfigurator hostConf = new CassandraHostConfigurator();
    hostConf.setHosts(realmConfig.getUserStoreProperty(CFConstants.HOST_XML_ATTRIB));
    hostConf.setPort(Integer.parseInt(realmConfig.getUserStoreProperty(CFConstants.PORT_XML_ATTRIB)));
    // set Cassandra specific properties
    cluster = HFactory.getOrCreateCluster(realmConfig.getUserStoreProperty(CFConstants.KEYSPACE_NAME_XML_ATTRIB),
            hostConf, credentials);
    keyspace = HFactory.createKeyspace(realmConfig.getUserStoreProperty(CFConstants.KEYSPACE_NAME_XML_ATTRIB),
            cluster);
    insertInitialData(keyspace);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:46,代码来源:CassandraUserStoreManager.java


注:本文中的org.wso2.carbon.user.api.RealmConfiguration.getUserStoreProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。