Package com.floragunn.searchguard.user
Class User
- java.lang.Object
-
- com.floragunn.searchguard.user.User
-
- All Implemented Interfaces:
CustomAttributesAware,UserInformation,Serializable
public class User extends Object implements Serializable, CustomAttributesAware, UserInformation
A authenticated user and attributes associated to them (like roles, tenant, custom attributes) Do not subclass from this class!- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUser.Builder
-
Field Summary
Fields Modifier and Type Field Description static UserANONYMOUSstatic StringUSER_TENANT-
Fields inherited from interface com.floragunn.searchguard.user.UserInformation
NONE
-
-
Constructor Summary
Constructors Constructor Description User(String name)Create a new authenticated user without roles and attributesUser(String name, AuthDomainInfo authDomainInfo)User(String name, AuthDomainInfo authDomainInfo, Collection<String> roles, AuthCredentials customAttributes)Create a new authenticated userUser(String name, String subName, AuthDomainInfo authDomainInfo, String type, Set<String> roles, Set<String> searchGuardRoles, Object specialAuthzConfig, String requestedTenant, Map<String,Object> structuredAttributes, Map<String,String> attributes, boolean isInjected, boolean authzComplete)User(String name, Collection<String> roles, AuthCredentials customAttributes)Deprecated.
-
Method Summary
-
-
-
Field Detail
-
ANONYMOUS
public static final User ANONYMOUS
-
USER_TENANT
public static final String USER_TENANT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
User
public User(String name, String subName, AuthDomainInfo authDomainInfo, String type, Set<String> roles, Set<String> searchGuardRoles, Object specialAuthzConfig, String requestedTenant, Map<String,Object> structuredAttributes, Map<String,String> attributes, boolean isInjected, boolean authzComplete)
-
User
public User(String name, AuthDomainInfo authDomainInfo, 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
@Deprecated public User(String name, Collection<String> roles, AuthCredentials customAttributes)
Deprecated.
-
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
-
User
public User(String name, AuthDomainInfo authDomainInfo)
-
-
Method Detail
-
forUser
public static User.Builder forUser(String username)
-
getName
public final String getName()
- Specified by:
getNamein interfaceUserInformation
-
getSubName
public String getSubName()
- Specified by:
getSubNamein interfaceUserInformation
-
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
@Deprecated public final void addAttributes(Map<String,String> attributes)
Deprecated.Use structured attributes instead
-
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()
-
getCustomAttributesMap
@Deprecated public final Map<String,String> getCustomAttributesMap()
Deprecated.use getStructuredAttributes() insteadGet the custom attributes associated with this user- Specified by:
getCustomAttributesMapin interfaceCustomAttributesAware- Returns:
- A modifiable map with all the current custom attributes associated with this user
-
addStructuredAttributesByJsonPath
public void addStructuredAttributesByJsonPath(Map<String,com.jayway.jsonpath.JsonPath> jsonPathMap, Object source)
-
addSearchGuardRoles
public final void addSearchGuardRoles(Collection<String> sgRoles)
-
getType
public String getType()
-
getSpecialAuthzConfig
public Object getSpecialAuthzConfig()
-
isAuthzComplete
public boolean isAuthzComplete()
-
copy
public User.Builder copy()
-
getAuthDomain
public String getAuthDomain()
- Specified by:
getAuthDomainin interfaceUserInformation
-
setAuthDomain
public void setAuthDomain(String authDomain)
-
-