Class PermissionInfo
- java.lang.Object
-
- org.osgi.service.permissionadmin.PermissionInfo
-
public class PermissionInfo extends java.lang.Object
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 aPermissionInfo
may be delayed until the package containing its Permission class has been exported by a bundle.
-
-
Constructor Summary
Constructors Constructor Description PermissionInfo(java.lang.String encodedPermission)
Constructs aPermissionInfo
object from the specified encodedPermissionInfo
string.PermissionInfo(java.lang.String type, java.lang.String name, java.lang.String actions)
Constructs aPermissionInfo
from the specified type, name, and actions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Determines the equality of twoPermissionInfo
objects.java.lang.String
getActions()
Returns the actions of the permission represented by thisPermissionInfo
.java.lang.String
getEncoded()
Returns the string encoding of thisPermissionInfo
in a form suitable for restoring thisPermissionInfo
.java.lang.String
getName()
Returns the name of the permission represented by thisPermissionInfo
.java.lang.String
getType()
Returns the fully qualified class name of the permission represented by thisPermissionInfo
.int
hashCode()
Returns the hash code value for this object.java.lang.String
toString()
Returns the string representation of thisPermissionInfo
.
-
-
-
Constructor Detail
-
PermissionInfo
public PermissionInfo(java.lang.String type, java.lang.String name, java.lang.String actions)
Constructs aPermissionInfo
from the specified type, name, and actions.- Parameters:
type
- The fully qualified class name of the permission represented by thisPermissionInfo
. The class must be a subclass ofjava.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 thePermission
class identified bytype
.actions
- The permission actions that will be passed as the second argument to the constructor of thePermission
class identified bytype
.- Throws:
java.lang.NullPointerException
- Iftype
isnull
.java.lang.IllegalArgumentException
- Ifaction
is notnull
andname
isnull
.
-
PermissionInfo
public PermissionInfo(java.lang.String encodedPermission)
Constructs aPermissionInfo
object from the specified encodedPermissionInfo
string. White space in the encodedPermissionInfo
string is ignored.- Parameters:
encodedPermission
- The encodedPermissionInfo
.- Throws:
java.lang.IllegalArgumentException
- If the specifiedencodedPermission
is not properly formatted.- See Also:
getEncoded()
-
-
Method Detail
-
getEncoded
public final java.lang.String getEncoded()
Returns the string encoding of thisPermissionInfo
in a form suitable for restoring thisPermissionInfo
.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:
- The string encoding of this
PermissionInfo
.
-
toString
public java.lang.String toString()
Returns the string representation of thisPermissionInfo
. The string is created by calling thegetEncoded
method on thisPermissionInfo
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string representation of this
PermissionInfo
.
-
getType
public final java.lang.String getType()
Returns the fully qualified class name of the permission represented by thisPermissionInfo
.- Returns:
- The fully qualified class name of the permission represented by
this
PermissionInfo
.
-
getName
public final java.lang.String getName()
Returns the name of the permission represented by thisPermissionInfo
.- Returns:
- The name of the permission represented by this
PermissionInfo
, ornull
if the permission does not have a name.
-
getActions
public final java.lang.String getActions()
Returns the actions of the permission represented by thisPermissionInfo
.- Returns:
- The actions of the permission represented by this
PermissionInfo
, ornull
if the permission does not have any actions associated with it.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of twoPermissionInfo
objects. This method checks that specified object has the same type, name and actions as thisPermissionInfo
object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The object to test for equality with thisPermissionInfo
object.- Returns:
true
ifobj
is aPermissionInfo
, and has the same type, name and actions as thisPermissionInfo
object;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hash code value for this object.
-
-