Class PrivilegeBits
java.lang.Object
org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits
- All Implemented Interfaces:
PrivilegeConstants
Internal representation of JCR privileges.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map<String,PrivilegeBits> static final PrivilegeBitsstatic final PrivilegeBitsFields inherited from interface org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants
AGGREGATE_PRIVILEGES, JCR_ADD_CHILD_NODES, JCR_ALL, JCR_LIFECYCLE_MANAGEMENT, JCR_LOCK_MANAGEMENT, JCR_MODIFY_ACCESS_CONTROL, JCR_MODIFY_PROPERTIES, JCR_NAMESPACE_MANAGEMENT, JCR_NODE_TYPE_DEFINITION_MANAGEMENT, JCR_NODE_TYPE_MANAGEMENT, JCR_READ, JCR_READ_ACCESS_CONTROL, JCR_REMOVE_CHILD_NODES, JCR_REMOVE_NODE, JCR_RETENTION_MANAGEMENT, JCR_VERSION_MANAGEMENT, JCR_WORKSPACE_MANAGEMENT, JCR_WRITE, NON_AGGREGATE_PRIVILEGES, NT_REP_PRIVILEGE, NT_REP_PRIVILEGES, PRIVILEGE_NODETYPE_NAMES, PRIVILEGE_PROPERTY_NAMES, PRIVILEGES_PATH, REP_ADD_PROPERTIES, REP_AGGREGATES, REP_ALTER_PROPERTIES, REP_BITS, REP_INDEX_DEFINITION_MANAGEMENT, REP_IS_ABSTRACT, REP_NEXT, REP_PRIVILEGE_MANAGEMENT, REP_PRIVILEGES, REP_READ_NODES, REP_READ_PROPERTIES, REP_REMOVE_PROPERTIES, REP_USER_MANAGEMENT, REP_WRITE -
Method Summary
Modifier and TypeMethodDescription@NotNull PrivilegeBitsadd(@NotNull PrivilegeBits other) Adds the other privilege bits to this instance.@NotNull PrivilegeBitsaddDifference(@NotNull PrivilegeBits a, @NotNull PrivilegeBits b) Subtracts thebfromaand adds the result (diff) to this instance.@NotNull org.apache.jackrabbit.oak.api.PropertyStateasPropertyState(@NotNull String name) static longcalculatePermissions(@NotNull PrivilegeBits bits, @NotNull PrivilegeBits parentBits, boolean isAllow) Calculate the granted permissions by evaluating the given privileges.@NotNull PrivilegeBitsdiff(@NotNull PrivilegeBits other) Subtracts the other PrivilegeBits from the this.
If the specified bits do not intersect with this, it isn't modified.
Ifthisis included inotheremptyprivilege bits is returned.booleanstatic PrivilegeBitsCreates a mutable instance of privilege bits.static @NotNull PrivilegeBitsgetInstance(@NotNull PrivilegeBits... base) Creates a mutable instance of privilege bits.static @NotNull PrivilegeBitsgetInstance(@Nullable org.apache.jackrabbit.oak.api.PropertyState property) Get or create an instance of privilege bits for a specific property that stores privileges.static @NotNull PrivilegeBitsgetInstance(@Nullable org.apache.jackrabbit.oak.api.Tree tree) Get or create an instance of privilege bits for a privilege definition.inthashCode()booleanincludes(@NotNull PrivilegeBits otherBits) Returnstrueif all privileges defined by the specifiedotherBitsare present in this instance.booleanbooleanisEmpty()Returnstrueif this privilege bits includes no privileges at all.@NotNull PrivilegeBits@NotNull PrivilegeBitsnextBits()Method to calculate the next privilege bits associated with this instance.@NotNull PrivilegeBitsretain(@NotNull PrivilegeBits other) Retains the elements in thisPrivilegeBitsthat are contained in the specified otherPrivilegeBits.toString()@NotNull PrivilegeBitsReturns an unmodifiable instance.voidwriteTo(@NotNull org.apache.jackrabbit.oak.api.Tree tree) Write this instance as property to the specified tree.
-
Field Details
-
EMPTY
-
BUILT_IN
-
NEXT_AFTER_BUILT_INS
-
-
Method Details
-
getInstance
Creates a mutable instance of privilege bits.- Returns:
- a new instance of privilege bits.
-
getInstance
Creates a mutable instance of privilege bits.- Parameters:
base- The base for this mutable instance.- Returns:
- a new instance of privilege bits.
-
getInstance
@NotNull public static @NotNull PrivilegeBits getInstance(@Nullable @Nullable org.apache.jackrabbit.oak.api.PropertyState property) Get or create an instance of privilege bits for a specific property that stores privileges.- Parameters:
property- The property state storing privilege bits information.- Returns:
- an instance of
PrivilegeBits
-
getInstance
@NotNull public static @NotNull PrivilegeBits getInstance(@Nullable @Nullable org.apache.jackrabbit.oak.api.Tree tree) Get or create an instance of privilege bits for a privilege definition.- Parameters:
tree- A privilege definition tree or the privileges root.- Returns:
- an instance of
PrivilegeBits
-
calculatePermissions
public static long calculatePermissions(@NotNull @NotNull PrivilegeBits bits, @NotNull @NotNull PrivilegeBits parentBits, boolean isAllow) Calculate the granted permissions by evaluating the given privileges. Note, that only built-in privileges can be mapped to permissions. Any other privileges will be ignored.- Parameters:
bits- The set of privileges present at given tree.parentBits- The privileges present on the parent tree. These are required in order to determine permissions that include a modification of the parent tree (add_child_nodes, remove_child_nodes).isAllow-trueif the privileges are granted;falseotherwise.- Returns:
- the resulting permissions.
-
isEmpty
public boolean isEmpty()Returnstrueif this privilege bits includes no privileges at all.- Returns:
trueif this privilege bits includes no privileges at all;falseotherwise.- See Also:
-
unmodifiable
Returns an unmodifiable instance.- Returns:
- an unmodifiable
PrivilegeBitsinstance.
-
modifiable
-
includes
Returnstrueif all privileges defined by the specifiedotherBitsare present in this instance.- Parameters:
otherBits-- Returns:
trueif all privileges defined by the specifiedotherBitsare included in this instance;falseotherwise.
-
isBuiltin
public boolean isBuiltin()- Returns:
trueif this instance represents one of the built-in privilege- See Also:
-
add
Adds the other privilege bits to this instance.- Parameters:
other- The other privilege bits to be added.- Returns:
- The updated instance.
- Throws:
UnsupportedOperationException- if this instance is immutable.
-
diff
Subtracts the other PrivilegeBits from the this.
If the specified bits do not intersect with this, it isn't modified.
Ifthisis included inotheremptyprivilege bits is returned.- Parameters:
other- The other privilege bits to be subtracted from this instance.- Returns:
- The updated instance.
- Throws:
UnsupportedOperationException- if this instance is immutable.
-
addDifference
@NotNull public @NotNull PrivilegeBits addDifference(@NotNull @NotNull PrivilegeBits a, @NotNull @NotNull PrivilegeBits b) Subtracts thebfromaand adds the result (diff) to this instance.- Parameters:
a- An instance of privilege bits.b- An instance of privilege bits.- Returns:
- The updated instance.
- Throws:
UnsupportedOperationException- if this instance is immutable.
-
retain
Retains the elements in thisPrivilegeBitsthat are contained in the specified otherPrivilegeBits.- Parameters:
other- Other privilege bits.- Returns:
- This modifiable instance of privilege bits modified such it contains
only privileges that were also contained in the
otherinstance.
-
asPropertyState
@NotNull public @NotNull org.apache.jackrabbit.oak.api.PropertyState asPropertyState(@NotNull @NotNull String name) -
nextBits
Method to calculate the next privilege bits associated with this instance.- Returns:
- an new instance of
PrivilegeBits
-
writeTo
public void writeTo(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree) Write this instance as property to the specified tree.- Parameters:
tree- The target tree.
-
hashCode
public int hashCode() -
equals
-
toString
-