Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/jcl/src/java.management/share/classes/java/lang/management/ManagementPermission.java
12511 views
1
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/
2
/*
3
*******************************************************************************
4
* Copyright (c) 2005, 2022 IBM Corp. and others
5
*
6
* This program and the accompanying materials are made available under
7
* the terms of the Eclipse Public License 2.0 which accompanies this
8
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
9
* or the Apache License, Version 2.0 which accompanies this distribution and
10
* is available at https://www.apache.org/licenses/LICENSE-2.0.
11
*
12
* This Source Code may also be made available under the following
13
* Secondary Licenses when the conditions for such availability set
14
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
15
* General Public License, version 2 with the GNU Classpath
16
* Exception [1] and GNU General Public License, version 2 with the
17
* OpenJDK Assembly Exception [2].
18
*
19
* [1] https://www.gnu.org/software/classpath/license.html
20
* [2] http://openjdk.java.net/legal/assembly-exception.html
21
*
22
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
23
*******************************************************************************/
24
package java.lang.management;
25
26
import java.security.BasicPermission;
27
28
/**
29
* This is the security permission that code running with a Java security
30
* manager will be verified against when attempts are made to invoke methods in
31
* the platform's management interface.
32
* <p>
33
* Instances of this type are normally created by security code.
34
* </p>
35
*
36
* @since 1.5
37
*/
38
public final class ManagementPermission extends BasicPermission {
39
40
/**
41
* Helps to determine if a de-serialized file is compatible with this type.
42
*/
43
private static final long serialVersionUID = 1897496590799378737L;
44
45
private static final String CONTROL = "control"; //$NON-NLS-1$
46
private static final String MONITOR = "monitor"; //$NON-NLS-1$
47
48
/**
49
* Creates a new instance of <code>ManagementPermission</code> with
50
* the given name.
51
* @param name the name of the permission. The only acceptable values
52
* are the strings &quot;control&quot; or &quot;monitor&quot;.
53
* @throws IllegalArgumentException if <code>name</code> is not one of
54
* the string values &quot;control&quot; or &quot;monitor&quot;.
55
* @throws NullPointerException if <code>name</code> is <code>null</code>.
56
*/
57
public ManagementPermission(String name) {
58
this(name, null);
59
}
60
61
/**
62
* Creates a new instance of <code>ManagementPermission</code> with
63
* the given name and permitted actions.
64
* @param name the name of the permission. The only acceptable values
65
* are the strings &quot;control&quot; or &quot;monitor&quot;.
66
* @param actions this argument must either be an empty string or
67
* <code>null</code>.
68
* @throws NullPointerException if <code>name</code> is <code>null</code>.
69
*/
70
public ManagementPermission(String name, String actions) {
71
super(name, actions);
72
if (actions != null && actions.length() != 0) {
73
/*[MSG "K0606", "The actions argument must be either null or the empty string."]*/
74
throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0606")); //$NON-NLS-1$
75
}
76
if ((name == null) || (!CONTROL.equals(name) && !MONITOR.equals(name))) {
77
/*[MSG "K0607", "Only control or monitor values expected for ManagementPermission name."]*/
78
throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0607")); //$NON-NLS-1$
79
}
80
}
81
82
}
83
84