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


Java UserStoreManager.getRoleListOfUser方法代码示例

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


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

示例1: registerApiAccessRoles

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
public static void registerApiAccessRoles(String user) {
    UserStoreManager userStoreManager = null;
    try {
        userStoreManager = getUserStoreManager();
        String[] userList = new String[]{user};
        if (userStoreManager != null) {
            String rolesOfUser[] = userStoreManager.getRoleListOfUser(user);
            if (!userStoreManager.isExistingRole(Constants.DEFAULT_ROLE_NAME)) {
                userStoreManager.addRole(Constants.DEFAULT_ROLE_NAME, userList, Constants.DEFAULT_PERMISSION);
            } else if (rolesOfUser != null && Arrays.asList(rolesOfUser).contains(Constants.DEFAULT_ROLE_NAME)) {
                return;
            } else {
                userStoreManager.updateUserListOfRole(Constants.DEFAULT_ROLE_NAME, new String[0], userList);
            }
        }
    } catch (UserStoreException e) {
        log.error("Error while creating a role and adding a user for virtual_firealarm.", e);
    }
}
 
开发者ID:wso2,项目名称:product-iots,代码行数:20,代码来源:APIUtil.java

示例2: getRefinedListOfRolesOfUser

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
/**
 * Get the List of userRoles except the Internal/everyone role
 *
 * @param userStoreManager UserStoreManager
 * @param username         Username of the user
 * @return String[]
 * @throws UserManagerException
 */
private static String[] getRefinedListOfRolesOfUser(UserStoreManager userStoreManager, String username)
        throws UserManagerException {

    ArrayList<String> rolesWithoutEveryoneRole = new ArrayList<String>();

    try {
        String[] allUserRoles = userStoreManager.getRoleListOfUser(username);

        for (String role : allUserRoles) {
            if (!role.equals(INTERNAL_EVERYONE_ROLE)) {
                rolesWithoutEveryoneRole.add(role);
            }
        }
        String[] rolesWithoutEveryoneRoleArray = new String[rolesWithoutEveryoneRole.size()];
        return rolesWithoutEveryoneRole.toArray(rolesWithoutEveryoneRoleArray);

    } catch (UserStoreException e) {
        String msg = "Error in listing the roles of user " + username + " in User Store";
        log.error(msg, e);
        throw new UserManagerException(msg, e);
    }
}
 
开发者ID:apache,项目名称:stratos,代码行数:31,代码来源:StratosUserManagerUtils.java

示例3: isUserAuthorized

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
/**
 * @param applicationName
 * @param username
 * @return
 * @throws IdentityApplicationManagementException
 */
public static boolean isUserAuthorized(String applicationName, String username)
        throws IdentityApplicationManagementException {

    String applicationRoleName = getAppRoleName(applicationName);
    try {
        if (log.isDebugEnabled()) {
            log.debug("Checking whether user has role : " + applicationRoleName + " by retrieving role list of " +
                      "user : " + username);
        }

        UserStoreManager userStoreManager = CarbonContext.getThreadLocalCarbonContext().getUserRealm()
                .getUserStoreManager();
        if (userStoreManager instanceof AbstractUserStoreManager) {
            return ((AbstractUserStoreManager) userStoreManager).isUserInRole(username, applicationRoleName);
        }

        String[] userRoles = userStoreManager.getRoleListOfUser(username);
        for (String userRole : userRoles) {
            if (applicationRoleName.equals(userRole)) {
                return true;
            }
        }
    } catch (UserStoreException e) {
        throw new IdentityApplicationManagementException("Error while checking authorization for user: " +
                username + " for application: " + applicationName, e);
    }
    return false;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:35,代码来源:ApplicationMgtUtil.java

示例4: getFilteredRoles

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
private List<String> getFilteredRoles(UserStoreManager userStoreManager, String username)
        throws UserStoreException {
    String[] roleListOfUser;
    roleListOfUser = userStoreManager.getRoleListOfUser(username);
    List<String> filteredRoles = new ArrayList<>();
    for (String role : roleListOfUser) {
        if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) {
            filteredRoles.add(role);
        }
    }
    return filteredRoles;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:13,代码来源:UserManagementServiceImpl.java


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