public class MemorySubjectData extends Object implements OptionSubjectData
This class is thread-safe.
GLOBAL_CONTEXT
Constructor and Description |
---|
MemorySubjectData(PermissionService service)
Creates a new subject data instance, using the provided service to request instances of permission subjects.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addParent(Set<Context> contexts,
Subject parent)
Adds a parent in a particular context combination.
|
boolean |
clearOptions()
Clear all options.
|
boolean |
clearOptions(Set<Context> contexts)
Clear all options in the given context combination.
|
boolean |
clearParents()
Remove all parents in any context combination.
|
boolean |
clearParents(Set<Context> contexts)
Remove all parents in a given context combination.
|
boolean |
clearPermissions()
Clear all permissions set in any context.
|
boolean |
clearPermissions(Set<Context> context)
Clear all permissions set in a given context combination.
|
Map<Set<Context>,Map<String,String>> |
getAllOptions()
Return all options for all context combinations currently registered.
|
Map<Set<Context>,List<Subject>> |
getAllParents()
Return all registered parent subjects for all contexts.
|
Map<Set<Context>,Map<String,Boolean>> |
getAllPermissions()
Return all permissions associated with this data object.
|
NodeTree |
getNodeTree(Set<Context> contexts)
Get the calculated node tree representation of the permissions for this subject data instance.
|
Map<String,String> |
getOptions(Set<Context> contexts)
Get options for a specific context combination.
|
List<Subject> |
getParents(Set<Context> contexts)
Return all registered parent subjects for a given context.
|
Map<String,Boolean> |
getPermissions(Set<Context> contexts)
Returns the list of permissions set for the given context.
|
boolean |
removeParent(Set<Context> contexts,
Subject parent)
Removes a parent in a particular context combination.
|
boolean |
setOption(Set<Context> contexts,
String key,
String value)
Set a specific option to a value.
|
boolean |
setPermission(Set<Context> contexts,
String permission,
Tristate value)
Set a permission to a given value.
|
public MemorySubjectData(PermissionService service)
service
- The service to request subjects frompublic Map<Set<Context>,Map<String,Boolean>> getAllPermissions()
SubjectData
getAllPermissions
in interface SubjectData
public NodeTree getNodeTree(Set<Context> contexts)
contexts
- The contexts to get a node tree forpublic Map<String,Boolean> getPermissions(Set<Context> contexts)
SubjectData
getPermissions
in interface SubjectData
contexts
- The particular context combination to checkpublic boolean setPermission(Set<Context> contexts, String permission, Tristate value)
SubjectData
Tristate.UNDEFINED
unsets the permission. An empty set of
contexts applies this permission to the global context.setPermission
in interface SubjectData
contexts
- The particular combination of contexts to set this
permission inpermission
- The permission to setvalue
- The value to set this permission topublic boolean clearPermissions()
SubjectData
clearPermissions
in interface SubjectData
public boolean clearPermissions(Set<Context> context)
SubjectData
clearPermissions
in interface SubjectData
context
- The context combination to clear permissions inpublic Map<Set<Context>,List<Subject>> getAllParents()
SubjectData
getAllParents
in interface SubjectData
public List<Subject> getParents(Set<Context> contexts)
SubjectData
getParents
in interface SubjectData
contexts
- The context to checkpublic boolean addParent(Set<Context> contexts, Subject parent)
SubjectData
addParent
in interface SubjectData
contexts
- The context combination this operation is applicable toparent
- The name of the parent to addpublic boolean removeParent(Set<Context> contexts, Subject parent)
SubjectData
removeParent
in interface SubjectData
contexts
- The context combination this operation is applicable toparent
- The name of the parent to removepublic boolean clearParents()
SubjectData
clearParents
in interface SubjectData
public boolean clearParents(Set<Context> contexts)
SubjectData
clearParents
in interface SubjectData
contexts
- The context combination to clear the parents ofpublic Map<Set<Context>,Map<String,String>> getAllOptions()
OptionSubjectData
getAllOptions
in interface OptionSubjectData
public Map<String,String> getOptions(Set<Context> contexts)
OptionSubjectData
getOptions
in interface OptionSubjectData
contexts
- The context combination to get options forpublic boolean setOption(Set<Context> contexts, String key, @Nullable String value)
OptionSubjectData
setOption
in interface OptionSubjectData
contexts
- The context combination to set the given option inkey
- The key to set. Case-insensitive.value
- The value to set.public boolean clearOptions(Set<Context> contexts)
OptionSubjectData
clearOptions
in interface OptionSubjectData
contexts
- The context combinationpublic boolean clearOptions()
OptionSubjectData
clearOptions
in interface OptionSubjectData