Class EndpointPermission
- java.lang.Object
-
- java.security.Permission
-
- org.osgi.service.remoteserviceadmin.EndpointPermission
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Guard
public final class EndpointPermission extends java.security.PermissionA bundle's authority to export, import or read an Endpoint.- The
exportaction allows a bundle to export a service as an Endpoint. - The
importaction allows a bundle to import a service from an Endpoint. - The
readaction allows a bundle to read references to an Endpoint.
EndpointPermissionto read the specific service.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static intACTION_ALLprivate static intACTION_EXPORTprivate static intACTION_IMPORT(package private) intaction_maskThe actions mask.(package private) static intACTION_NONEprivate static intACTION_READprivate java.lang.StringactionsThe actions in canonical form.(package private) EndpointDescriptionendpointThe endpoint used by this EndpointPermission.static java.lang.StringEXPORTThe action stringexport.(package private) org.osgi.framework.FilterfilterIf this EndpointPermission was not constructed with an EndpointDescription, this holds a Filter matching object used to evaluate the filter in implies ornullfor wildcard.static java.lang.StringIMPORTThe action stringimport.private java.util.Dictionary<java.lang.String,java.lang.Object>propertiesThis dictionary holds the properties of the permission, used to match a filter in implies.static java.lang.StringREADThe action stringread.(package private) static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description EndpointPermission(java.lang.String name, int mask)Package private constructor used by EndpointPermissionCollection.EndpointPermission(java.lang.String filterString, java.lang.String actions)Create a new EndpointPermission with the specified filter.EndpointPermission(EndpointDescription endpoint, java.lang.String localFrameworkUUID, java.lang.String actions)Creates a new requestedEndpointPermissionobject to be used by code that must performcheckPermission.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringcreateName(EndpointDescription endpoint)Create a permission name from a EndpointDescription.booleanequals(java.lang.Object obj)Determines the equality of two EndpointPermission objects.java.lang.StringgetActions()Returns the canonical string representation of the actions.private java.util.Dictionary<java.lang.String,java.lang.Object>getProperties()Called byimplies(Permission).inthashCode()Returns the hash code value for this object.booleanimplies(java.security.Permission p)Determines if aEndpointPermissionobject "implies" the specified permission.(package private) booleanimplies0(EndpointPermission requested, int effective)Internal implies method.java.security.PermissionCollectionnewPermissionCollection()Returns a newPermissionCollectionobject for storingEndpointPermissionobjects.private static intparseActions(java.lang.String actions)Parse action string into action mask.private static org.osgi.framework.FilterparseFilter(java.lang.String filterString)Parse filter string into a Filter object.private voidreadObject(java.io.ObjectInputStream s)readObject is called to restore the state of this permission from a stream.private voidsetTransients(org.osgi.framework.Filter f, int mask)Called by constructors and when deserialized.private voidwriteObject(java.io.ObjectOutputStream s)WriteObject is called to save the state of this permission to a stream.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
READ
public static final java.lang.String READ
The action stringread.- See Also:
- Constant Field Values
-
IMPORT
public static final java.lang.String IMPORT
The action stringimport. Theimportaction implies thereadaction.- See Also:
- Constant Field Values
-
EXPORT
public static final java.lang.String EXPORT
The action stringexport. Theexportaction implies thereadaction.- See Also:
- Constant Field Values
-
ACTION_READ
private static final int ACTION_READ
- See Also:
- Constant Field Values
-
ACTION_IMPORT
private static final int ACTION_IMPORT
- See Also:
- Constant Field Values
-
ACTION_EXPORT
private static final int ACTION_EXPORT
- See Also:
- Constant Field Values
-
ACTION_ALL
private static final int ACTION_ALL
- See Also:
- Constant Field Values
-
ACTION_NONE
static final int ACTION_NONE
- See Also:
- Constant Field Values
-
action_mask
transient int action_mask
The actions mask.
-
actions
private volatile java.lang.String actions
The actions in canonical form.
-
endpoint
final transient EndpointDescription endpoint
The endpoint used by this EndpointPermission. Must benullif not constructed with a endpoint.
-
properties
private final transient java.util.Dictionary<java.lang.String,java.lang.Object> properties
This dictionary holds the properties of the permission, used to match a filter in implies.
-
filter
transient org.osgi.framework.Filter filter
If this EndpointPermission was not constructed with an EndpointDescription, this holds a Filter matching object used to evaluate the filter in implies ornullfor wildcard.
-
-
Constructor Detail
-
EndpointPermission
public EndpointPermission(java.lang.String filterString, java.lang.String actions)Create a new EndpointPermission with the specified filter.The filter will be evaluated against the endpoint properties of a requested EndpointPermission.
There are three possible actions:
read,importandexport. Thereadaction allows the owner of this permission to see the presence of distributed services. Theimportaction allows the owner of this permission to import an endpoint. Theexportaction allows the owner of this permission to export a service.- Parameters:
filterString- The filter string or "*" to match all endpoints.actions- The actionsread,import, orexport.- Throws:
java.lang.IllegalArgumentException- If the filter has an invalid syntax or the actions are not valid.
-
EndpointPermission
public EndpointPermission(EndpointDescription endpoint, java.lang.String localFrameworkUUID, java.lang.String actions)
Creates a new requestedEndpointPermissionobject to be used by code that must performcheckPermission.EndpointPermissionobjects created with this constructor cannot be added to anEndpointPermissionpermission collection.- Parameters:
endpoint- The requested endpoint.localFrameworkUUID- The UUID of the local framework. This is used to support matching theendpoint.framework.uuidendpoint property to the<<LOCAL>>value in the filter expression.actions- The actionsread,import, orexport.- Throws:
java.lang.IllegalArgumentException- If the endpoint isnullor the actions are not valid.
-
EndpointPermission
EndpointPermission(java.lang.String name, int mask)Package private constructor used by EndpointPermissionCollection.- Parameters:
name- class namemask- action mask
-
-
Method Detail
-
createName
private static java.lang.String createName(EndpointDescription endpoint)
Create a permission name from a EndpointDescription.- Parameters:
endpoint- EndpointDescription to use to create permission name.- Returns:
- permission name.
-
setTransients
private void setTransients(org.osgi.framework.Filter f, int mask)Called by constructors and when deserialized.- Parameters:
mask- action mask
-
parseActions
private static int parseActions(java.lang.String actions)
Parse action string into action mask.- Parameters:
actions- Action string.- Returns:
- action mask.
-
parseFilter
private static org.osgi.framework.Filter parseFilter(java.lang.String filterString)
Parse filter string into a Filter object.- Parameters:
filterString- The filter string to parse.- Returns:
- a Filter for this bundle.
- Throws:
java.lang.IllegalArgumentException- If the filter syntax is invalid.
-
implies
public boolean implies(java.security.Permission p)
Determines if aEndpointPermissionobject "implies" the specified permission.- Specified by:
impliesin classjava.security.Permission- Parameters:
p- The target permission to check.- Returns:
trueif the specified permission is implied by this object;falseotherwise.
-
implies0
boolean implies0(EndpointPermission requested, int effective)
Internal implies method. Used by the implies and the permission collection implies methods.- Parameters:
requested- The requested EndpointPermission which has already be validated as a proper argument. The requested EndpointPermission must not have a filter expression.effective- The effective actions with which to start.- 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 canonical order:read,import,export.- Specified by:
getActionsin classjava.security.Permission- Returns:
- The canonical string representation of the actions.
-
newPermissionCollection
public java.security.PermissionCollection newPermissionCollection()
Returns a newPermissionCollectionobject for storingEndpointPermissionobjects.- Overrides:
newPermissionCollectionin classjava.security.Permission- Returns:
- A new
PermissionCollectionobject suitable for storingEndpointPermissionobjects.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of two EndpointPermission objects. Checks that specified object has the same name, actions and endpoint as thisEndpointPermission.- Specified by:
equalsin classjava.security.Permission- Parameters:
obj- The object to test for equality.- Returns:
- true If obj is a
EndpointPermission, and has the same name, actions and endpoint as thisEndpointPermissionobject;falseotherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Specified by:
hashCodein classjava.security.Permission- Returns:
- Hash code value for this object.
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOExceptionWriteObject is called to save the state of this permission to a stream. The actions are serialized, and the superclass takes care of the name.- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundExceptionreadObject is called to restore the state of this permission from a stream.- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
getProperties
private java.util.Dictionary<java.lang.String,java.lang.Object> getProperties()
Called byimplies(Permission).- Returns:
- a dictionary of properties for this permission.
-
-