Top Description Fields Constructors Methods
org.osgi.service.dmt.security

public Class DmtPermission

Additional top-level class in compilation unit: DmtPermissionCollection.

extends Permission
Class Inheritance
Imports
java.security.Permission, .PermissionCollection, java.util.ArrayList, .Collections, .Enumeration, .Iterator, .StringTokenizer, org.osgi.service.dmt.Acl, .Uri

Controls access to management objects in the Device Management Tree (DMT). It is intended to control local access to the DMT. DmtPermission target string identifies the management object URI and the action field lists the OMA DM commands that are permitted on the management object. Example:
DmtPermission("./OSGi/bundles", "Add,Replace,Get");
This means that owner of this permission can execute Add, Replace and Get commands on the ./OSGi/bundles management object. It is possible to use wildcards in both the target and the actions field. Wildcard in the target field means that the owner of the permission can access children nodes of the target node. Example:
DmtPermission("./OSGi/bundles/*", "Get");
This means that owner of this permission has Get access on every child node of ./OSGi/bundles. The asterisk does not necessarily have to follow a '/' character. For example the "./OSGi/a*" target matches the ./OSGi/applications subtree.

If wildcard is present in the actions field, all legal OMA DM commands are allowed on the designated nodes(s) by the owner of the permission. Action names are interpreted case-insensitively, but the canonical action string returned by getActions() uses the forms defined by the action constants.

Author
$Id: cba01575d5c18e8b462c6b1fb399dba69c5e21bd $

Field Summary

Modifier and TypeField and Description
private final String
public static final String
ADD

Holders of DmtPermission with the Add action present can create new nodes in the DMT, that is they are authorized to execute the createInteriorNode() and createLeafNode() methods of the DmtSession.

public static final String
DELETE

Holders of DmtPermission with the Delete action present can delete nodes from the DMT, that is they are authorized to execute the deleteNode() method of the DmtSession.

public static final String
EXEC

Holders of DmtPermission with the Exec action present can execute nodes in the DMT, that is they are authorized to call the execute() method of the DmtSession.

public static final String
GET

Holders of DmtPermission with the Get action present can query DMT node value or properties, that is they are authorized to execute the isLeafNode(), getNodeAcl(), getEffectiveNodeAcl(), getMetaNode(), getNodeValue(), getChildNodeNames(), getNodeTitle(), getNodeVersion(), getNodeTimeStamp(), getNodeSize() and getNodeType() methods of the DmtSession.

private final int
private final String
private final boolean
public static final String
REPLACE

Holders of DmtPermission with the Replace action present can update DMT node value or properties, that is they are authorized to execute the setNodeAcl(), setNodeTitle(), setNodeValue(), setNodeType() and renameNode() methods of the DmtSession.

private static final long

Constructor Summary

AccessConstructor and Description
public
DmtPermission(String
URI of the management object (or subtree)
dmtUri
,
String
OMA DM actions allowed
actions
)

Creates a new DmtPermission object for the specified DMT URI with the specified actions.

Method Summary

Modifier and TypeMethod and Description
private static void
addAction(StringBuilder sb, int mask, int flag, String action)

private static String
canonicalActions(int mask)

private void
checkUri(String dmtUri)

public boolean

Returns:

true if the parameter represents the same permissions as this instance
equals
(Object
the object to compare to this DmtPermission instance
obj
)

Implements abstract java.security.Permission.equals.

Checks whether the given object is equal to this DmtPermission instance.

public String

Returns:

canonical action list for this permission object
getActions
()

Implements abstract java.security.Permission.getActions.

Returns the String representation of the action list.

private static int
getMask(String actions)

pack-priv int
public int

Returns:

hash code for this permission object
hashCode
()

Implements abstract java.security.Permission.hashCode.

Returns the hash code for this permission object.

public boolean

Returns:

true if this DmtPermission instance implies the specified permission
implies
(Permission
the permission to check for implication
p
)

Implements abstract java.security.Permission.implies.

Checks if this DmtPermission object "implies" the specified permission.

pack-priv boolean
public PermissionCollection

Returns:

the new PermissionCollection
newPermissionCollection
()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object for storing DmtPermission objects.

Inherited from java.security.Permission:
checkGuardgetNametoString

Field Detail

actionsback to summary
private final String actions
ADDback to summary
public static final String ADD

Holders of DmtPermission with the Add action present can create new nodes in the DMT, that is they are authorized to execute the createInteriorNode() and createLeafNode() methods of the DmtSession. This action is also required for the copy() command, which needs to perform node creation operations (among others).

DELETEback to summary
public static final String DELETE

