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.BasicPermission
Permission to configure and access theRole
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 ofUser
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 removingRole
objects in the User Admin service, as well as adding and removing members in aGroup
object. ThisUserAdminPermission
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
, 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
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 configureGroup
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.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ADMIN
The permission name "admin".static java.lang.String
CHANGE_CREDENTIAL
The action string "changeCredential".static java.lang.String
CHANGE_PROPERTY
The action string "changeProperty".static java.lang.String
GET_CREDENTIAL
The action string "getCredential".
-
Constructor Summary
Constructors Constructor Description UserAdminPermission(java.lang.String name, java.lang.String actions)
Creates a newUserAdminPermission
with the specified name and actions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Checks twoUserAdminPermission
objects for equality.java.lang.String
getActions()
Returns the canonical string representation of the actions, separated by comma.int
hashCode()
Returns the hash code value for this object.boolean
implies(java.security.Permission p)
Checks if thisUserAdminPermission
object "implies" the specified permission.java.security.PermissionCollection
newPermissionCollection()
Returns a newPermissionCollection
object for storingUserAdminPermission
objects.java.lang.String
toString()
Returns a string describing thisUserAdminPermission
object.
-
-
-
Field Detail
-
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
-
CHANGE_CREDENTIAL
public static final java.lang.String CHANGE_CREDENTIAL
The action string "changeCredential".- See Also:
- Constant Field Values
-
GET_CREDENTIAL
public static final java.lang.String GET_CREDENTIAL
The action string "getCredential".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UserAdminPermission
public UserAdminPermission(java.lang.String name, java.lang.String actions)
Creates a newUserAdminPermission
with the specified name and actions.name
is either the reserved string "admin" or the name of a credential or property, andactions
contains a comma-separated list of the actions granted on the specified name. Valid actions arechangeProperty
,changeCredential
, and getCredential.- Parameters:
name
- the name of thisUserAdminPermission
actions
- the action string.- Throws:
java.lang.IllegalArgumentException
- Ifname
equals "admin" andactions
are specified.
-
-
Method Detail
-
implies
public boolean implies(java.security.Permission p)
Checks if thisUserAdminPermission
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".
- Overrides:
implies
in classjava.security.BasicPermission
- Parameters:
p
- the permission to check against.- Returns:
true
if the specified permission is implied by this object;false
otherwise.
- p is an instanceof
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of the actions, separated by comma.- Overrides:
getActions
in classjava.security.BasicPermission
- Returns:
- the canonical string representation of the actions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollection
object for storingUserAdminPermission
objects.- Overrides:
newPermissionCollection
in classjava.security.BasicPermission
- Returns:
- a new
PermissionCollection
object suitable for storingUserAdminPermission
objects.
-
equals
public boolean equals(java.lang.Object obj)
Checks twoUserAdminPermission
objects for equality. Checks thatobj
is aUserAdminPermission
, and has the same name and actions as this object.- Overrides:
equals
in classjava.security.BasicPermission
- Parameters:
obj
- the object to be compared for equality with this object.- Returns:
true
ifobj
is aUserAdminPermission
object, and has the same name and actions as thisUserAdminPermission
object.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCode
in classjava.security.BasicPermission
- Returns:
- A hash code value for this object.
-
toString
public java.lang.String toString()
Returns a string describing thisUserAdminPermission
object. This string must be inPermissionInfo
encoded format.- Overrides:
toString
in classjava.security.Permission
- Returns:
- The
PermissionInfo
encoded string for thisUserAdminPermission
object. - See Also:
- "org.osgi.service.permissionadmin.PermissionInfo.getEncoded()"
-
-