public abstract class UserAuthorityHelper extends Object
TODO Move helper to helper package
Modifier and Type | Method and Description |
---|---|
static boolean |
containsRole(Collection<org.springframework.security.core.GrantedAuthority> authorities,
UserRole role)
Test whether the granted authorities contain a given role.
|
static Set<UserRole> |
getAllRoles()
Gets a set of all available user roles.
|
static UserRole[] |
getAssignableRoles(User user)
Gets the assignable roles for an user.
|
static Collection<org.springframework.security.core.GrantedAuthority> |
getGrantedAuthorities(User user)
Gets the granted Spring Security authorities of an user.
|
static Set<UserAuthority> |
getUserAuthorities(UserRole[] roles)
Creates a set of UserAuthority entities from UserRole's.
|
static Set<UserRole> |
getUserRoles(Long userId)
Gets the user roles.
|
static Set<UserRole> |
getUserRoles(User user)
Gets the user roles.
|
static boolean |
hasAuthority(Long userId,
UserRole role)
Checks if a user has a given user role.
|
static boolean |
hasAuthority(User user,
UserRole role)
Checks if a user has a given user role.
|
public static boolean containsRole(Collection<org.springframework.security.core.GrantedAuthority> authorities, UserRole role)
authorities
- the granted authorities of a user as returned by
getGrantedAuthorities(User)
role
- the role to testpublic static Set<UserRole> getAllRoles()
public static UserRole[] getAssignableRoles(User user)
user
- the userpublic static Collection<org.springframework.security.core.GrantedAuthority> getGrantedAuthorities(User user)
user
- the userpublic static Set<UserAuthority> getUserAuthorities(UserRole[] roles)
roles
- the rolespublic static Set<UserRole> getUserRoles(User user)
user
- the userpublic static Set<UserRole> getUserRoles(Long userId)
userId
- the ID of the userpublic static boolean hasAuthority(User user, UserRole role)
user
- the userrole
- the roleCopyright © 2019 Communote team. All rights reserved.