use of gemma.gsec.model.UserGroup in project Gemma by PavlidisLab.
the class UserManagerImpl method findGroupsForUser.
@Override
@Secured({ "IS_AUTHENTICATED_ANONYMOUSLY", "RUN_AS_USER" })
public Collection<String> findGroupsForUser(String userName) {
Collection<String> result = new HashSet<>();
if (!this.loggedIn()) {
return result;
}
User u = this.loadUser(userName);
Collection<UserGroup> groups = userService.findGroupsForUser(u);
for (UserGroup g : groups) {
result.add(g.getName());
}
return result;
}
use of gemma.gsec.model.UserGroup in project Gemma by PavlidisLab.
the class UserManagerImpl method findUsersInGroup.
@Override
public List<String> findUsersInGroup(String groupName) {
UserGroup group = this.loadGroup(groupName);
Collection<gemma.gsec.model.User> groupMembers = group.getGroupMembers();
List<String> result = new ArrayList<>();
for (gemma.gsec.model.User u : groupMembers) {
result.add(u.getUserName());
}
return result;
}
use of gemma.gsec.model.UserGroup in project Gemma by PavlidisLab.
the class UserManagerImpl method findAllGroups.
@Override
public List<String> findAllGroups() {
Collection<UserGroup> groups = userService.listAvailableGroups();
List<String> result = new ArrayList<>();
for (UserGroup group : groups) {
result.add(group.getName());
}
return result;
}
use of gemma.gsec.model.UserGroup in project Gemma by PavlidisLab.
the class UserManagerImpl method addGroupAuthority.
@Override
public void addGroupAuthority(String groupName, GrantedAuthority authority) {
UserGroup g = this.loadGroup(groupName);
for (gemma.gsec.model.GroupAuthority ga : g.getAuthorities()) {
if (ga.getAuthority().equals(authority.getAuthority())) {
logger.warn("Group already has authority" + authority.getAuthority());
return;
}
}
GroupAuthority auth = ubic.gemma.model.common.auditAndSecurity.GroupAuthority.Factory.newInstance();
auth.setAuthority(authority.getAuthority());
g.getAuthorities().add(auth);
userService.update(g);
}
use of gemma.gsec.model.UserGroup in project Gemma by PavlidisLab.
the class UserManagerImpl method findGroupAuthorities.
@Override
public List<GrantedAuthority> findGroupAuthorities(String groupName) {
String groupToSearch = groupName;
if (groupName.startsWith(rolePrefix)) {
groupToSearch = groupToSearch.replaceFirst(rolePrefix, "");
}
UserGroup group = this.loadGroup(groupToSearch);
List<GrantedAuthority> result = new ArrayList<>();
for (gemma.gsec.model.GroupAuthority ga : group.getAuthorities()) {
result.add(new SimpleGrantedAuthority(ga.getAuthority()));
}
return result;
}
Aggregations