Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/attach/AttachPermission.java
38920 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.attach;2627/**28* When a {@link java.lang.SecurityManager SecurityManager} set, this29* is the permission which will be checked when code invokes {@link30* VirtualMachine#attach VirtalMachine.attach} to attach to a target virtual31* machine.32* This permission is also checked when an {@link33* com.sun.tools.attach.spi.AttachProvider AttachProvider} is created. </p>34*35* <p> An <code>AttachPermission</code> object contains a name (also referred36* to as a "target name") but no actions list; you either have the37* named permission or you don't.38* The following table provides a summary description of what the39* permission allows, and discusses the risks of granting code the40* permission.41* <P>42* <table border=1 cellpadding=5 summary="Table shows permission43* target name, what the permission allows, and associated risks">44* <tr>45* <th>Permission Target Name</th>46* <th>What the Permission Allows</th>47* <th>Risks of Allowing this Permission</th>48* </tr>49*50* <tr>51* <td>attachVirtualMachine</td>52* <td>Ability to attach to another Java virtual machine and load agents53* into that VM.54* </td>55* <td>This allows an attacker to control the target VM which can potentially56* cause it to misbehave.57* </td>58* </tr>59*60* <tr>61* <td>createAttachProvider</td>62* <td>Ability to create an <code>AttachProvider</code> instance.63* </td>64* <td>This allows an attacker to create an AttachProvider which can65* potentially be used to attach to other Java virtual machines.66* </td>67* </tr>6869*70* </table>7172* <p>73* Programmers do not normally create AttachPermission objects directly.74* Instead they are created by the security policy code based on reading75* the security policy file.76*77* @see com.sun.tools.attach.VirtualMachine78* @see com.sun.tools.attach.spi.AttachProvider79*/8081@jdk.Exported82public final class AttachPermission extends java.security.BasicPermission {8384/** use serialVersionUID for interoperability */85static final long serialVersionUID = -4619447669752976181L;8687/**88* Constructs a new AttachPermission object.89*90* @param name Permission name. Must be either "attachVirtualMachine",91* or "createAttachProvider".92*93* @throws NullPointerException if name is <code>null</code>.94* @throws IllegalArgumentException if the name is invalid.95*/96public AttachPermission(String name) {97super(name);98if (!name.equals("attachVirtualMachine") && !name.equals("createAttachProvider")) {99throw new IllegalArgumentException("name: " + name);100}101}102103/**104* Constructs a new AttachPermission object.105*106* @param name Permission name. Must be either "attachVirtualMachine",107* or "createAttachProvider".108*109* @param actions Not used and should be <code>null</code>, or110* the empty string.111*112* @throws NullPointerException if name is <code>null</code>.113* @throws IllegalArgumentException if arguments are invalid.114*/115public AttachPermission(String name, String actions) {116super(name);117if (!name.equals("attachVirtualMachine") && !name.equals("createAttachProvider")) {118throw new IllegalArgumentException("name: " + name);119}120if (actions != null && actions.length() > 0) {121throw new IllegalArgumentException("actions: " + actions);122}123}124}125126127