Holders of DmtPermission with the Delete action present can delete nodes from the DMT, that is they are authorized to execute the deleteNode() method of the DmtSession.

EXECback to summary
public static final String EXEC

Holders of DmtPermission with the Exec action present can execute nodes in the DMT, that is they are authorized to call the execute() method of the DmtSession.

GETback to summary
public static final String GET

Holders of DmtPermission with the Get action present can query DMT node value or properties, that is they are authorized to execute the isLeafNode(), getNodeAcl(), getEffectiveNodeAcl(), getMetaNode(), getNodeValue(), getChildNodeNames(), getNodeTitle(), getNodeVersion(), getNodeTimeStamp(), getNodeSize() and getNodeType() methods of the DmtSession. This action is also required for the copy() command, which needs to perform node query operations (among others).

maskback to summary
private final int mask
pathback to summary
private final String path
prefixPathback to summary
private final boolean prefixPath
REPLACEback to summary
public static final String REPLACE

Holders of DmtPermission with the Replace action present can update DMT node value or properties, that is they are authorized to execute the setNodeAcl(), setNodeTitle(), setNodeValue(), setNodeType() and renameNode() methods of the DmtSession. This action is also be required for the copy() command if the original node had a title property (which must be set in the new node).

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.Permission.serialVersionUID.

Constructor Detail

DmtPermissionback to summary
public DmtPermission(String dmtUri, String actions)

Creates a new DmtPermission object for the specified DMT URI with the specified actions. The given URI can be:

  • "*", which matches all valid (see Uri#isValidUri(String)) absolute URIs;
  • the prefix of an absolute URI followed by the * character (for example "./OSGi/L*"), which matches all valid absolute URIs beginning with the given prefix;
  • a valid absolute URI, which matches itself.

Since the * character is itself a valid URI character, it can appear as the last character of a valid absolute URI. To distinguish this case from using * as a wildcard, the * character at the end of the URI must be escaped with the \ character. For example the URI "./a*" matches "./a", "./aa", "./a/b" etc. while "./a\*" matches "./a*" only.

The actions string must either be "*" to allow all actions, or it must contain a non-empty subset of the valid actions, defined as constants in this class.

Parameters
dmtUri:String

URI of the management object (or subtree)

actions:String

OMA DM actions allowed

Exceptions
NullPointerException:
if any of the parameters are null
IllegalArgumentException:
if any of the parameters are invalid

Method Detail

addActionback to summary
private static void addAction(StringBuilder sb, int mask, int flag, String action)
canonicalActionsback to summary
private static String canonicalActions(int mask)
checkUriback to summary
private void checkUri(String dmtUri) throws IllegalArgumentException
equalsback to summary
public boolean equals(Object obj)

Implements abstract java.security.Permission.equals.

Checks whether the given object is equal to this DmtPermission instance. Two DmtPermission instances are equal if they have the same target string and the same action mask. The "*" action mask is considered equal to a mask containing all actions.

Parameters
obj:Object

the object to compare to this DmtPermission instance

Returns:boolean

true if the parameter represents the same permissions as this instance

Annotations
@Override
getActionsback to summary
public String getActions()

Implements abstract java.security.Permission.getActions.

Returns the String representation of the action list. The allowed actions are listed in the following order: Add, Delete, Exec, Get, Replace. The wildcard character is not used in the returned string, even if the class was created using the "*" wildcard.

Returns:String

canonical action list for this permission object

Annotations
@Override
getMaskback to summary
private static int getMask(String actions)
getMaskback to summary
pack-priv int getMask()
hashCodeback to summary
public int hashCode()

Implements abstract java.security.Permission.hashCode.

Returns the hash code for this permission object. If two DmtPermission objects are equal according to the equals(Object) method, then calling this method on each of the two DmtPermission objects must produce the same integer result.

Returns:int

hash code for this permission object

Annotations
@Override
impliesback to summary
public boolean implies(Permission p)

Implements abstract java.security.Permission.implies.

Checks if this DmtPermission object "implies" the specified permission. This method returns false if and only if at least one of the following conditions are fulfilled for the specified permission:

  • it is not a DmtPermission
  • its set of actions contains an action not allowed by this permission
  • the set of nodes defined by its path contains a node not defined by the path of this permission
Parameters
p:Permission

the permission to check for implication

Returns:boolean

true if this DmtPermission instance implies the specified permission

Annotations
@Override
impliesPathback to summary
pack-priv boolean impliesPath(DmtPermission p)
newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object for storing DmtPermission objects.

Returns:PermissionCollection

the new PermissionCollection

Annotations
@Override