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


Java UserCoreConstants类代码示例

本文整理汇总了Java中org.wso2.carbon.user.core.UserCoreConstants的典型用法代码示例。如果您正苦于以下问题:Java UserCoreConstants类的具体用法?Java UserCoreConstants怎么用?Java UserCoreConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UserCoreConstants类属于org.wso2.carbon.user.core包,在下文中一共展示了UserCoreConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
public void setUp() {

        this.realmConfiguration = new RealmConfiguration();

        Map<String,String> map = new HashMap<String, String>();
        map.put(UserCoreConstants.RealmConfig.PROPERTY_JAVA_REG_EX, "[\\S]{5,30}");
        map.put(LDAPConstants.USER_SEARCH_BASE, "ou=Users,dc=example,dc=com");
        map.put("PASSWORD_HASH_METHOD", "PlainText");
        map.put("DEFAULT_REALM_NAME", "EXAMPLE..COM");
        map.put(LDAPConstants.CONNECTION_URL, "ldap://localhost:10389");
        map.put(LDAPConstants.CONNECTION_NAME, "uid=admin,ou=system");
        map.put(LDAPConstants.CONNECTION_PASSWORD, "secret");
        map.put(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST, "50");
        map.put(LDAPConstants.USER_NAME_LIST_FILTER, "(objectClass=person)");


        this.realmConfiguration.setUserStoreProperties(map);
        
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:LDAPServerStoreManagerTest.java

示例2: getRolesToAdd

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
private Collection<String> getRolesToAdd(UserStoreManager userStoreManager, String[] newRoles)
        throws UserStoreException {

    List<String> rolesToAdd = Arrays.asList(newRoles);
    List<String> updatedRolesToAdd = new ArrayList<>();

    // Make Internal domain name case insensitive
    for (String role : rolesToAdd) {
        if (StringUtils.containsIgnoreCase(role, UserCoreConstants.INTERNAL_DOMAIN +
                CarbonConstants.DOMAIN_SEPARATOR)) {
            updatedRolesToAdd.add(UserCoreConstants.INTERNAL_DOMAIN + CarbonConstants.DOMAIN_SEPARATOR +
                    UserCoreUtil.removeDomainFromName(role));
        } else {
            updatedRolesToAdd.add(role);
        }
    }
    List<String> allExistingRoles = removeDomainFromNamesExcludeInternal(
            Arrays.asList(userStoreManager.getRoleNames()), userStoreManager.getTenantId());
    updatedRolesToAdd.retainAll(allExistingRoles);
    return updatedRolesToAdd;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:DefaultProvisioningHandler.java

示例3: getUsernames

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
@DataProvider(name = "usernameProvider")
public Object[][] getUsernames() {

    String userStoreDomainAppendedName = USER_STORE_NAME + UserCoreConstants.DOMAIN_SEPARATOR + USER_NAME;

    return new Object[][]{
            {
                    // username already has a domain appended
                    userStoreDomainAppendedName, "WSO2.COM", userStoreDomainAppendedName
            },
            {
                    // setting domain from threadlocal
                    USER_NAME, USER_STORE_NAME, userStoreDomainAppendedName
            },
            {
                    // username doesn't have domain, thread local domain is empty too
                    USER_NAME, null, USER_NAME
            },
            {
                    // username doesn't have domain, thread local domain is empty too
                    USER_NAME, "", USER_NAME
            },

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

示例4: getUserFromUserName

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Returns a User object constructed from fully qualified username
 *
 * @param username Fully qualified username
 * @return User object
 * @throws IllegalArgumentException
 */
public static User getUserFromUserName(String username) {

    User user = new User();
    if (StringUtils.isNotBlank(username)) {
        String tenantDomain = MultitenantUtils.getTenantDomain(username);
        String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(username);
        String tenantAwareUsernameWithNoUserDomain = UserCoreUtil.removeDomainFromName(tenantAwareUsername);
        String userStoreDomain = IdentityUtil.extractDomainFromName(username).toUpperCase();
        user.setUserName(tenantAwareUsernameWithNoUserDomain);
        if (StringUtils.isNotEmpty(tenantDomain)) {
            user.setTenantDomain(tenantDomain);
        } else {
            user.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        }
        if (StringUtils.isNotEmpty(userStoreDomain)) {
            user.setUserStoreDomain(userStoreDomain);
        } else {
            user.setTenantDomain(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME);
        }
    }
    return user;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:User.java

示例5: addPrimaryQuestions

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Add or update primary security questions
 *
 * @param primarySecurityQuestion
 * @param tenantId
 * @throws IdentityException
 */
public static void addPrimaryQuestions(String[] primarySecurityQuestion, int tenantId) throws IdentityException {
    JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
    UserRecoveryDataDO[] metadata = new UserRecoveryDataDO[primarySecurityQuestion.length];
    int i = 0;
    for (String secQuestion : primarySecurityQuestion) {
        if (!secQuestion.contains(UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI)) {
            throw IdentityException.error("One or more security questions does not contain the namespace " +
                    UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI);
        }
        metadata[i++] =
                new UserRecoveryDataDO("TENANT", tenantId,
                        UserRecoveryDataDO.METADATA_PRIMARAY_SECURITY_QUESTION,
                        secQuestion);
    }
    store.store(metadata);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:UserIdentityManagementUtil.java

示例6: removePrimaryQuestions

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Remove primary security questions
 *
 * @param tenantId
 * @throws IdentityException
 */
public static void removePrimaryQuestions(String[] primarySecurityQuestion, int tenantId) throws IdentityException {

    UserRecoveryDataDO[] metadata = new UserRecoveryDataDO[primarySecurityQuestion.length];
    int i = 0;
    for (String secQuestion : primarySecurityQuestion) {
        if (!secQuestion.contains(UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI)) {
            throw IdentityException.error("One or more security questions does not contain the namespace " +
                    UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI);
        }
        metadata[i++] =
                new UserRecoveryDataDO("TENANT", tenantId,
                        UserRecoveryDataDO.METADATA_PRIMARAY_SECURITY_QUESTION,
                        secQuestion);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:UserIdentityManagementUtil.java

示例7: preparePassword

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
public static String preparePassword(String password, String saltValue) throws UserStoreException {
    try {
        String digestInput = password;
        if (saltValue != null) {
            digestInput = password + saltValue;
        }
        String digsestFunction = Util.getRealmConfig().getUserStoreProperties()
                .get(JDBCRealmConstants.DIGEST_FUNCTION);
        if (digsestFunction != null) {

            if (digsestFunction.equals(UserCoreConstants.RealmConfig.PASSWORD_HASH_METHOD_PLAIN_TEXT)) {
                return password;
            }

            MessageDigest dgst = MessageDigest.getInstance(digsestFunction);
            byte[] byteValue = dgst.digest(digestInput.getBytes(Charset.forName("UTF-8")));
            password = Base64.encode(byteValue);
        }
        return password;
    } catch (NoSuchAlgorithmException e) {
        log.error(e.getMessage(), e);
        throw new UserStoreException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:Util.java

示例8: countRolesInDomain

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Get the count of roles having a matching role name for the filter
 *
 * @param filter the filter for the role name. Use '*' to have all.
 * @return the number of roles matching the filter within this user store domain
 */
public Long countRolesInDomain(String filter, String domain) throws UserStoreCounterException {

    if (UserCoreConstants.INTERNAL_DOMAIN.equalsIgnoreCase(domain)) {
        return UserStoreCountUtils.getInternalRoleCount(filter);
    } else if (InternalStoreCountConstants.APPLICATION_DOMAIN.equalsIgnoreCase(domain)) {
        return UserStoreCountUtils.getApplicationRoleCount(filter);
    } else {              //Not an internal domain
        UserStoreCountRetriever counter = UserStoreCountUtils.getCounterInstanceForDomain(domain);
        if (counter != null) {
            return counter.countRoles(filter);
        } else {
            return Long.valueOf(-1);
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:UserStoreCountService.java

示例9: getDBConnection

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的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

示例10: getCountEnabledUserStores

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Get the domain names of user stores which has count functionality enabled
 *
 * @return
 */
public static Set<String> getCountEnabledUserStores() throws UserStoreCounterException {
    RealmConfiguration realmConfiguration;
    Set<String> userStoreList = new HashSet<>();

    try {
        realmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration();

        while (realmConfiguration != null) {
            if (!Boolean.valueOf(realmConfiguration.getUserStoreProperty(
                    UserCoreConstants.RealmConfig.USER_STORE_DISABLED))) {
                if (StringUtils.isNotEmpty(realmConfiguration.getUserStoreProperty(countRetrieverClass))) {
                    userStoreList.add(realmConfiguration
                            .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME));
                }
            }
            realmConfiguration = realmConfiguration.getSecondaryRealmConfig();
        }
    } catch (UserStoreException e) {
        throw new UserStoreCounterException("Error while getting the count enabled user stores", e);
    }

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

示例11: isUserStoreEnabled

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的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

示例12: isCurrentUser

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Provide whether the user referred is the logged-in user.
 *
 * @param currentUsername logged in username.
 * @param username provided username.
 * @param userRealmInfo User realm info.
 * @return Returns 'true' if the provided user is the logged-in user.
 */
public static boolean isCurrentUser(String currentUsername, String username, UserRealmInfo userRealmInfo) {

    if (username.contains(UserCoreConstants.DOMAIN_SEPARATOR)) {
        // username case sensitiveness can be changed in the database level or using the user-store configuration.
        // So always consider username as case insensitive.
        return currentUsername.equalsIgnoreCase(username);
    }

    if (currentUsername.contains(UserCoreConstants.DOMAIN_SEPARATOR)
            && !UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME
            .equalsIgnoreCase(UserCoreUtil.extractDomainFromName(currentUsername))) {
        return false;
    }

    // username case sensitiveness can be changed in the database level or using the user-store configuration.
    // So always consider username as case insensitive.
    return UserCoreUtil.removeDomainFromName(currentUsername).equalsIgnoreCase(username);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:Util.java

示例13: mapEntityName

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
private void mapEntityName(String entityName, FlaggedName fName,
                           UserStoreManager userStoreManager) {
    if (entityName.contains(UserCoreConstants.SHARED_ROLE_TENANT_SEPERATOR)) {
        String[] nameAndDn = entityName.split(UserCoreConstants.SHARED_ROLE_TENANT_SEPERATOR);
        fName.setItemName(nameAndDn[0]);
        fName.setDn(nameAndDn[1]);

        // TODO remove abstract user store
        fName.setShared(((AbstractUserStoreManager) userStoreManager).isOthersSharedRole(entityName));
        if (fName.isShared()) {
            fName.setItemDisplayName(UserCoreConstants.SHARED_ROLE_TENANT_SEPERATOR +
                    fName.getItemName());
        }

    } else {
        fName.setItemName(entityName);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:UserRealmProxy.java

示例14: testGetUserRealmInfo

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
@Test
public void testGetUserRealmInfo() throws Exception {
    Mockito.when(realm.getAuthorizationManager()).thenReturn(authorizationManager);
    Mockito.when(realm.getClaimManager()).thenReturn(claimManager);
    Mockito.when(authorizationManager.isUserAuthorized("admin",
            "/permission/admin/manage/identity", CarbonConstants.UI_PERMISSION_ACTION)).thenReturn(true);
    Mockito.when(realm.getRealmConfiguration()).thenReturn(this.getSampleRelaimConfiguration());
    Mockito.when(realm.getUserStoreManager()).thenReturn(userStoreManagerWithAb);
    ClaimMapping claimMapping = new ClaimMapping();
    claimMapping.setMappedAttribute("test1");
    claimMapping.setMappedAttribute("test2");
    claimMapping.setMappedAttribute("test3");
    Claim claim = new Claim();
    claim.setClaimUri("testURI");
    claim.setValue("testClaim");
    claimMapping.setClaim(claim);

    Mockito.when(claimManager.getAllClaimMappings(UserCoreConstants.DEFAULT_CARBON_DIALECT))
            .thenReturn(new ClaimMapping[]{claimMapping});
    Mockito.when(userStoreManagerWithAb.getRealmConfiguration()).thenReturn(this.getSampleRelaimConfiguration());
    Mockito.when(userStoreManagerWithAb.isBulkImportSupported()).thenReturn(false);
    UserRealmInfo realmInfo = userRealmProxy.getUserRealmInfo();
    Assert.assertEquals(realmInfo.getEveryOneRole(), "everyone");
    Assert.assertEquals(realmInfo.getAdminRole(), "admin");
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:UserRealmProxyTest.java

示例15: doPreDeleteUser

import org.wso2.carbon.user.core.UserCoreConstants; //导入依赖的package包/类
/**
 * Delete federated user account associations a user has upon deleting the local user account.
 *
 * @param userName
 * @param userStoreManager
 * @return
 * @throws UserStoreException
 */
@Override
public boolean doPreDeleteUser(String userName,
        UserStoreManager userStoreManager) throws UserStoreException {

    if (!isEnable()) {
        return true;
    }

    String userStoreDomain = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration());
    if (StringUtils.isBlank(userStoreDomain)) {
        userStoreDomain = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME;
    }
    int tenantId = userStoreManager.getTenantId();

    if (log.isDebugEnabled()) {
        log.debug("doPreDeleteUser method executed in ProfileMgtEventListener for user:" +
                getFullQualifiedUsername(userName, userStoreDomain, IdentityTenantUtil.getTenantDomain(tenantId)));
    }

    deleteFederatedIdpAccountAssociations(userName, userStoreDomain, tenantId);
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:ProfileMgtEventListener.java


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