1 /*
   2  * Copyright 2008-2009 Sun Microsystems, Inc.  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.  Sun designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any 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 runtime permissions. A RuntimePermission
  35  * contains a name (also referred to as a "target name") but
  36  * no actions list; you either have the named permission
  37  * or you don't.
  38  *
  39  * <P>
  40  * The target name is the name of the runtime permission (see below). The
  41  * naming convention follows the  hierarchical property naming convention.
  42  * Also, an asterisk
  43  * may appear at the end of the name, following a ".", or by itself, to
  44  * signify a wildcard match. For example: "loadLibrary.*" or "*" is valid,
  45  * "*loadLibrary" or "a*b" is not valid.
  46  * <P>
  47  * The following table lists all the possible RuntimePermission target names,
  48  * and for each provides a description of what the permission allows
  49  * and a discussion of the risks of granting code the permission.
  50  * <P>
  51  *
  52  * <table border=1 cellpadding=5 summary="permission target name,
  53  *  what the target allows,and associated risks">
  54  * <tr>
  55  * <th>Permission Target Name</th>
  56  * <th>What the Permission Allows</th>
  57  * <th>Risks of Allowing this Permission</th>
  58  * </tr>
  59  *
  60  * <tr>
  61  *   <td>registerBootstrapMethod.{class name}</td>
  62  *   <td>Specifying a bootstrap method for invokedynamic, within a class of the given name</td>
  63  *   <td>An attacker could attempt to attach a bootstrap method to a class which
  64  *       has just been loaded, thus gaining control of its invokedynamic calls.</td>
  65  * </tr>
  66  *
  67  * <tr>
  68  *   <td>invalidateAll</td>
  69  *   <td>Force the relinking of invokedynamic call sites everywhere.</td>
  70  *   <td>This could allow an attacker to slow down the system, or perhaps surface timing bugs in a dynamic language implementations, by forcing redundant relinking operations.</td>
  71  * </tr>
  72  *
  73  *
  74  * <tr>
  75  *   <td>invalidateCallerClass.{class name}</td>
  76  *   <td>Force the relinking of invokedynamic call sites in the given class.</td>
  77  *   <td>See {@code invalidateAll}.</td>
  78  * </tr>
  79  * </table>
  80  *
  81  * @see java.security.BasicPermission
  82  * @see java.lang.SecurityManager
  83  *
  84  * @author John Rose, JSR 292 EG
  85  */
  86 
  87 public final class LinkagePermission extends BasicPermission {
  88     /**
  89      * Create a new LinkagePermission with the given name.
  90      * The name is the symbolic name of the LinkagePermission, such as
  91      * "registerBootstrapMethod", "invalidateClass.*", etc. An asterisk
  92      * may appear at the end of the name, following a ".", or by itself, to
  93      * signify a wildcard match.
  94      *
  95      * @param name the name of the LinkagePermission
  96      */
  97     public LinkagePermission(String name) {
  98         super(name);
  99     }
 100 
 101     /**
 102      * Create a new LinkagePermission with the given name on the given class.
 103      * Equivalent to {@code LinkagePermission(name+"."+clazz.getName())}.
 104      *
 105      * @param name the name of the LinkagePermission
 106      * @param clazz the class affected by the permission
 107      */
 108     public LinkagePermission(String name, Class<?> clazz) {
 109         super(name + "." + clazz.getName());
 110     }
 111 }