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 classUserContext.ImplThe 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 StringgetName()default @NotNull Set<String>getRoles()Gets roles.StringgetUserId()Gets user id.default booleanhasAnyRole(String... roles)Has any role boolean.default booleanhasAnyRole(Collection<String> roles)Has any role boolean.default booleanhasRole(String role)Has role boolean.default booleanisInAnyGroup(String... groups)Is in any group boolean.default booleanisInAnyGroup(Collection<String> groups)Is in any group boolean.default booleanisInGroup(String group)Is in group boolean.default booleanisUserIdPresent()Determines whether the user id is present or not.static UserContextnewInstance()New instance user context.static UserContextnewInstance(String userId, Collection<String> roles, Collection<String> groups)New instance user context.static UserContextnewInstance(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
-
-