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
register
action allows a bundle to register a service on the specified names. - The
get
action allows a bundle to detect a service and get it.
ServicePermission
to get the specific service.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionServicePermission
(String name, String actions) Create a new ServicePermission.ServicePermission
(ServiceReference<?> reference, String actions) Creates a new requestedServicePermission
object to be used by code that must performcheckPermission
for theget
action. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines the equality of two ServicePermission objects.Returns the canonical string representation of the actions.int
hashCode()
Returns the hash code value for this object.boolean
Determines if aServicePermission
object "implies" the specified permission.Returns a newPermissionCollection
object for storingServicePermission
objects.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 theget
action, 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:
get
andregister
. Theget
permission allows the owner of this permission to obtain a service with this name. Theregister
permission 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 notget
or the filter has an invalid syntax.
-
ServicePermission
Creates a new requestedServicePermission
object to be used by code that must performcheckPermission
for theget
action.ServicePermission
objects created with this constructor cannot be added to aServicePermission
permission collection.- Parameters:
reference
- The requested service.actions
- The actionget
.- Throws:
IllegalArgumentException
- If the specified action is notget
or reference isnull
.- Since:
- 1.5
-
-
Method Details
-
implies
Determines if aServicePermission
object "implies" the specified permission.- Overrides:
implies
in classBasicPermission
- Parameters:
p
- The target permission to check.- Returns:
true
if the specified permission is implied by this object;false
otherwise.
-
getActions
Returns the canonical string representation of the actions. Always returns present actions in the following order:get
,register
.- Overrides:
getActions
in classBasicPermission
- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
Returns a newPermissionCollection
object for storingServicePermission
objects.- Overrides:
newPermissionCollection
in classBasicPermission
- Returns:
- A new
PermissionCollection
object suitable for storingServicePermission
objects.
-
equals
Determines the equality of two ServicePermission objects. Checks that specified object has the same class name and action as thisServicePermission
.- Overrides:
equals
in 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 thisServicePermission
object;false
otherwise.
-
hashCode
public int hashCode()Returns the hash code value for this object.- Overrides:
hashCode
in classBasicPermission
- Returns:
- Hash code value for this object.
-