public Collection<String> allRoleNames(CruiseConfig cruiseConfig) { List<String> roles = new ArrayList<String>(); for (Role role : allRoles(cruiseConfig)) { roles.add(CaseInsensitiveString.str(role.getName())); } return roles; }
private List<UserModel> allUsersForDisplay() { Collection<User> users = allUsers(); ArrayList<UserModel> userModels = new ArrayList<UserModel>(); for (User user : users) { String userName = user.getName(); ArrayList<String> roles = new ArrayList<String>(); for (Role role : goConfigService.rolesForUser(new CaseInsensitiveString(userName))) { roles.add(CaseInsensitiveString.str(role.getName())); } userModels.add( new UserModel( user, roles, securityService.isUserAdmin(new Username(new CaseInsensitiveString(userName))))); } return userModels; }
public Set<String> usersThatCanOperateOnStage( CruiseConfig cruiseConfig, PipelineConfig pipelineConfig) { SortedSet<String> users = new TreeSet<String>(); PipelineConfigs group = cruiseConfig.findGroupOfPipeline(pipelineConfig); if (group.hasAuthorizationDefined()) { if (group.hasOperationPermissionDefined()) { users.addAll(group.getOperateUserNames()); List<String> roles = group.getOperateRoleNames(); for (Role role : cruiseConfig.server().security().getRoles()) { if (roles.contains(CaseInsensitiveString.str(role.getName()))) { users.addAll(role.usersOfRole()); } } } } else { users.addAll(allUsernames()); } return users; }