1 /* 2 * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.dyn; 27 28 import java.security.*; 29 import java.util.Enumeration; 30 import java.util.Hashtable; 31 import java.util.StringTokenizer; 32 33 /** 34 * This class is for managing runtime permission checking for 35 * operations performed by methods in the {@link Linkage} class. 36 * Like a {@link RuntimePermission}, on which it is modeled, 37 * a {@code LinkagePermission} contains a target name but 38 * no actions list; you either have the named permission 39 * or you don't. 40 * <p> 41 * The following table lists all the possible {@code LinkagePermission} target names, 42 * and for each provides a description of what the permission allows 43 * and a discussion of the risks of granting code the permission. 44 * <p> 45 * 46 * <table border=1 cellpadding=5 summary="permission target name, 47 * what the target allows,and associated risks"> 48 * <tr> 49 * <th>Permission Target Name</th> 50 * <th>What the Permission Allows</th> 51 * <th>Risks of Allowing this Permission</th> 52 * </tr> 53 * 54 * <tr> 55 * <td>registerBootstrapMethod.{class name}</td> 56 * <td>Specifying a bootstrap method for {@code invokedynamic} instructions within a class of the given name</td> 57 * <td>An attacker could attempt to attach a bootstrap method to a class which 58 * has just been loaded, thus gaining control of its {@code invokedynamic} calls.</td> 59 * </tr> 60 * 61 * <tr> 62 * <td>invalidateAll</td> 63 * <td>Force the relinking of invokedynamic call sites everywhere.</td> 64 * <td>This could allow an attacker to slow down the system, 65 * or perhaps expose timing bugs in a dynamic language implementations, 66 * by forcing redundant relinking operations.</td> 67 * </tr> 68 * 69 * 70 * <tr> 71 * <td>invalidateCallerClass.{class name}</td> 72 * <td>Force the relinking of invokedynamic call sites in the given class.</td> 73 * <td>See {@code invalidateAll}.</td> 74 * </tr> 75 * </table> 76 * 77 * @see java.security.RuntimePermission 78 * @see java.lang.SecurityManager 79 * 80 * @author John Rose, JSR 292 EG 81 */ 82 83 public final class LinkagePermission extends BasicPermission { 84 /** 85 * Create a new LinkagePermission with the given name. 86 * The name is the symbolic name of the LinkagePermission, such as 87 * "registerBootstrapMethod", "invalidateCallerClass.*", etc. An asterisk 88 * may appear at the end of the name, following a ".", or by itself, to 89 * signify a wildcard match. 90 * 91 * @param name the name of the LinkagePermission 92 */ 93 public LinkagePermission(String name) { 94 super(name); 95 } 96 97 /** 98 * Create a new LinkagePermission with the given name on the given class. 99 * Equivalent to {@code LinkagePermission(name+"."+clazz.getName())}. 100 * 101 * @param name the name of the LinkagePermission 102 * @param clazz the class affected by the permission 103 */ 104 public LinkagePermission(String name, Class<?> clazz) { 105 super(name + "." + clazz.getName()); 106 } 107 }