本文整理汇总了Java中org.wso2.carbon.user.api.UserStoreManager.listUsers方法的典型用法代码示例。如果您正苦于以下问题:Java UserStoreManager.listUsers方法的具体用法?Java UserStoreManager.listUsers怎么用?Java UserStoreManager.listUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.user.api.UserStoreManager
的用法示例。
在下文中一共展示了UserStoreManager.listUsers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserCountViaUserStoreManager
import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
/**
* This method returns the count of users using UserStoreManager.
*
* @return user count
*/
private Response getUserCountViaUserStoreManager() {
if (log.isDebugEnabled()) {
log.debug("Getting the user count");
}
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
int userCount = userStoreManager.listUsers("*", -1).length;
BasicUserInfoList result = new BasicUserInfoList();
result.setCount(userCount);
return Response.status(Response.Status.OK).entity(result).build();
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving the user count.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
示例2: getUserNames
import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@GET
@Path("/search/usernames")
@Override
public Response getUserNames(@QueryParam("filter") String filter, @QueryParam("domain") String domain,
@HeaderParam("If-Modified-Since") String timestamp,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
if (log.isDebugEnabled()) {
log.debug("Getting the list of users with all user-related information using the filter : " + filter);
}
String userStoreDomain = Constants.PRIMARY_USER_STORE;
if (domain != null && !domain.isEmpty()) {
userStoreDomain = domain;
}
if (limit == 0){
//If there is no limit is passed, then return all.
limit = -1;
}
List<UserInfo> userList;
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
String[] users = userStoreManager.listUsers(userStoreDomain + "/" + filter + "*", limit);
userList = new ArrayList<>();
UserInfo user;
for (String username : users) {
user = new UserInfo();
user.setUsername(username);
user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
userList.add(user);
}
return Response.status(Response.Status.OK).entity(userList).build();
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving the list of users using the filter : " + filter;
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
示例3: getUsersForTenant
import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@Override
public List<User> getUsersForTenant(int tenantId) throws UserManagementException {
UserStoreManager userStoreManager;
String[] userNames;
ArrayList usersList = new ArrayList();
try {
userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
.getUserStoreManager();
userNames = userStoreManager.listUsers("", -1);
User newUser;
for (String userName : userNames) {
newUser = new User(userName);
Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
Map<String,String> claimMap = new HashMap<String, String>();
for(Claim claim:claims){
String claimURI = claim.getClaimUri();
String value = claim.getValue();
claimMap.put(claimURI, value);
}
setUserClaims(newUser, claimMap);
usersList.add(newUser);
}
} catch (UserStoreException userStoreEx) {
String errorMsg = "User store error in fetching user list for tenant id:" + tenantId;
log.error(errorMsg, userStoreEx);
throw new UserManagementException(errorMsg, userStoreEx);
}
return usersList;
}
示例4: getAllUsers
import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
/**
* Get a List of usernames and associated Roles as a UserInfoBean
*
* @param userStoreManager UserStoreManager
* @return List<UserInfoBean>
* @throws UserManagerException
*/
public static List<UserInfoBean> getAllUsers(UserStoreManager userStoreManager)
throws UserManagerException {
String[] users;
List<UserInfoBean> userList = new ArrayList<UserInfoBean>();
try {
users = userStoreManager.listUsers(GET_ALL_USERS_WILD_CARD, -1);
} catch (UserStoreException e) {
String msg = "Error in listing the users in User Store";
log.error(msg, e);
throw new UserManagerException(msg, e);
}
//Iterate through the list of users and retrieve their roles
for (String user : users) {
UserInfoBean userInfoBean = new UserInfoBean();
userInfoBean.setUserName(user);
String[] refinedListOfRolesOfUser = getRefinedListOfRolesOfUser(userStoreManager, user);
//TODO : Should support multiple roles for user
if (refinedListOfRolesOfUser.length != 0) {
userInfoBean.setRole(getRefinedListOfRolesOfUser(userStoreManager, user)[0]);
} else {
userInfoBean.setRole(INTERNAL_EVERYONE_ROLE);
}
userList.add(userInfoBean);
}
return userList;
}
示例5: getUsers
import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@GET
@Override
public Response getUsers(@QueryParam("filter") String filter, @HeaderParam("If-Modified-Since") String timestamp,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
if (log.isDebugEnabled()) {
log.debug("Getting the list of users with all user-related information");
}
RequestValidationUtil.validatePaginationParameters(offset, limit);
if (limit == 0) {
limit = Constants.DEFAULT_PAGE_LIMIT;
}
List<BasicUserInfo> userList, offsetList;
String appliedFilter = ((filter == null) || filter.isEmpty() ? "*" : filter + "*");
// to get whole set of users, appliedLimit is set to -1
// by default, this whole set is limited to 100 - MaxUserNameListLength of user-mgt.xml
int appliedLimit = -1;
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
//As the listUsers function accepts limit only to accommodate offset we are passing offset + limit
String[] users = userStoreManager.listUsers(appliedFilter, appliedLimit);
userList = new ArrayList<>(users.length);
BasicUserInfo user;
for (String username : users) {
user = new BasicUserInfo();
user.setUsername(username);
user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
userList.add(user);
}
int toIndex = offset + limit;
int listSize = userList.size();
int lastIndex = listSize - 1;
if (offset <= lastIndex) {
if (toIndex <= listSize) {
offsetList = userList.subList(offset, toIndex);
} else {
offsetList = userList.subList(offset, listSize);
}
} else {
offsetList = new ArrayList<>();
}
BasicUserInfoList result = new BasicUserInfoList();
result.setList(offsetList);
result.setCount(users.length);
return Response.status(Response.Status.OK).entity(result).build();
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving the list of users.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}