public abstract class BitFlagsResource extends AbstractResource implements BitFlagsConstants
Rights objects for this resource are made of one bitfield with 8 bits. The first four bits
correspond to the create, delete, read and write respectively. There are 3 reserved bits.
The last bit is for explicit denial of access. When printed, they are shown as
CDRW...N
.
Resource names will be namespaced using the subclass' resource type name. The naming approach
is /resource_type_name/instance_name
. Each different instance of a particular
resource type will share the same type name but must have a unique, non-empty instance name.
objectPointer, resourceIndex, sm
BIT_CREATE_ACCESS, BIT_DELETE_ACCESS, BIT_DENIED_ACCESS, BIT_READ_ACCESS, BIT_WRITE_ACCESS, BITSET_SIZE
Constructor and Description |
---|
BitFlagsResource()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accessWorker(java.lang.String name,
int bit)
Implements generalized access rights check worker.
|
boolean |
canCreate(java.lang.String name)
Reports if CREATE is allowed for the given resource name.
|
boolean |
canDelete(java.lang.String name)
Reports if DELETE is allowed for the given resource name.
|
boolean |
canRead(java.lang.String name)
Reports if READ is allowed for the given resource name.
|
boolean |
canWrite(java.lang.String name)
Reports if WRITE is allowed for the given resource name.
|
Description[] |
describeRights()
Returns an array of descriptions, one object per the plugin's access rights item.
|
Rights |
getRightsInstance(java.lang.Object[] rights)
Converts from the persistent form of the plugin's rights to the specific in-memory
type.
|
java.lang.String |
getTypeName()
Returns the plugin's resource type name as a string.
|
boolean |
isInstanceNameValid(java.lang.String resource)
Checks whether a given string is a valid resource name for this resource type.
|
boolean |
isRightsSetValid(java.lang.Object[] rights)
Checks whether a given array of objects representing a set of access
rights fields is acceptable.
|
abstract java.util.Set<java.lang.String> |
resourceTypeName()
Obtains the set of all possible valid resource type names.
|
associate, attach, disassociate, getEnclosingScope, getLibrary, getLink, getPermissions, init, refresh, registeredAs, toString
public abstract java.util.Set<java.lang.String> resourceTypeName()
public java.lang.String getTypeName()
getTypeName
in interface Resource
public Description[] describeRights()
This plugin uses one field of type BitField with three bits: read, write end execute.
describeRights
in interface Resource
public Rights getRightsInstance(java.lang.Object[] rights)
getRightsInstance
in interface Resource
rights
- An array of objects of proper types representing items in a set
of access rights.public boolean isInstanceNameValid(java.lang.String resource)
Valid names are of the form /resource_type_name/instance_name
where instance_name
is a non-empty string which has no whitespace and which uniquely identifies a given
resource instance and where resource_type_name is shared across all resources of the same
type. Resource names are NOT case sensitive.
isInstanceNameValid
in interface Resource
resource
- The possible name to validate.true
if the name is syntactically correctpublic boolean isRightsSetValid(java.lang.Object[] rights)
This method returns true
only if:
isRightsSetValid
in interface Resource
rights
- An array of objects of proper types representing items in a set of access rights.true
if the array is acceptable for an instance of access rights.public boolean canCreate(java.lang.String name)
name
- Resource instance name.true
if access is allowed.public boolean canDelete(java.lang.String name)
name
- Resource instance name.true
if access is allowed.public boolean canRead(java.lang.String name)
name
- Resource instance name.true
if access is allowed.public boolean canWrite(java.lang.String name)
name
- Resource instance name.true
if access is allowed.public boolean accessWorker(java.lang.String name, int bit)
name
- Resource instance name.bit
- The bit to check.true
if access is allowed.