Search in sources :

Example 1 with SidUtils

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SidUtils(org.molgenis.security.acl.SidUtils)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 SidUtils (org.molgenis.security.acl.SidUtils)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1