Path: blob/master/jcl/src/java.management/share/classes/java/lang/management/ManagementPermission.java
12511 views
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/1/*2*******************************************************************************3* Copyright (c) 2005, 2022 IBM Corp. and others4*5* This program and the accompanying materials are made available under6* the terms of the Eclipse Public License 2.0 which accompanies this7* distribution and is available at https://www.eclipse.org/legal/epl-2.0/8* or the Apache License, Version 2.0 which accompanies this distribution and9* is available at https://www.apache.org/licenses/LICENSE-2.0.10*11* This Source Code may also be made available under the following12* Secondary Licenses when the conditions for such availability set13* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU14* General Public License, version 2 with the GNU Classpath15* Exception [1] and GNU General Public License, version 2 with the16* OpenJDK Assembly Exception [2].17*18* [1] https://www.gnu.org/software/classpath/license.html19* [2] http://openjdk.java.net/legal/assembly-exception.html20*21* 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-exception22*******************************************************************************/23package java.lang.management;2425import java.security.BasicPermission;2627/**28* This is the security permission that code running with a Java security29* manager will be verified against when attempts are made to invoke methods in30* the platform's management interface.31* <p>32* Instances of this type are normally created by security code.33* </p>34*35* @since 1.536*/37public final class ManagementPermission extends BasicPermission {3839/**40* Helps to determine if a de-serialized file is compatible with this type.41*/42private static final long serialVersionUID = 1897496590799378737L;4344private static final String CONTROL = "control"; //$NON-NLS-1$45private static final String MONITOR = "monitor"; //$NON-NLS-1$4647/**48* Creates a new instance of <code>ManagementPermission</code> with49* the given name.50* @param name the name of the permission. The only acceptable values51* are the strings "control" or "monitor".52* @throws IllegalArgumentException if <code>name</code> is not one of53* the string values "control" or "monitor".54* @throws NullPointerException if <code>name</code> is <code>null</code>.55*/56public ManagementPermission(String name) {57this(name, null);58}5960/**61* Creates a new instance of <code>ManagementPermission</code> with62* the given name and permitted actions.63* @param name the name of the permission. The only acceptable values64* are the strings "control" or "monitor".65* @param actions this argument must either be an empty string or66* <code>null</code>.67* @throws NullPointerException if <code>name</code> is <code>null</code>.68*/69public ManagementPermission(String name, String actions) {70super(name, actions);71if (actions != null && actions.length() != 0) {72/*[MSG "K0606", "The actions argument must be either null or the empty string."]*/73throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0606")); //$NON-NLS-1$74}75if ((name == null) || (!CONTROL.equals(name) && !MONITOR.equals(name))) {76/*[MSG "K0607", "Only control or monitor values expected for ManagementPermission name."]*/77throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0607")); //$NON-NLS-1$78}79}8081}828384