0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.attach;
0N/A
0N/A/**
0N/A * When a {@link java.lang.SecurityManager SecurityManager} set, this
0N/A * is the permission which will be checked when code invokes {@link
0N/A * VirtualMachine#attach VirtalMachine.attach} to attach to a target virtual
0N/A * machine.
0N/A * This permission is also checked when an {@link
0N/A * com.sun.tools.attach.spi.AttachProvider AttachProvider} is created. </p>
0N/A *
0N/A * <p> An <code>AttachPermission</code> object contains a name (also referred
0N/A * to as a "target name") but no actions list; you either have the
0N/A * named permission or you don't.
0N/A * The following table provides a summary description of what the
0N/A * permission allows, and discusses the risks of granting code the
0N/A * permission.
0N/A * <P>
0N/A * <table border=1 cellpadding=5 summary="Table shows permission
0N/A * target name, what the permission allows, and associated risks">
0N/A * <tr>
0N/A * <th>Permission Target Name</th>
0N/A * <th>What the Permission Allows</th>
0N/A * <th>Risks of Allowing this Permission</th>
0N/A * </tr>
0N/A *
0N/A * <tr>
0N/A * <td>attachVirtualMachine</td>
0N/A * <td>Ability to attach to another Java virtual machine and load agents
0N/A * into that VM.
0N/A * </td>
0N/A * <td>This allows an attacker to control the target VM which can potentially
0N/A * cause it to misbehave.
0N/A * </td>
0N/A * </tr>
0N/A *
0N/A * <tr>
0N/A * <td>createAttachProvider</td>
0N/A * <td>Ability to create an <code>AttachProvider</code> instance.
0N/A * </td>
0N/A * <td>This allows an attacker to create an AttachProvider which can
0N/A * potentially be used to attach to other Java virtual machines.
0N/A * </td>
0N/A * </tr>
0N/A
0N/A *
0N/A * </table>
0N/A
0N/A * <p>
0N/A * Programmers do not normally create AttachPermission objects directly.
0N/A * Instead they are created by the security policy code based on reading
0N/A * the security policy file.
0N/A *
0N/A * @see com.sun.tools.attach.VirtualMachine
0N/A * @see com.sun.tools.attach.spi.AttachProvider
0N/A */
0N/A
0N/Apublic final class AttachPermission extends java.security.BasicPermission {
0N/A
0N/A /** use serialVersionUID for interoperability */
0N/A static final long serialVersionUID = -4619447669752976181L;
0N/A
0N/A /**
0N/A * Constructs a new AttachPermission object.
0N/A *
0N/A * @param name Permission name. Must be either "attachVirtualMachine",
0N/A * or "createAttachProvider".
0N/A *
0N/A * @throws NullPointerException if name is <code>null</code>.
0N/A * @throws IllegalArgumentException if the name is invalid.
0N/A */
0N/A public AttachPermission(String name) {
0N/A super(name);
0N/A if (!name.equals("attachVirtualMachine") && !name.equals("createAttachProvider")) {
0N/A throw new IllegalArgumentException("name: " + name);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new AttachPermission object.
0N/A *
0N/A * @param name Permission name. Must be either "attachVirtualMachine",
0N/A * or "createAttachProvider".
0N/A *
0N/A * @param actions Not used and should be <code>null</code>, or
0N/A * the empty string.
0N/A *
0N/A * @throws NullPointerException if name is <code>null</code>.
0N/A * @throws IllegalArgumentException if arguments are invalid.
0N/A */
0N/A public AttachPermission(String name, String actions) {
0N/A super(name);
0N/A if (!name.equals("attachVirtualMachine") && !name.equals("createAttachProvider")) {
0N/A throw new IllegalArgumentException("name: " + name);
0N/A }
0N/A if (actions != null && actions.length() > 0) {
0N/A throw new IllegalArgumentException("actions: " + actions);
0N/A }
0N/A }
0N/A}