Class UserAdminPermission
- java.lang.Object
-
- java.security.Permission
-
- java.security.BasicPermission
-
- org.osgi.service.useradmin.UserAdminPermission
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Guard
public final class UserAdminPermission extends java.security.BasicPermissionPermission to configure and access theRoleobjects managed by a User Admin service.This class represents access to the
Roleobjects managed by a User Admin service and their properties and credentials (in the case ofUserobjects).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
UserAdminPermissionwith the reserved name "admin" represents the permission required for creating and removingRoleobjects in the User Admin service, as well as adding and removing members in aGroupobject. ThisUserAdminPermissiondoes 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, andgetCredential. 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
UserAdminPermissionobject:(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 configureGroupobjects.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.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static intACTION_ALLAll actionsprivate static intACTION_CHANGE_CREDENTIALprivate static intACTION_CHANGE_PROPERTYprivate static intACTION_GET_CREDENTIALprivate intaction_maskThe actions mask.(package private) static intACTION_NONENo actions.private java.lang.StringactionsThe actions in canonical form.static java.lang.StringADMINThe permission name "admin".static java.lang.StringCHANGE_CREDENTIALThe action string "changeCredential".static java.lang.StringCHANGE_PROPERTYThe action string "changeProperty".static java.lang.StringGET_CREDENTIALThe action string "getCredential".(package private) static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description UserAdminPermission(java.lang.String name, int mask)Package private constructor used byUserAdminPermissionCollection.UserAdminPermission(java.lang.String name, java.lang.String actions)Creates a newUserAdminPermissionwith the specified name and actions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Checks twoUserAdminPermissionobjects for equality.java.lang.StringgetActions()Returns the canonical string representation of the actions, separated by comma.(package private) intgetActionsMask()Returns the current action mask.inthashCode()Returns the hash code value for this object.booleanimplies(java.security.Permission p)Checks if thisUserAdminPermissionobject "implies" the specified permission.private static booleanmatch_change(char[] a, int i)private static booleanmatch_credential(char[] a, int i)private static booleanmatch_get(char[] a, int i)private static booleanmatch_property(char[] a, int i)java.security.PermissionCollectionnewPermissionCollection()Returns a newPermissionCollectionobject for storingUserAdminPermissionobjects.private static intparseActions(java.lang.String actions)Parse action string into action mask.private voidreadObject(java.io.ObjectInputStream s)private voidsetTransients(int mask)Called by constructors and when deserialized.java.lang.StringtoString()Returns a string describing thisUserAdminPermissionobject.private voidwriteObject(java.io.ObjectOutputStream s)writeObject is called to save the state of this object to a stream.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
ADMIN
public static final java.lang.String ADMIN
The permission name "admin".- See Also:
- Constant Field Values
-
CHANGE_PROPERTY
public static final java.lang.String CHANGE_PROPERTY
The action string "changeProperty".- See Also:
- Constant Field Values
-
ACTION_CHANGE_PROPERTY
private static final int ACTION_CHANGE_PROPERTY
- See Also:
- Constant Field Values
-
CHANGE_CREDENTIAL
public static final java.lang.String CHANGE_CREDENTIAL
The action string "changeCredential".- See Also:
- Constant Field Values
-
ACTION_CHANGE_CREDENTIAL
private static final int ACTION_CHANGE_CREDENTIAL
- See Also:
- Constant Field Values
-
GET_CREDENTIAL
public static final java.lang.String GET_CREDENTIAL
The action string "getCredential".- See Also:
- Constant Field Values
-
ACTION_GET_CREDENTIAL
private static final int ACTION_GET_CREDENTIAL
- See Also:
- Constant Field Values
-
ACTION_ALL
private static final int ACTION_ALL
All actions- See Also:
- Constant Field Values
-
ACTION_NONE
static final int ACTION_NONE
No actions.- See Also:
- Constant Field Values
-
actions
private volatile java.lang.String actions
The actions in canonical form.
-
action_mask
private transient int action_mask
The actions mask.
-
-
Constructor Detail
-
UserAdminPermission
public UserAdminPermission(java.lang.String name, java.lang.String actions)Creates a newUserAdminPermissionwith the specified name and actions.nameis either the reserved string "admin" or the name of a credential or property, andactionscontains a comma-separated list of the actions granted on the specified name. Valid actions arechangeProperty,changeCredential, and getCredential.- Parameters:
name- the name of thisUserAdminPermissionactions- the action string.- Throws:
java.lang.IllegalArgumentException- Ifnameequals "admin" andactionsare specified.
-
UserAdminPermission
UserAdminPermission(java.lang.String name, int mask)Package private constructor used byUserAdminPermissionCollection.- Parameters:
name- class namemask- action mask
-
-
Method Detail
-
setTransients
private void setTransients(int mask)
Called by constructors and when deserialized.- Parameters:
mask- action mask
-
getActionsMask
int getActionsMask()
Returns the current action mask.Used by the UserAdminPermissionCollection class.
- Returns:
- Current action mask.
-
parseActions
private static int parseActions(java.lang.String actions)
Parse action string into action mask.- Parameters:
actions- Action string.- Returns:
- action mask.
-
match_change
private static boolean match_change(char[] a, int i)
-
match_get
private static boolean match_get(char[] a, int i)
-
match_property
private static boolean match_property(char[] a, int i)
-
match_credential
private static boolean match_credential(char[] a, int i)
-
implies
public boolean implies(java.security.Permission p)
Checks if thisUserAdminPermissionobject "implies" the specified permission.More specifically, this method returns
trueif:- 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".
- Overrides:
impliesin classjava.security.BasicPermission- Parameters:
p- the permission to check against.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
- p is an instanceof
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of the actions, separated by comma.- Overrides:
getActionsin classjava.security.BasicPermission- Returns:
- the canonical string representation of the actions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollectionobject for storingUserAdminPermissionobjects.- Overrides:
newPermissionCollectionin classjava.security.BasicPermission- Returns:
- a new
PermissionCollectionobject suitable for storingUserAdminPermissionobjects.
-
equals
public boolean equals(java.lang.Object obj)
Checks twoUserAdminPermissionobjects for equality. Checks thatobjis aUserAdminPermission, and has the same name and actions as this object.- Overrides:
equalsin classjava.security.BasicPermission- Parameters:
obj- the object to be compared for equality with this object.- Returns:
trueifobjis aUserAdminPermissionobject, and has the same name and actions as thisUserAdminPermissionobject.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCodein classjava.security.BasicPermission- Returns:
- A hash code value for this object.
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOExceptionwriteObject is called to save the state of this object to a stream. The actions are serialized, and the superclass takes care of the name.- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
toString
public java.lang.String toString()
Returns a string describing thisUserAdminPermissionobject. This string must be inPermissionInfoencoded format.- Overrides:
toStringin classjava.security.Permission- Returns:
- The
PermissionInfoencoded string for thisUserAdminPermissionobject. - See Also:
- "org.osgi.service.permissionadmin.PermissionInfo.getEncoded()"
-
-