Package com.avoka.core.security
Class UserContext
- java.lang.Object
-
- com.avoka.core.security.UserContext
-
public class UserContext extends Object
Provides a thread local user context object.
-
-
Constructor Summary
Constructors Constructor Description UserContext(String userName)Constructor for the classUserContext(String userName, Set<String> permissions)Constructor for the class
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getPermissions()Return a set of permissions for the user context object.static UserContextgetThreadUserContext()Return thread local user context object.StringgetUserName()Return user name for the user context object.booleanhasPermission(String permission)Check whether the permission is in the permissions set.voidsetPermissions(Set<String> permissions)Set a set of permissions to the user context object.static voidsetThreadUserContext(UserContext userContext)Set thread local user context object.voidsetUserName(String userName)Set user name for the user context object.StringtoString()Returns a string representation of the object.
-
-
-
Method Detail
-
getThreadUserContext
public static UserContext getThreadUserContext()
Return thread local user context object.- Returns:
- thread local user context object
-
setThreadUserContext
public static void setThreadUserContext(UserContext userContext)
Set thread local user context object.- Parameters:
userContext- user context object
-
getUserName
public String getUserName()
Return user name for the user context object.- Returns:
- user name
-
setUserName
public void setUserName(String userName)
Set user name for the user context object.- Parameters:
userName- user name
-
getPermissions
public Set<String> getPermissions()
Return a set of permissions for the user context object.- Returns:
- a set of permissions
-
setPermissions
public void setPermissions(Set<String> permissions)
Set a set of permissions to the user context object.- Parameters:
permissions- a set of permissions
-
hasPermission
public boolean hasPermission(String permission)
Check whether the permission is in the permissions set.- Parameters:
permission- a permission- Returns:
- ture if the permission is in the set
-
toString
public String toString()
Returns a string representation of the object. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the character[, the user name, permissions set and]. In other words, this method returns a string equal to the value of:getClass().getSimpleName() + "[userName=" + userName + ",permissions=" + permissions + "]";
- Overrides:
toStringin classObject- Returns:
- a string representation of the object.
- See Also:
Object.toString()
-
-