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()
SubjectDatagetAllPermissions in interface SubjectDatapublic NodeTree getNodeTree(Set<Context> contexts)
contexts - The contexts to get a node tree forpublic Map<String,Boolean> getPermissions(Set<Context> contexts)
SubjectDataThis list is immutable and is not a live view. If no permissions have been set, it returns an empty list.
getPermissions in interface SubjectDatacontexts - The particular context combination to checkpublic CompletableFuture<Boolean> setPermission(Set<Context> contexts, String permission, Tristate value)
SubjectDataSetting value as Tristate.UNDEFINED unsets the permission.
An empty set of contexts applies this permission to the global context.
setPermission in interface SubjectDatacontexts - The particular combination of contexts to set this
permission inpermission - The permission to setvalue - The value to set this permission topublic CompletableFuture<Boolean> clearPermissions()
SubjectDataclearPermissions in interface SubjectDatapublic CompletableFuture<Boolean> clearPermissions(Set<Context> context)
SubjectDataPassing an empty context set clears permissions in the global context.
clearPermissions in interface SubjectDatacontext - The context combination to clear permissions inpublic Map<Set<Context>,List<SubjectReference>> getAllParents()
SubjectDataThe 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 SubjectDatapublic List<SubjectReference> getParents(Set<Context> contexts)
SubjectDataThe 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 SubjectDatacontexts - The context to checkpublic CompletableFuture<Boolean> addParent(Set<Context> contexts, SubjectReference parent)
SubjectDataPassing an empty context combination means the parent is added in the global context.
addParent in interface SubjectDatacontexts - The context combination this operation is applicable toparent - The name of the parent to addpublic CompletableFuture<Boolean> removeParent(Set<Context> contexts, SubjectReference parent)
SubjectDataPassing an empty context combination means the parent is removed in the global context.
removeParent in interface SubjectDatacontexts - The context combination this operation is applicable toparent - The name of the parent to removepublic CompletableFuture<Boolean> clearParents()
SubjectDataclearParents in interface SubjectDatapublic CompletableFuture<Boolean> clearParents(Set<Context> contexts)
SubjectDataPassing an empty context set clears parents in the global context.
clearParents in interface SubjectDatacontexts - The context combination to clear the parents ofpublic Map<Set<Context>,Map<String,String>> getAllOptions()
SubjectDatagetAllOptions in interface SubjectDatapublic Map<String,String> getOptions(Set<Context> contexts)
SubjectDatagetOptions in interface SubjectDatacontexts - The context combination to get options forpublic CompletableFuture<Boolean> setOption(Set<Context> contexts, String key, @Nullable String value)
SubjectDataPassing a null value will unset the option.
setOption in interface SubjectDatacontexts - 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)
SubjectDataPassing an empty context set clears options in the global context.
clearOptions in interface SubjectDatacontexts - The context combinationpublic CompletableFuture<Boolean> clearOptions()
SubjectDataclearOptions in interface SubjectData