Top Description Fields Constructors Methods
org.osgi.service.useradmin

public final Class UserAdminPermission

Additional top-level class in compilation unit: UserAdminPermissionCollection.

extends BasicPermission
Class Inheritance
Imports
java.io.IOException, java.security.BasicPermission, .Permission, .PermissionCollection, java.util.ArrayList, .Collections, .Enumeration, .Hashtable, .List

Permission to configure and access the Role objects managed by a User Admin service.

This class represents access to the Role objects managed by a User Admin service and their properties and credentials (in the case of User objects).

The permission name is the name (or name prefix) of a property or credential. The naming convention follows the hierarchical property naming convention. Also, an asterisk may appear at the end of the name, following a ".", or by itself, to signify a wildcard match. For example: "org.osgi.security.protocol.*" or "*" is valid, but "*protocol" or "a*b" are not valid.

The UserAdminPermission with the reserved name "admin" represents the permission required for creating and removing Role objects in the User Admin service, as well as adding and removing members in a Group object. This UserAdminPermission does not have any actions associated with it.

The actions to be granted are passed to the constructor in a string containing a list of one or more comma-separated keywords. The possible keywords are: changeProperty,changeCredential, and getCredential. Their meaning is defined as follows:


 action
 changeProperty    Permission to change (i.e., add and remove)
                   Role object properties whose names start with
                   the name argument specified in the constructor.
 changeCredential  Permission to change (i.e., add and remove)
                   User object credentials whose names start
                   with the name argument specified in the constructor.
 getCredential     Permission to retrieve and check for the
                   existence of User object credentials whose names
                   start with the name argument specified in the
                   constructor.

The action string is converted to lowercase before processing.

Following is a PermissionInfo style policy entry which grants a user administration bundle a number of UserAdminPermission object:


 (org.osgi.service.useradmin.UserAdminPermission "admin")
 (org.osgi.service.useradmin.UserAdminPermission "com.foo.*"
               "changeProperty,getCredential,changeCredential")
 (org.osgi.service.useradmin.UserAdminPermission "user.*"
                             "changeProperty,changeCredential")

The first permission statement grants the bundle the permission to perform any User Admin service operations of type "admin", that is, create and remove roles and configure Group objects.

The second permission statement grants the bundle the permission to change any properties as well as get and change any credentials whose names start with com.foo..

The third permission statement grants the bundle the permission to change any properties and credentials whose names start with user.. This means that the bundle is allowed to change, but not retrieve any credentials with the given prefix.

The following policy entry empowers the Http Service bundle to perform user authentication:


 grant codeBase "${jars}http.jar" {
   permission org.osgi.service.useradmin.UserAdminPermission
     "user.password", "getCredential";
 };

The permission statement grants the Http Service bundle the permission to validate any password credentials (for authentication purposes), but the bundle is not allowed to change any properties or credentials.

Author
$Id: 33a82bc2d3cd5194b5968582da62f36cc0dc930f $

Field Summary

Modifier and TypeField and Description
private static final int
ACTION_ALL

All actions

private static final int
private static final int
private static final int
private transient int
action_mask

The actions mask.

pack-priv static final int
ACTION_NONE

No actions.

private volatile String
actions

The actions in canonical form.

public static final String
ADMIN

The permission name "admin".

public static final String
CHANGE_CREDENTIAL

The action string "changeCredential".

public static final String
CHANGE_PROPERTY

The action string "changeProperty".

public static final String
GET_CREDENTIAL

The action string "getCredential".

pack-priv static final long

Constructor Summary

AccessConstructor and Description
public
UserAdminPermission(String
the name of this UserAdminPermission
name
,
String
the action string.
actions
)

Creates a new UserAdminPermission with the specified name and actions.

pack-priv
UserAdminPermission(String
class name
name
,
int
action mask
mask
)

Package private constructor used by UserAdminPermissionCollection .

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is a UserAdminPermission object, and has the same name and actions as this UserAdminPermission object.
equals
(Object
the object to be compared for equality with this object.
obj
)

Overrides java.security.BasicPermission.equals.

Checks two UserAdminPermission objects for equality.

public String

Returns:

the canonical string representation of the actions.
getActions
()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the actions, separated by comma.

pack-priv synchronized int

Returns:

Current action mask.
getActionsMask
()

Returns the current action mask.

public int

Returns:

A hash code value for this object.
hashCode
()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified permission is implied by this object; false otherwise.
implies
(Permission
the permission to check against.
p
)

Overrides java.security.BasicPermission.implies.

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

private static boolean
match_change(char[] a, int i)

private static boolean
match_credential(char[] a, int i)

private static boolean
match_get(char[] a, int i)

private static boolean
match_property(char[] a, int i)

public PermissionCollection

Returns:

a new PermissionCollection object suitable for storing UserAdminPermission objects.
newPermissionCollection
()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object for storing UserAdminPermission objects.

private static int

Returns:

action mask.
parseActions
(String
Action string.
actions
)

Parse action string into action mask.

private synchronized void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Hides java.security.BasicPermission.readObject.

readObject is called to restore the state of the BasicPermission from a stream.

