Top Description Fields Constructors Methods
org.osgi.service.permissionadmin

public Class PermissionInfo

extends Object
Class Inheritance

Permission representation used by the Permission Admin service.

This class encapsulates three pieces of information: a Permission type (class name), which must be a subclass of java.security.Permission, and the name and actions arguments passed to its constructor.

In order for a permission represented by a PermissionInfo to be instantiated and considered during a permission check, its Permission class must be available from the system classpath or an exported package. This means that the instantiation of a permission represented by a PermissionInfo may be delayed until the package containing its Permission class has been exported by a bundle.

Author
$Id: b6cc8440e07c61e1d4d53a58ac3610c99e5c34f7 $

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final String

Constructor Summary

AccessConstructor and Description
public
PermissionInfo(String
The fully qualified class name of the permission represented by this PermissionInfo. The class must be a subclass of java.security.Permission and must define a 2-argument constructor that takes a name string and an actions string.
type
,
String
The permission name that will be passed as the first argument to the constructor of the Permission class identified by type.
name
,
String
The permission actions that will be passed as the second argument to the constructor of the Permission class identified by type.
actions
)

Constructs a PermissionInfo from the specified type, name, and actions.

public
PermissionInfo(String
The encoded PermissionInfo.
encodedPermission
)

Constructs a PermissionInfo object from the specified encoded PermissionInfo string.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is a PermissionInfo, and has the same type, name and actions as this PermissionInfo object; false otherwise.
equals
(Object
The object to test for equality with this PermissionInfo object.
obj
)

Overrides java.lang.Object.equals.

Determines the equality of two PermissionInfo objects.

private static void
escapeString(String str, StringBuffer output)

This escapes the quotes, backslashes, \n, and \r in the string using a backslash and appends the newly escaped string to a StringBuffer.

public final String

Returns:

The actions of the permission represented by this PermissionInfo, or null if the permission does not have any actions associated with it.
getActions
()

Returns the actions of the permission represented by this PermissionInfo.

public final String

Returns:

The string encoding of this PermissionInfo.
getEncoded
()

Returns the string encoding of this PermissionInfo in a form suitable for restoring this PermissionInfo.

public final String

Returns:

The name of the permission represented by this PermissionInfo, or null if the permission does not have a name.
getName
()

Returns the name of the permission represented by this PermissionInfo.

public final String

Returns:

The fully qualified class name of the permission represented by this PermissionInfo.
getType
()

Returns the fully qualified class name of the permission represented by this PermissionInfo.

public int

Returns:

A hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this object.

public String

Returns:

The string representation of this PermissionInfo.
toString
()

Overrides java.lang.Object.toString.

Returns the string representation of this PermissionInfo.

private static String
unescapeString(char[] str, int begin, int end)

Takes an encoded character array and decodes it into a new String.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

actionsback to summary
private final String actions
nameback to summary
private final String name
typeback to summary
private final String type

Constructor Detail

PermissionInfoback to summary
public PermissionInfo(String type, String name, String actions)

Constructs a PermissionInfo from the specified type, name, and actions.

Parameters
type:String

The fully qualified class name of the permission represented by this PermissionInfo. The class must be a subclass of java.security.Permission and must define a 2-argument constructor that takes a name string and an actions string.

name:String

The permission name that will be passed as the first argument to the constructor of the Permission class identified by type.

actions:String

The permission actions that will be passed as the second argument to the constructor of the Permission class identified by type.

Exceptions
NullPointerException:
If type is null.
IllegalArgumentException:
If action is not null and name is null.
PermissionInfoback to summary
public PermissionInfo(String encodedPermission)

Constructs a PermissionInfo object from the specified encoded PermissionInfo string. White space in the encoded PermissionInfo string is ignored.

Parameters
encodedPermission:String

The encoded PermissionInfo.

Exceptions
IllegalArgumentException:
If the specified encodedPermission is not properly formatted.
See Also
getEncoded()

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Determines the equality of two PermissionInfo objects. This method checks that specified object has the same type, name and actions as this PermissionInfo object.

Parameters
obj:Object

The object to test for equality with this PermissionInfo object.

Returns:boolean

true if obj is a PermissionInfo, and has the same type, name and actions as this PermissionInfo object; false otherwise.

Annotations
@Override
escapeStringback to summary
private static void escapeString(String str, StringBuffer output)

This escapes the quotes, backslashes, \n, and \r in the string using a backslash and appends the newly escaped string to a StringBuffer.

getActionsback to summary
public final String getActions()

Returns the actions of the permission represented by this PermissionInfo.

Returns:String

The actions of the permission represented by this PermissionInfo, or null if the permission does not have any actions associated with it.

getEncodedback to summary
public final String getEncoded()

Returns the string encoding of this PermissionInfo in a form suitable for restoring this PermissionInfo.

The encoded format is:

(type)
or
(type "name")
or
(type "name" "actions")
where name and actions are strings that must be encoded for proper parsing. Specifically, the ",\, carriage return, and line feed characters must be escaped using \", \\, \r, and \n, respectively.

The encoded string contains no leading or trailing whitespace characters. A single space character is used between type and "name" and between "name" and "actions".

Returns:String

The string encoding of this PermissionInfo.

getNameback to summary
public final String getName()

Returns the name of the permission represented by this PermissionInfo.

Returns:String

The name of the permission represented by this PermissionInfo, or null if the permission does not have a name.

getTypeback to summary
public final String getType()

Returns the fully qualified class name of the permission represented by this PermissionInfo.

Returns:String

The fully qualified class name of the permission represented by this PermissionInfo.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this object.

Returns:int

A hash code value for this object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string representation of this PermissionInfo. The string is created by calling the getEncoded method on this PermissionInfo.

Returns:String

The string representation of this PermissionInfo.

Annotations
@Override
unescapeStringback to summary
private static String unescapeString(char[] str, int begin, int end)

Takes an encoded character array and decodes it into a new String.