java.lang.management.ManagementPermission Class in Java
Last Updated :
28 Mar, 2021
java.lang.ManagementPermission Class contains abstract methods to determine access to a system resource. Every object has some name. Most permission object also has some "actions" associated with it that tells which activities are permitted by this permission object.
Class declaration :
public final class ManagementPermission
extends BasicPermission
Constructor:
Permission(String name)
public Permission(String name): Constructs a new Permission object with this name.
Method:
Method | Description |
---|
checkGuard(Object object) | It is used to determine if this Permission object can be guarded (protect access to another object) or not. |
equals(Object obj) | It checks whether two Permission objects are equal or not. |
hashCode() | It returns the hash code value for this Permission object. |
getName() | It returns the name of this Permission. |
implies(Permission permission) | It checks whether this ManagementPermssion object implies this permission or not. |
newPermissionCollection() | It returns a new PermissionCollection object. |
toString() | It returns a string representation of the specified Permission object. |
1.public void checkGuard(Object object): It is used to determine if this Permission object can be guarded (protect access to another object) or not.
Parameters:
object - the object to guard.
Throws:
SecurityException - if the access is denied by checkPermission method.
2.public abstract boolean implies(Permission permission): It checks whether this ManagementPermssion object implies this permission or not.
Parameters:
permission - the permission to check against.
Returns:
true if this permission is implied by this object, false otherwise.
3.public abstract boolean equals(Object obj): It checks whether two Permission objects are equal or not.
Parameters:
obj - the object to be compared
Returns:
true if both Permission objects are equal, false otherwise.
4.public abstract int hashCode(): It returns the hash code value for this Permission object.
Returns:
a hash code value for this object.
5.public final String getName(): It returns the name of this Permission.
Returns:
the name of this Permission.
6.public abstract String getActions(): It returns the actions of this Permission object in String format.
Returns:
the actions of this Permission.
7.public PermissionCollection newPermissionCollection(): It returns a new PermissionCollection object.
Returns:
a new PermissionCollection object
8.public String toString(): It returns a string representation of the specified Permission object.
Returns:
string representation of the specified Permission object.
Java
import java.lang.management.ManagementPermission;
import java.security.Permission;
public class GFG {
public static void main(String[] args)
{
// Creating a new ManagementPermission object with
// name control
Permission p = new ManagementPermission("control");
try {
// Printing name of the object
System.out.println("Name: " + p.getName());
// Printing hash value of the object
System.out.println("Hashcode: " + p.hashCode());
// Printing actions of the object
System.out.println("Actions: "
+ p.getActions());
// Converting this managementPermission object
// to new PermissionCollection object
System.out.println(
"As a new PermissionCollection object: "
+ p.newPermissionCollection().toString());
// Checking if new permissionCollection implies
// managementPermission object or not
System.out.println(
"Implies: "
+ p.newPermissionCollection().implies(p));
}
catch (Exception e) {
System.err.println(e.toString());
}
}
}
OutputName: control
Hashcode: 951543133
Actions:
As a new PermissionCollection object: java.security.BasicPermissionCollection@5b6f7412 (
)
Implies: false
Similar Reads
java.lang.reflect.ReflectPermission Class in Java ReflectPermission class extends BasicPermission class. It is a ânamedâ permission i.e it contains a name but no action. It may implement actions on top of BasicPermission, if desired. It is used to get information about the behaviour of Constructors. ConstructorsDescriptionReflectPermission(String n
2 min read
java.net.NetPermission Class in Java NetPermission class is used to allow network permissions. NetPermission class extends BasicPermission class. It is a ânamedâ permission i.e it contains a name but no action. Permission nameWhat permission allowsRisks associated with this permissionallowHttpTraceThis permission allows using the HTTP
4 min read
java.lang.management.ThreadInfo Class in Java java.lang.management.ThreadInfo class contains methods to get information about a thread. This information includes: Thread IDThread NameState of the ThreadStack trace of the ThreadThe object upon which the Thread is blockedList of object monitors that are blocked by the ThreadList of ownable synchr
4 min read
java.net.SocketPermission Class in Java The java.net.SocketPermisson class represents whether you have permission to access a network via sockets. A SocketPermission consists of a host and a set of actions. Class Declaration: public final class SocketPermission extends Permission implements SerializableConstructor: ConstructorDescriptionM
2 min read
Java.lang.Runtime class in Java In Java, the Runtime class is used to interact with Every Java application that has a single instance of class Runtime that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from the getRuntime() method. Methods of Java
6 min read
Java.util.PropertyPermission class in Java This class is for property permission. It extends BasicPermission. The name is the name of the property ("java.home", "os.name", etc). The naming convention follows the hierarchical property naming convention. Also, an asterisk may appear at the end of the name, following a ".", or by itself, to sig
4 min read
java.nio.file.LinkPermission Class in Java The java.nio.file.LinkPermission class handles permissions for link creation operations. The permission allowed by these class are as follows: Permission name What permission allows Risk of granting this permission hard This permission allows adding an existing file to a directory. This operation is
3 min read
java.lang.reflect.Modifier Class in Java The java.lang.reflect.Modifier class contains methods used to get information about class, member and method access modifiers. The modifiers are represented as int value with set bits at distinct positions. The int value represents different modifiers. These values are taken from the tables in secti
7 min read
java.rmi.RMISecurityManager Class in Java The RMISecurityManager enforces the security policy for classes that are loaded as stubs for remote objects, by overriding all of the relevant access-check methods from the SecurityManager. By default, stub objects are only allowed to perform class definition and class access operations. Note: If
3 min read
Java.lang.Class class in Java | Set 1 Java provides a class with name Class in java.lang package. Instances of the class Class represent classes and interfaces in a running Java application. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. It
15+ min read