Interface UserContext

  • All Superinterfaces:
    Principal
    All Known Implementing Classes:
    UserContext.Impl

    @Validated
    public interface UserContext
    extends Principal
    The user context.
    Author:
    Christian Bremer
    • Method Detail

      • getUserId

        String getUserId()
        Gets user id.
        Returns:
        the user id
      • getRoles

        @NotNull
        default @NotNull Set<String> getRoles()
        Gets roles.
        Returns:
        the roles
      • getGroups

        @NotNull
        default @NotNull Set<String> getGroups()
        Gets groups.
        Returns:
        the groups
      • 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 authentication
        groups - 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 id
        roles - the roles
        groups - 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