private synchronized void
setTransients(int
action mask
mask
)

Called by constructors and when deserialized.

public String

Returns:

The PermissionInfo encoded string for this UserAdminPermission object.
toString
()

Overrides java.security.Permission.toString.

Returns a string describing this UserAdminPermission object.

private synchronized void
writeObject(ObjectOutputStream s)

writeObject is called to save the state of this object to a stream.

Field Detail

ACTION_ALLback to summary
private static final int ACTION_ALL

All actions

ACTION_CHANGE_CREDENTIALback to summary
private static final int ACTION_CHANGE_CREDENTIAL
ACTION_CHANGE_PROPERTYback to summary
private static final int ACTION_CHANGE_PROPERTY
ACTION_GET_CREDENTIALback to summary
private static final int ACTION_GET_CREDENTIAL
action_maskback to summary
private transient int action_mask

The actions mask.

ACTION_NONEback to summary
pack-priv static final int ACTION_NONE

No actions.

actionsback to summary
private volatile String actions

The actions in canonical form.

ADMINback to summary
public static final String ADMIN

The permission name "admin".

CHANGE_CREDENTIALback to summary
public static final String CHANGE_CREDENTIAL

The action string "changeCredential".

CHANGE_PROPERTYback to summary
public static final String CHANGE_PROPERTY

The action string "changeProperty".

GET_CREDENTIALback to summary
public static final String GET_CREDENTIAL

The action string "getCredential".

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.security.BasicPermission.serialVersionUID.

Constructor Detail

UserAdminPermissionback to summary
public UserAdminPermission(String name, String actions)

Creates a new UserAdminPermission with the specified name and actions. name is either the reserved string "admin" or the name of a credential or property, and actions contains a comma-separated list of the actions granted on the specified name. Valid actions are changeProperty,changeCredential, and getCredential.

Parameters
name:String

the name of this UserAdminPermission

actions:String

the action string.

Exceptions
IllegalArgumentException:
If name equals "admin" and actions are specified.
UserAdminPermissionback to summary
pack-priv UserAdminPermission(String name, int mask)

Package private constructor used by UserAdminPermissionCollection .

Parameters
name:String

class name

mask:int

action mask

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.security.BasicPermission.equals.

Checks two UserAdminPermission objects for equality. Checks that obj is a UserAdminPermission, and has the same name and actions as this object.

Parameters
obj:Object

the object to be compared for equality with this object.

Returns:boolean

true if obj is a UserAdminPermission object, and has the same name and actions as this UserAdminPermission object.

Annotations
@Override
getActionsback to summary
public String getActions()

Overrides java.security.BasicPermission.getActions.

Returns the canonical string representation of the actions, separated by comma.

Returns:String

the canonical string representation of the actions.

Annotations
@Override
getActionsMaskback to summary
pack-priv synchronized int getActionsMask()

Returns the current action mask.

Used by the UserAdminPermissionCollection class.

Returns:int

Current action mask.

hashCodeback to summary
public int hashCode()

Overrides java.security.BasicPermission.hashCode.

Returns the hash code value for this object.

Returns:int

A hash code value for this object.

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

Overrides java.security.BasicPermission.implies.

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

More specifically, this method returns true if:

  • p is an instanceof UserAdminPermission,
  • p's actions are a proper subset of this object's actions, and
  • p's name is implied by this object's name. For example, "java.*" implies "java.home".
Parameters
p:Permission

the permission to check against.

Returns:boolean

true if the specified permission is implied by this object; false otherwise.

Annotations
@Override
match_changeback to summary
private static boolean match_change(char[] a, int i)
match_credentialback to summary
private static boolean match_credential(char[] a, int i)
match_getback to summary
private static boolean match_get(char[] a, int i)
match_propertyback to summary
private static boolean match_property(char[] a, int i)
newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.BasicPermission.newPermissionCollection.

Returns a new PermissionCollection object for storing UserAdminPermission objects.

Returns:PermissionCollection

a new PermissionCollection object suitable for storing UserAdminPermission objects.

Annotations
@Override
parseActionsback to summary
private static int parseActions(String actions)

Parse action string into action mask.

Parameters
actions:String

Action string.

Returns:int

action mask.

readObjectback to summary
private synchronized void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Hides java.security.BasicPermission.readObject.

Doc from java.security.BasicPermission.readObject.

readObject is called to restore the state of the BasicPermission from a stream.

Parameters
s:ObjectInputStream

the ObjectInputStream from which data is read

Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
setTransientsback to summary
private synchronized void setTransients(int mask)

Called by constructors and when deserialized.

Parameters
mask:int

action mask

toStringback to summary
public String toString()

Overrides java.security.Permission.toString.

Returns a string describing this UserAdminPermission object. This string must be in PermissionInfo encoded format.

Returns:String

The PermissionInfo encoded string for this UserAdminPermission object.

Annotations
@Override
See Also
org.osgi.service.permissionadmin.PermissionInfo.getEncoded()
writeObjectback to summary
private synchronized void writeObject(ObjectOutputStream s) throws IOException

writeObject is called to save the state of this object to a stream. The actions are serialized, and the superclass takes care of the name.