Package org.bremersee.security.core
Interface UserContext
-
- All Superinterfaces:
Principal
- All Known Implementing Classes:
UserContext.Impl
@Validated public interface UserContext extends Principal
The user context.- Author:
- Christian Bremer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
UserContext.Impl
The default implementation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @NotNull Set<String>
getGroups()
Gets groups.default String
getName()
default @NotNull Set<String>
getRoles()
Gets roles.String
getUserId()
Gets user id.default boolean
hasAnyRole(String... roles)
Has any role boolean.default boolean
hasAnyRole(Collection<String> roles)
Has any role boolean.default boolean
hasRole(String role)
Has role boolean.default boolean
isInAnyGroup(String... groups)
Is in any group boolean.default boolean
isInAnyGroup(Collection<String> groups)
Is in any group boolean.default boolean
isInGroup(String group)
Is in group boolean.default boolean
isUserIdPresent()
Determines whether the user id is present or not.static UserContext
newInstance()
New instance user context.static UserContext
newInstance(String userId, Collection<String> roles, Collection<String> groups)
New instance user context.static UserContext
newInstance(org.springframework.security.core.Authentication authentication, Collection<String> groups)
New instance user context.
-
-
-
Method Detail
-
getUserId
String getUserId()
Gets user id.- Returns:
- the user id
-
newInstance
static UserContext newInstance()
New instance user context.- Returns:
- the user context
-
newInstance
static UserContext newInstance(@Nullable org.springframework.security.core.Authentication authentication, @Nullable Collection<String> groups)
New instance user context.- Parameters:
authentication
- the authenticationgroups
- the groups- Returns:
- the user context
-
newInstance
static UserContext newInstance(@Nullable String userId, @Nullable Collection<String> roles, @Nullable Collection<String> groups)
New instance user context.- Parameters:
userId
- the user idroles
- the rolesgroups
- the groups- Returns:
- the user context
-
isUserIdPresent
default boolean isUserIdPresent()
Determines whether the user id is present or not.- Returns:
- the boolean
-
hasRole
default boolean hasRole(@Nullable String role)
Has role boolean.- Parameters:
role
- the role- Returns:
- the boolean
-
hasAnyRole
default boolean hasAnyRole(@Nullable Collection<String> roles)
Has any role boolean.- Parameters:
roles
- the roles- Returns:
- the boolean
-
hasAnyRole
default boolean hasAnyRole(@Nullable String... roles)
Has any role boolean.- Parameters:
roles
- the roles- Returns:
- the boolean
-
isInGroup
default boolean isInGroup(@Nullable String group)
Is in group boolean.- Parameters:
group
- the group- Returns:
- the boolean
-
isInAnyGroup
default boolean isInAnyGroup(@Nullable Collection<String> groups)
Is in any group boolean.- Parameters:
groups
- the groups- Returns:
- the boolean
-
isInAnyGroup
default boolean isInAnyGroup(@Nullable String... groups)
Is in any group boolean.- Parameters:
groups
- the groups- Returns:
- the boolean
-
-