public class PermissionInfo
extends java.lang.Object
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.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
actions |
private java.lang.String |
name |
private java.lang.String |
type |
| Constructor and Description |
|---|
PermissionInfo(java.lang.String encodedPermission)
Constructs a
PermissionInfo object from the specified
encoded PermissionInfo string. |
PermissionInfo(java.lang.String type,
java.lang.String name,
java.lang.String actions)
Constructs a
PermissionInfo from the specified type, name,
and actions. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Determines the equality of two
PermissionInfo objects. |
private static void |
escapeString(java.lang.String str,
java.lang.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.
|
java.lang.String |
getActions()
Returns the actions of the permission represented by this
PermissionInfo. |
java.lang.String |
getEncoded()
Returns the string encoding of this
PermissionInfo in a form
suitable for restoring this PermissionInfo. |
java.lang.String |
getName()
Returns the name of the permission represented by this
PermissionInfo. |
java.lang.String |
getType()
Returns the fully qualified class name of the permission represented by
this
PermissionInfo. |
int |
hashCode()
Returns the hash code value for this object.
|
java.lang.String |
toString()
Returns the string representation of this
PermissionInfo. |
private static java.lang.String |
unescapeString(char[] str,
int begin,
int end)
Takes an encoded character array and decodes it into a new String.
|
private final java.lang.String type
private final java.lang.String name
private final java.lang.String actions
public PermissionInfo(java.lang.String type,
java.lang.String name,
java.lang.String actions)
PermissionInfo from the specified type, name,
and actions.type - 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 - The permission name that will be passed as the first argument
to the constructor of the Permission class identified
by type.actions - The permission actions that will be passed as the second
argument to the constructor of the Permission class
identified by type.java.lang.NullPointerException - If type is null.java.lang.IllegalArgumentException - If action is not
null and name is null.public PermissionInfo(java.lang.String encodedPermission)
PermissionInfo object from the specified
encoded PermissionInfo string. White space in the encoded
PermissionInfo string is ignored.encodedPermission - The encoded PermissionInfo.java.lang.IllegalArgumentException - If the specified
encodedPermission is not properly formatted.getEncoded()public final java.lang.String getEncoded()
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".
PermissionInfo.public java.lang.String toString()
PermissionInfo.
The string is created by calling the getEncoded method on
this PermissionInfo.toString in class java.lang.ObjectPermissionInfo.public final java.lang.String getType()
PermissionInfo.PermissionInfo.public final java.lang.String getName()
PermissionInfo.PermissionInfo, or null if the
permission does not have a name.public final java.lang.String getActions()
PermissionInfo.PermissionInfo, or null if the
permission does not have any actions associated with it.public boolean equals(java.lang.Object obj)
PermissionInfo objects.
This method checks that specified object has the same type, name and
actions as this PermissionInfo object.equals in class java.lang.Objectobj - The object to test for equality with this
PermissionInfo object.true if obj is a
PermissionInfo, and has the same type, name and
actions as this PermissionInfo object;
false otherwise.public int hashCode()
hashCode in class java.lang.Objectprivate static void escapeString(java.lang.String str,
java.lang.StringBuffer output)
private static java.lang.String unescapeString(char[] str,
int begin,
int end)