Class User

    • Constructor Detail

      • User

        public User​(org.elasticsearch.common.io.stream.StreamInput in)
             throws IOException
        Throws:
        IOException
      • User

        public User​(String name,
                    Collection<String> roles,
                    AuthCredentials customAttributes)
        Create a new authenticated user
        Parameters:
        name - The username (must not be null or empty)
        roles - Roles of which the user is a member off (maybe null)
        customAttributes - Custom attributes associated with this (maybe null)
        Throws:
        IllegalArgumentException - if name is null or empty
      • User

        public User​(String name)
        Create a new authenticated user without roles and attributes
        Parameters:
        name - The username (must not be null or empty)
        Throws:
        IllegalArgumentException - if name is null or empty
    • Method Detail

      • getName

        public final String getName()
      • getRoles

        public final Set<String> getRoles()
        Returns:
        A unmodifiable set of the backend roles this user is a member of
      • addRole

        public final void addRole​(String role)
        Associate this user with a backend role
        Parameters:
        role - The backend role
      • addRoles

        public final void addRoles​(Collection<String> roles)
        Associate this user with a set of backend roles
        Parameters:
        roles - The backend roles
      • isUserInRole

        public final boolean isUserInRole​(String role)
        Check if this user is a member of a backend role
        Parameters:
        role - The backend role
        Returns:
        true if this user is a member of the backend role, false otherwise
      • addAttributes

        public final void addAttributes​(Map<String,​String> attributes)
        Associate this user with a set of roles
        Parameters:
        roles - The roles
      • getRequestedTenant

        public final String getRequestedTenant()
      • setRequestedTenant

        public final void setRequestedTenant​(String requestedTenant)
      • isInjected

        public boolean isInjected()
      • setInjected

        public void setInjected​(boolean isInjected)
      • toStringWithAttributes

        public final String toStringWithAttributes()
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • copyRolesFrom

        public final void copyRolesFrom​(User user)
        Copy all backend roles from another user
        Parameters:
        user - The user from which the backend roles should be copied over
      • writeTo

        public void writeTo​(org.elasticsearch.common.io.stream.StreamOutput out)
                     throws IOException
        Specified by:
        writeTo in interface org.elasticsearch.common.io.stream.Writeable
        Throws:
        IOException
      • getCustomAttributesMap

        public final Map<String,​String> getCustomAttributesMap()
        Get the custom attributes associated with this user
        Specified by:
        getCustomAttributesMap in interface CustomAttributesAware
        Returns:
        A modifiable map with all the current custom attributes associated with this user
      • addSearchGuardRoles

        public final void addSearchGuardRoles​(Collection<String> sgRoles)
      • getSearchGuardRoles

        public final Set<String> getSearchGuardRoles()