OSGi™ Core
Release 5

org.osgi.framework
Class ServicePermission

java.lang.Object
  extended by java.security.Permission
      extended by java.security.BasicPermission
          extended by org.osgi.framework.ServicePermission
All Implemented Interfaces:
java.io.Serializable, java.security.Guard

public final class ServicePermission
extends java.security.BasicPermission

A bundle's authority to register or get a service.

Permission to get a service is required in order to detect events regarding the service. Untrusted bundles should not be able to detect the presence of certain services unless they have the appropriate ServicePermission to get the specific service.

See Also:
Serialized Form
ThreadSafe

Field Summary
static java.lang.String GET
          The action string get.
static java.lang.String REGISTER
          The action string register.
 
Constructor Summary
ServicePermission(ServiceReference<?> reference, java.lang.String actions)
          Creates a new requested ServicePermission object to be used by code that must perform checkPermission for the get action.
ServicePermission(java.lang.String name, java.lang.String actions)
          Create a new ServicePermission.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determines the equality of two ServicePermission objects.
 java.lang.String getActions()
          Returns the canonical string representation of the actions.
 int hashCode()
          Returns the hash code value for this object.
 boolean implies(java.security.Permission p)
          Determines if a ServicePermission object "implies" the specified permission.
 java.security.PermissionCollection newPermissionCollection()
          Returns a new PermissionCollection object for storing ServicePermission objects.
 
Methods inherited from class java.security.Permission
checkGuard, getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET

public static final java.lang.String GET
The action string get.

See Also:
Constant Field Values

REGISTER

public static final java.lang.String REGISTER
The action string register.

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 the get action, the name can also be a filter expression. The filter gives access to the service properties as well as the following attributes: Since the above attribute names may conflict with service property names used by a service, you can prefix an attribute name with '@' in the filter expression to match against the service property and not one of the above attributes. Filter attribute names are processed in a case sensitive manner unless the attribute references a service property. Service properties names are case insensitive.

There are two possible actions: get and register. The get permission allows the owner of this permission to obtain a service with this name. The register permission allows the bundle to register a service under that name.

Parameters:
name - The service class name
actions - get,register (canonical order)
Throws:
java.lang.IllegalArgumentException - If the specified name is a filter expression and either the specified action is not get or the filter has an invalid syntax.

ServicePermission

public ServicePermission(ServiceReference<?> reference,
                         java.lang.String actions)
Creates a new requested ServicePermission object to be used by code that must perform checkPermission for the get action. ServicePermission objects created with this constructor cannot be added to a ServicePermission permission collection.

Parameters:
reference - The requested service.
actions - The action get.
Throws:
java.lang.IllegalArgumentException - If the specified action is not get or reference is null.
Since:
1.5
Method Detail

implies

public boolean implies(java.security.Permission p)
Determines if a ServicePermission object "implies" the specified permission.

Overrides:
implies in class java.security.BasicPermission
Parameters:
p - The target permission to check.
Returns:
true if the specified permission is implied by this object; false otherwise.

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:
getActions in class java.security.BasicPermission
Returns:
The canonical string representation of the actions.

newPermissionCollection

public java.security.PermissionCollection newPermissionCollection()
Returns a new PermissionCollection object for storing ServicePermission objects.

Overrides:
newPermissionCollection in class java.security.Permission
Returns:
A new PermissionCollection object suitable for storing ServicePermission objects.

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 this ServicePermission.

Overrides:
equals in class java.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 this ServicePermission object; false otherwise.

hashCode

public int hashCode()
Returns the hash code value for this object.

Overrides:
hashCode in class java.security.BasicPermission
Returns:
Hash code value for this object.

OSGi™ Core
Release 5

Copyright © OSGi Alliance (2000, 2012). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0