use of org.molgenis.security.acl.SidUtils in project molgenis by molgenis.
the class UserDetailsService method getAuthorities.
public Collection<? extends GrantedAuthority> getAuthorities(User user) {
Set<GrantedAuthority> authorities = new LinkedHashSet<>();
if (user.isSuperuser() != null && user.isSuperuser()) {
authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_SU));
}
if (user.getUsername().equals(SecurityUtils.ANONYMOUS_USERNAME)) {
authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_ANONYMOUS));
}
// add authorities of groups that this user is member of
dataService.query(GROUP_MEMBER, GroupMember.class).eq(GroupMemberMetaData.USER, user).findAll().map(GroupMember::getGroup).map(SidUtils::createGroupAuthority).map(SimpleGrantedAuthority::new).forEach(authorities::add);
return grantedAuthoritiesMapper.mapAuthorities(authorities);
}
Aggregations