public class MemorySubjectData extends Object implements SubjectData
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 |
---|---|
CompletableFuture<Boolean> |
addParent(Set<Context> contexts,
SubjectReference parent)
Adds a parent in a particular context combination.
|
CompletableFuture<Boolean> |
clearOptions()
Clear all options.
|
CompletableFuture<Boolean> |
clearOptions(Set<Context> contexts)
Clear all options in the given context combination.
|
CompletableFuture<Boolean> |
clearParents()
Remove all parents in any context combination.
|
CompletableFuture<Boolean> |
clearParents(Set<Context> contexts)
Remove all parents in a given context combination.
|
CompletableFuture<Boolean> |
clearPermissions()
Clear all permissions set in any context.
|
CompletableFuture<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<SubjectReference>> |
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)
Gets the calculated node tree representation of the permissions for this
subject data instance.
|
Map<String,String> |
getOptions(Set<Context> contexts)
Gets options for a specific context combination.
|
List<SubjectReference> |
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.
|
CompletableFuture<Boolean> |
removeParent(Set<Context> contexts,
SubjectReference parent)
Removes a parent in a particular context combination.
|
CompletableFuture<Boolean> |
setOption(Set<Context> contexts,
String key,
String value)
Sets a specific option to a value.
|
CompletableFuture<Boolean> |
setPermission(Set<Context> contexts,
String permission,
Tristate value)
Sets 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
This list is immutable and is not a live view. If no permissions have been set, it returns an empty list.
getPermissions
in interface SubjectData
contexts
- The particular context combination to checkpublic CompletableFuture<Boolean> setPermission(Set<Context> contexts, String permission, Tristate value)
SubjectData
Setting value as 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 CompletableFuture<Boolean> clearPermissions()
SubjectData
clearPermissions
in interface SubjectData
public CompletableFuture<Boolean> clearPermissions(Set<Context> context)
SubjectData
Passing an empty context set clears permissions in the global context.
clearPermissions
in interface SubjectData
context
- The context combination to clear permissions inpublic Map<Set<Context>,List<SubjectReference>> getAllParents()
SubjectData
The returned map is immutable and not a live view. The results of this method do not traverse any sort of inheritance structure a permissions plugin may implement.
getAllParents
in interface SubjectData
public List<SubjectReference> getParents(Set<Context> contexts)
SubjectData
The returned map is immutable and not a live view. The results of this method do not traverse any sort of inheritance structure a permissions plugin may implement.
getParents
in interface SubjectData
contexts
- The context to checkpublic CompletableFuture<Boolean> addParent(Set<Context> contexts, SubjectReference parent)
SubjectData
Passing an empty context combination means the parent is added in the global context.
addParent
in interface SubjectData
contexts
- The context combination this operation is applicable toparent
- The name of the parent to addpublic CompletableFuture<Boolean> removeParent(Set<Context> contexts, SubjectReference parent)
SubjectData
Passing an empty context combination means the parent is removed in the global context.
removeParent
in interface SubjectData
contexts
- The context combination this operation is applicable toparent
- The name of the parent to removepublic CompletableFuture<Boolean> clearParents()
SubjectData
clearParents
in interface SubjectData
public CompletableFuture<Boolean> clearParents(Set<Context> contexts)
SubjectData
Passing an empty context set clears parents in the global context.
clearParents
in interface SubjectData
contexts
- The context combination to clear the parents ofpublic Map<Set<Context>,Map<String,String>> getAllOptions()
SubjectData
getAllOptions
in interface SubjectData
public Map<String,String> getOptions(Set<Context> contexts)
SubjectData
getOptions
in interface SubjectData
contexts
- The context combination to get options forpublic CompletableFuture<Boolean> setOption(Set<Context> contexts, String key, @Nullable String value)
SubjectData
Passing a null value will unset the option.
setOption
in interface SubjectData
contexts
- The context combination to set the given option inkey
- The key to set. Case-insensitive.value
- The value to set.public CompletableFuture<Boolean> clearOptions(Set<Context> contexts)
SubjectData
Passing an empty context set clears options in the global context.
clearOptions
in interface SubjectData
contexts
- The context combinationpublic CompletableFuture<Boolean> clearOptions()
SubjectData
clearOptions
in interface SubjectData