Top Description Fields Constructors Methods
java.security

public abstract Class BasicPermission

Additional top-level class in compilation unit: BasicPermissionCollection.

extends Permission
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
java.security.SecurityPermission, javax.net.ssl.SSLPermission, javax.security.auth.AuthPermission, java.lang.RuntimePermission, java.util.PropertyPermission, java.io.SerializablePermission, java.lang.reflect.ReflectPermission, java.net.NetPermission, java.nio.file.LinkPermission
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, java.util.Enumeration, .Hashtable, java.util.concurrent.ConcurrentHashMap

The BasicPermission class extends the Permission class, and can be used as the base class for permissions that want to follow the same naming convention as BasicPermission.

The name for a BasicPermission is the name of the given permission (for example, "exit", "setFactory", "print.queueJob", etc.). The naming convention follows the hierarchical property naming convention. An asterisk may appear by itself, or if immediately preceded by a "." may appear at the end of the name, to signify a wildcard match. For example, "*" and "java.*" signify a wildcard match, while "*java", "a*b", and "java*" do not.

The action string (inherited from Permission) is unused. Thus, BasicPermission is commonly used as the base class for "named" permissions (ones that contain a name but no actions list; you either have the named permission or you don't.) Subclasses may implement actions on top of BasicPermission, if desired.

Authors
Marianne Mueller, Roland Schemers
Since
1.2
See Also
java.security.Permission, java.security.Permissions, java.security.PermissionCollection, java.lang.SecurityManager

Field Summary

Modifier and TypeField and Description
private transient boolean
private transient String
private static final long
private transient boolean

Constructor Summary

AccessConstructor and Description
public
BasicPermission(String
the name of the BasicPermission.
name
)

Creates a new BasicPermission with the specified name.

public
BasicPermission(String
the name of the BasicPermission.
name
,
String
ignored.
actions
)

Creates a new BasicPermission object with the specified name.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj's class is the same as this object's class and has the same name as this BasicPermission object, false otherwise.
equals
(Object
the object we are testing for equality with this object.
obj
)

Implements abstract java.security.Permission.equals.

Checks two BasicPermission objects for equality.

public String

Returns:

the empty string "".
getActions
()

Implements abstract java.security.Permission.getActions.

Returns the canonical string representation of the actions, which currently is the empty string "", since there are no actions for a BasicPermission.

pack-priv final String

Returns:

the canonical name of this BasicPermission.
getCanonicalName
()

Returns the canonical name of this BasicPermission.

public int

Returns:

the hash code value for this object
hashCode
()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the passed permission is equal to or implied by this permission, false otherwise.
implies
(Permission
the permission to check against.
p
)

Implements abstract java.security.Permission.implies.

Checks if the specified permission is "implied" by this object.

private void
init(String name)

initialize a BasicPermission object.

public PermissionCollection

Returns:

a new PermissionCollection object suitable for storing BasicPermission objects.
newPermissionCollection
()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object for storing BasicPermission objects.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

readObject is called to restore the state of the BasicPermission from a stream.

Inherited from java.security.Permission:
checkGuardgetNametoString

Field Detail

exitVMback to summary
private transient boolean exitVM
pathback to summary
private transient String path
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.Permission.serialVersionUID.

Annotations
@Serial
wildcardback to summary
private transient boolean wildcard

Constructor Detail

BasicPermissionback to summary
public BasicPermission(String name)

Creates a new BasicPermission with the specified name. Name is the symbolic name of the permission, such as "setFactory", "print.queueJob", or "topLevelWindow", etc.

Parameters
name:String

the name of the BasicPermission.

Exceptions
NullPointerException:
if name is null.
IllegalArgumentException:
if name is empty.
BasicPermissionback to summary
public BasicPermission(String name, String actions)

Creates a new BasicPermission object with the specified name. The name is the symbolic name of the BasicPermission, and the actions String is currently unused.

Parameters
name:String

the name of the BasicPermission.

actions:String

ignored.

Exceptions
NullPointerException:
if name is null.
IllegalArgumentException:
if name is empty.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract java.security.Permission.equals.

Checks two BasicPermission objects for equality. Checks that obj's class is the same as this object's class and has the same name as this object.

Parameters
obj:Object

the object we are testing for equality with this object.

Returns:boolean

true if obj's class is the same as this object's class and has the same name as this BasicPermission object, false otherwise.

Annotations
@Override
getActionsback to summary
public String getActions()

Implements abstract java.security.Permission.getActions.

Returns the canonical string representation of the actions, which currently is the empty string "", since there are no actions for a BasicPermission.

Returns:String

the empty string "".

Annotations
@Override
getCanonicalNameback to summary
pack-priv final String getCanonicalName()

Returns the canonical name of this BasicPermission. All internal invocations of getName should invoke this method, so that the pre-JDK 1.6 "exitVM" and current "exitVM.*" permission are equivalent in equals/hashCode methods.

Returns:String

the canonical name of this BasicPermission.

hashCodeback to summary
public int hashCode()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object. The hash code used is the hash code of the name, that is, getName().hashCode(), where getName is from the Permission superclass.

Returns:int

the hash code value for this object

Annotations
@Override
impliesback to summary
public boolean implies(Permission p)

Implements abstract java.security.Permission.implies.

Checks if the specified permission is "implied" by this object.

More specifically, this method returns true if:

  • p's class is the same as this object's class, and
  • p's name equals or (in the case of wildcards) is implied by this object's name. For example, "a.b.*" implies "a.b.c".
Parameters
p:Permission

the permission to check against.

Returns:boolean

true if the passed permission is equal to or implied by this permission, false otherwise.

Annotations
@Override
initback to summary
private void init(String name)

initialize a BasicPermission object. Common to all constructors.

newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object for storing BasicPermission objects.

BasicPermission objects must be stored in a manner that allows them to be inserted in any order, but that also enables the PermissionCollection#implies method to be implemented in an efficient (and consistent) manner.

Returns:PermissionCollection

a new PermissionCollection object suitable for storing BasicPermission objects.

Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

readObject is called to restore the state of the BasicPermission from a stream.

Parameters
s:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded