Package org.osgi.framework
Class ServicePermission
- java.lang.Object
-
- java.security.Permission
-
- java.security.BasicPermission
-
- org.osgi.framework.ServicePermission
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Guard
public final class ServicePermission extends java.security.BasicPermissionA bundle's authority to register or get a service.- The
registeraction allows a bundle to register a service on the specified names. - The
getaction allows a bundle to detect a service and get it.
ServicePermissionto get the specific service.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ServicePermission(java.lang.String name, java.lang.String actions)Create a new ServicePermission.ServicePermission(ServiceReference<?> reference, java.lang.String actions)Creates a new requestedServicePermissionobject to be used by code that must performcheckPermissionfor thegetaction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Determines the equality of two ServicePermission objects.java.lang.StringgetActions()Returns the canonical string representation of the actions.inthashCode()Returns the hash code value for this object.booleanimplies(java.security.Permission p)Determines if aServicePermissionobject "implies" the specified permission.java.security.PermissionCollectionnewPermissionCollection()Returns a newPermissionCollectionobject for storingServicePermissionobjects.
-
-
-
Field Detail
-
GET
public static final java.lang.String GET
The action stringget.- See Also:
- Constant Field Values
-
REGISTER
public static final java.lang.String REGISTER
The action stringregister.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServicePermission
public ServicePermission(java.lang.String name, java.lang.String actions)Create a new ServicePermission.The name of the service is specified as a fully qualified class name. Wildcards may be used.
name ::= <class name> | <class name ending in ".*"> | *
Examples:org.osgi.service.http.HttpService org.osgi.service.http.* *
For thegetaction, the name can also be a filter expression. The filter gives access to the service properties as well as the following attributes:- signer - A Distinguished Name chain used to sign the bundle publishing the service. Wildcards in a DN are not matched according to the filter string rules, but according to the rules defined for a DN chain.
- location - The location of the bundle publishing the service.
- id - The bundle ID of the bundle publishing the service.
- name - The symbolic name of the bundle publishing the service.
There are two possible actions:
getandregister. Thegetpermission allows the owner of this permission to obtain a service with this name. Theregisterpermission allows the bundle to register a service under that name.- Parameters:
name- The service class nameactions-get,register(canonical order)- Throws:
java.lang.IllegalArgumentException- If the specified name is a filter expression and either the specified action is notgetor the filter has an invalid syntax.
-
ServicePermission
public ServicePermission(ServiceReference<?> reference, java.lang.String actions)
Creates a new requestedServicePermissionobject to be used by code that must performcheckPermissionfor thegetaction.ServicePermissionobjects created with this constructor cannot be added to aServicePermissionpermission collection.- Parameters:
reference- The requested service.actions- The actionget.- Throws:
java.lang.IllegalArgumentException- If the specified action is notgetor reference isnull.- Since:
- 1.5
-
-
Method Detail
-
implies
public boolean implies(java.security.Permission p)
Determines if aServicePermissionobject "implies" the specified permission.- Overrides:
impliesin classjava.security.BasicPermission- Parameters:
p- The target permission to check.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
-
getActions
public java.lang.String getActions()
Returns the canonical string representation of the actions. Always returns present actions in the following order:get,register.- Overrides:
getActionsin classjava.security.BasicPermission- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollectionobject for storingServicePermissionobjects.- Overrides:
newPermissionCollectionin classjava.security.BasicPermission- Returns:
- A new
PermissionCollectionobject suitable for storingServicePermissionobjects.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of two ServicePermission objects. Checks that specified object has the same class name and action as thisServicePermission.- Overrides:
equalsin classjava.security.BasicPermission- Parameters:
obj- The object to test for equality.- Returns:
- true if obj is a
ServicePermission, and has the same class name and actions as thisServicePermissionobject;falseotherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCodein classjava.security.BasicPermission- Returns:
- Hash code value for this object.
-
-