public class UserSession
extends java.lang.Object
implements java.io.Serializable
It contains user attributes, credentials, set of permissions, and methods to check permissions for certain objects.
On the client side a descendant of this class is maintained:
com.haulmont.cuba.client.ClientUserSession
Constructor and Description |
---|
UserSession()
INTERNAL
Used only for kryo serialization
|
UserSession(UserSession src)
INTERNAL
|
UserSession(UserSession src,
User user,
java.util.Collection<Role> roles,
java.util.Locale locale)
INTERNAL
|
UserSession(java.util.UUID id,
User user,
java.util.Collection<Role> roles,
java.util.Locale locale,
boolean system)
INTERNAL
|
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(Constraint constraint)
INTERNAL
|
void |
addPermission(PermissionType type,
java.lang.String target,
java.lang.String extTarget,
int value)
INTERNAL
|
java.lang.String |
getAddress()
Client IP-address
|
<T> T |
getAttribute(java.lang.String name)
Get user session attribute.
|
java.util.Collection<java.lang.String> |
getAttributeNames()
User session attribute names.
|
java.lang.String |
getClientInfo()
Client application info
|
java.util.List<ConstraintData> |
getConstraints(java.lang.String entityName)
INTERNAL
|
java.util.List<ConstraintData> |
getConstraints(java.lang.String entityName,
java.util.function.Predicate<ConstraintData> predicate)
INTERNAL
|
User |
getCurrentOrSubstitutedUser()
Returns substituted user if it is not null, logged-in user otherwise.
|
java.util.UUID |
getId()
Session ID
|
<T> T |
getLocalAttribute(java.lang.String name)
Get local attribute.
|
java.util.Collection<java.lang.String> |
getLocalAttributeNames()
Local attribute names.
|
java.util.Locale |
getLocale()
User locale
|
java.util.Map<java.lang.String,java.lang.Integer> |
getPermissionsByType(PermissionType type)
Get permissions by type
|
java.lang.Integer |
getPermissionValue(PermissionType type,
java.lang.String target)
INTERNAL
|
java.util.Collection<java.lang.String> |
getRoles()
User role names
|
User |
getSubstitutedUser()
Substituted user.
|
java.util.TimeZone |
getTimeZone()
User time zone.
|
User |
getUser()
Logged-in user
|
boolean |
hasConstraints()
INTERNAL
|
boolean |
hasConstraints(java.lang.String entityName)
INTERNAL
|
boolean |
isEntityAttrPermitted(MetaClass metaClass,
java.lang.String property,
EntityAttrAccess access)
Check user permission for the entity attribute
|
boolean |
isEntityOpPermitted(MetaClass metaClass,
EntityOp entityOp)
Check user permission for the entity operation
|
boolean |
isPermitted(PermissionType type,
java.lang.String target)
Check user permission.
|
boolean |
isPermitted(PermissionType type,
java.lang.String target,
int value)
Check user permission for the specified value.
|
boolean |
isScreenPermitted(java.lang.String windowAlias)
Check user permission for the screen
|
boolean |
isSpecificPermitted(java.lang.String name)
Check specific user permission
|
boolean |
isSystem()
System session is created by
LoginWorker.loginSystem() for system users like schedulers and JMX. |
void |
removeAttribute(java.lang.String name)
Remove user session attribute.
|
void |
removeConstraint(Constraint constraintToRemove)
INTERNAL
|
void |
removeLocalAttribute(java.lang.String name)
Remove local attribute.
|
void |
removePermission(PermissionType type,
java.lang.String target)
INTERNAL
|
void |
setAddress(java.lang.String address)
INTERNAL
|
void |
setAttribute(java.lang.String name,
java.io.Serializable value)
Set user session attribute.
|
void |
setClientInfo(java.lang.String clientInfo)
INTERNAL
|
void |
setLocalAttribute(java.lang.String name,
java.lang.Object value)
Set local attribute.
|
java.lang.Object |
setLocalAttributeIfAbsent(java.lang.String name,
java.lang.Object value)
Set local attribute.
|
void |
setLocale(java.util.Locale locale)
INTERNAL
|
void |
setSubstitutedUser(User substitutedUser)
INTERNAL
|
void |
setTimeZone(java.util.TimeZone timeZone)
INTERNAL
|
void |
setUser(User user)
INTERNAL
|
java.lang.String |
toString() |
public UserSession()
public UserSession(java.util.UUID id, User user, java.util.Collection<Role> roles, java.util.Locale locale, boolean system)
public UserSession(UserSession src, User user, java.util.Collection<Role> roles, java.util.Locale locale)
public UserSession(UserSession src)
public java.util.UUID getId()
public User getUser()
public void setUser(User user)
public User getSubstitutedUser()
public void setSubstitutedUser(User substitutedUser)
public User getCurrentOrSubstitutedUser()
public java.util.Collection<java.lang.String> getRoles()
public java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
@Nullable public java.util.TimeZone getTimeZone()
public void setTimeZone(java.util.TimeZone timeZone)
public java.lang.String getAddress()
public void setAddress(java.lang.String address)
public java.lang.String getClientInfo()
public void setClientInfo(java.lang.String clientInfo)
public void addPermission(PermissionType type, java.lang.String target, @Nullable java.lang.String extTarget, int value)
public void removePermission(PermissionType type, java.lang.String target)
public java.lang.Integer getPermissionValue(PermissionType type, java.lang.String target)
public java.util.Map<java.lang.String,java.lang.Integer> getPermissionsByType(PermissionType type)
public boolean isScreenPermitted(java.lang.String windowAlias)
public boolean isEntityOpPermitted(MetaClass metaClass, EntityOp entityOp)
public boolean isEntityAttrPermitted(MetaClass metaClass, java.lang.String property, EntityAttrAccess access)
public boolean isSpecificPermitted(java.lang.String name)
public boolean isPermitted(PermissionType type, java.lang.String target)
isPermitted(com.haulmont.cuba.security.entity.PermissionType, String, int)
with value=1
type
- permission typetarget
- permission target:public boolean isPermitted(PermissionType type, java.lang.String target, int value)
type
- permission typetarget
- permission target:value
- method returns true if the corresponding Permission
record contains value equal or greater than specifiedpublic void addConstraint(Constraint constraint)
public void removeConstraint(Constraint constraintToRemove)
public java.util.List<ConstraintData> getConstraints(java.lang.String entityName)
public boolean hasConstraints(java.lang.String entityName)
public boolean hasConstraints()
public java.util.List<ConstraintData> getConstraints(java.lang.String entityName, java.util.function.Predicate<ConstraintData> predicate)
@Nullable public <T> T getAttribute(java.lang.String name)
name
- attribute name. The following names have predefined values:
public void removeAttribute(java.lang.String name)
name
- attribute namepublic void setAttribute(java.lang.String name, java.io.Serializable value)
name
- attribute namevalue
- attribute valuepublic java.util.Collection<java.lang.String> getAttributeNames()
@Nullable public <T> T getLocalAttribute(java.lang.String name)
name
- attribute namepublic void removeLocalAttribute(java.lang.String name)
name
- attribute namepublic void setLocalAttribute(java.lang.String name, java.lang.Object value)
name
- attribute namevalue
- attribute valuepublic java.lang.Object setLocalAttributeIfAbsent(java.lang.String name, java.lang.Object value)
name
- attribute namevalue
- attribute valuenull
if there was no mapping for the key.
(A null
return can also indicate that the map
previously associated null
with the key,
if the implementation supports null values.)public java.util.Collection<java.lang.String> getLocalAttributeNames()
public boolean isSystem()
LoginWorker.loginSystem()
for system users like schedulers and JMX.
It is not replicated in cluster.
public java.lang.String toString()
toString
in class java.lang.Object