Package org.osgi.framework
Class ServicePermission
java.lang.Object
java.security.Permission
java.security.BasicPermission
org.osgi.framework.ServicePermission
- All Implemented Interfaces:
Serializable,Guard
A 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.
ServicePermission
to get the specific service.- Author:
- $Id: ff7fc46dd623c0a09b49965048dd6faa2b111b39 $
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServicePermission(String name, String actions) Create a new ServicePermission.ServicePermission(ServiceReference<?> reference, String actions) Creates a new requestedServicePermissionobject to be used by code that must performcheckPermissionfor thegetaction. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines the equality of two ServicePermission objects.Returns the canonical string representation of the actions.inthashCode()Returns the hash code value for this object.booleanDetermines if aServicePermissionobject "implies" the specified permission.Returns a newPermissionCollectionobject for storingServicePermissionobjects.Methods inherited from class java.security.Permission
checkGuard, getName, toString
-
Field Details
-
GET
The action stringget.- See Also:
-
REGISTER
The action stringregister.- See Also:
-
-
Constructor Details
-
ServicePermission
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:
IllegalArgumentException- If the specified name is a filter expression and either the specified action is notgetor the filter has an invalid syntax.
-
ServicePermission
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:
IllegalArgumentException- If the specified action is notgetor reference isnull.- Since:
- 1.5
-
-
Method Details
-
implies
Determines if aServicePermissionobject "implies" the specified permission.- Overrides:
impliesin classBasicPermission- Parameters:
p- The target permission to check.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
-
getActions
Returns the canonical string representation of the actions. Always returns present actions in the following order:get,register.- Overrides:
getActionsin classBasicPermission- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
Returns a newPermissionCollectionobject for storingServicePermissionobjects.- Overrides:
newPermissionCollectionin classBasicPermission- Returns:
- A new
PermissionCollectionobject suitable for storingServicePermissionobjects.
-
equals
Determines the equality of two ServicePermission objects. Checks that specified object has the same class name and action as thisServicePermission.- Overrides:
equalsin classBasicPermission- 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 classBasicPermission- Returns:
- Hash code value for this object.
-