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.reflect.Method Class in Java
java.lang.reflect.Method class provides necessary details about one method on a certain category or interface and provides access for the same. The reflected method could also be a category method or an instance method (including an abstract method). This class allows broadening of conversions to oc
3 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.net.PasswordAuthentication Class in Java
PasswordAuthentication class is provided by package java.net for implementing networking applications, and it is used in those cases when it is required to hold the data that will be used by the Authenticator. It holds the username and password. Syntax of its constructors : PasswordAuthentication(St
2 min read
java.rmi.Naming Class in Java
Java.rmi.Naming class contains a method to bind, unbind or rebind names with a remote object present at the remote registry. This class is also used to get the reference of the object present at remote registries or the list of name associated with this registry. Syntax: Class declaration public fin
4 min read