1 /* 2 * Copyright (c) 1997, 2017, 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.awt; 27 28 import java.security.BasicPermission; 29 30 /** 31 * This class is for AWT permissions. 32 * An {@code AWTPermission} contains a target name but 33 * no actions list; you either have the named permission 34 * or you don't. 35 * 36 * <P> 37 * The target name is the name of the AWT permission (see below). The naming 38 * convention follows the hierarchical property naming convention. 39 * Also, an asterisk could be used to represent all AWT permissions. 40 * 41 * <P> 42 * The following table lists all the possible {@code AWTPermission} 43 * target names, and for each provides a description of what the 44 * permission allows and a discussion of the risks of granting code 45 * the permission. 46 * 47 * <table class="striped"> 48 * <caption>AWTPermission target names, descriptions, and associated risks 49 * </caption> 50 * <thead> 51 * <tr> 52 * <th scope="col">Permission Target Name 53 * <th scope="col">What the Permission Allows 54 * <th scope="col">Risks of Allowing this Permission 55 * </thead> 56 * <tbody> 57 * <tr> 58 * <th scope="row">accessClipboard 59 * <td>Posting and retrieval of information to and from the AWT clipboard 60 * <td>This would allow malfeasant code to share potentially sensitive or 61 * confidential information. 62 * <tr> 63 * <th scope="row">accessEventQueue 64 * <td>Access to the AWT event queue 65 * <td>After retrieving the AWT event queue, malicious code may peek at and 66 * even remove existing events from its event queue, as well as post bogus 67 * events which may purposefully cause the application or applet to 68 * misbehave in an insecure manner. 69 * <tr> 70 * <th scope="row">accessSystemTray 71 * <td>Access to the AWT SystemTray instance 72 * <td>This would allow malicious code to add tray icons to the system tray. 73 * First, such an icon may look like the icon of some known application 74 * (such as a firewall or anti-virus) and order a user to do something 75 * unsafe (with help of balloon messages). Second, the system tray may be 76 * glutted with tray icons so that no one could add a tray icon anymore. 77 * <tr> 78 * <th scope="row">createRobot 79 * <td>Create java.awt.Robot objects 80 * <td>The java.awt.Robot object allows code to generate native-level mouse 81 * and keyboard events as well as read the screen. It could allow malicious 82 * code to control the system, run other programs, read the display, and 83 * deny mouse and keyboard access to the user. 84 * <tr> 85 * <th scope="row">fullScreenExclusive 86 * <td>Enter full-screen exclusive mode 87 * <td>Entering full-screen exclusive mode allows direct access to low-level 88 * graphics card memory. This could be used to spoof the system, since the 89 * program is in direct control of rendering. Depending on the 90 * implementation, the security warning may not be shown for the windows 91 * used to enter the full-screen exclusive mode (assuming that the 92 * {@code fullScreenExclusive} permission has been granted to this 93 * application). Note that this behavior does not mean that the 94 * {@code showWindowWithoutWarningBanner} permission will be automatically 95 * granted to the application which has the {@code fullScreenExclusive} 96 * permission: non-full-screen windows will continue to be shown with the 97 * security warning. 98 * <tr> 99 * <th scope="row">listenToAllAWTEvents 100 * <td>Listen to all AWT events, system-wide 101 * <td>After adding an AWT event listener, malicious code may scan all AWT 102 * events dispatched in the system, allowing it to read all user input (such 103 * as passwords). Each AWT event listener is called from within the context 104 * of that event queue's EventDispatchThread, so if the accessEventQueue 105 * permission is also enabled, malicious code could modify the contents of 106 * AWT event queues system-wide, causing the application or applet to 107 * misbehave in an insecure manner. 108 * <tr> 109 * <th scope="row">readDisplayPixels 110 * <td>Readback of pixels from the display screen 111 * <td>Interfaces such as the java.awt.Composite interface or the 112 * java.awt.Robot class allow arbitrary code to examine pixels on the 113 * display enable malicious code to snoop on the activities of the user. 114 * <tr> 115 * <th scope="row">replaceKeyboardFocusManager 116 * <td>Sets the {@code KeyboardFocusManager} for a particular thread. 117 * <td>When {@code SecurityManager} is installed, the invoking thread must 118 * be granted this permission in order to replace the current 119 * {@code KeyboardFocusManager}. If permission is not granted, a 120 * {@code SecurityException} will be thrown. 121 * <tr> 122 * <th scope="row">setAppletStub 123 * <td>Setting the stub which implements Applet container services 124 * <td>Malicious code could set an applet's stub and result in unexpected 125 * behavior or denial of service to an applet. 126 * <tr> 127 * <th scope="row">setWindowAlwaysOnTop 128 * <td>Setting always-on-top property of the window: 129 * {@link Window#setAlwaysOnTop} 130 * <td>The malicious window might make itself look and behave like a real 131 * full desktop, so that information entered by the unsuspecting user is 132 * captured and subsequently misused 133 * <tr> 134 * <th scope="row">showWindowWithoutWarningBanner 135 * <td>Display of a window without also displaying a banner warning that the 136 * window was created by an applet 137 * <td>Without this warning, an applet may pop up windows without the user 138 * knowing that they belong to an applet. Since users may make 139 * security-sensitive decisions based on whether or not the window belongs 140 * to an applet (entering a username and password into a dialog box, for 141 * example), disabling this warning banner may allow applets to trick the 142 * user into entering such information. 143 * <tr> 144 * <th scope="row">toolkitModality 145 * <td>Creating {@link Dialog.ModalityType#TOOLKIT_MODAL TOOLKIT_MODAL} 146 * dialogs and setting the 147 * {@link Dialog.ModalExclusionType#TOOLKIT_EXCLUDE TOOLKIT_EXCLUDE} window 148 * property. 149 * <td>When a toolkit-modal dialog is shown from an applet, it blocks all 150 * other applets in the browser. When launching applications from Java Web 151 * Start, its windows (such as the security dialog) may also be blocked by 152 * toolkit-modal dialogs, shown from these applications. 153 * <tr> 154 * <th scope="row">watchMousePointer 155 * <td>Getting the information about the mouse pointer position at any time 156 * <td>Constantly watching the mouse pointer, an applet can make guesses 157 * about what the user is doing, i.e. moving the mouse to the lower left 158 * corner of the screen most likely means that the user is about to launch 159 * an application. If a virtual keypad is used so that keyboard is emulated 160 * using the mouse, an applet may guess what is being typed. 161 * </tbody> 162 * </table> 163 * 164 * @see java.security.BasicPermission 165 * @see java.security.Permission 166 * @see java.security.Permissions 167 * @see java.security.PermissionCollection 168 * @see java.lang.SecurityManager 169 * 170 * @author Marianne Mueller 171 * @author Roland Schemers 172 */ 173 public final class AWTPermission extends BasicPermission { 174 175 /** use serialVersionUID from the Java 2 platform for interoperability */ 176 private static final long serialVersionUID = 8890392402588814465L; 177 178 /** 179 * Creates a new {@code AWTPermission} with the specified name. 180 * The name is the symbolic name of the {@code AWTPermission}, 181 * such as "topLevelWindow", "systemClipboard", etc. An asterisk 182 * may be used to indicate all AWT permissions. 183 * 184 * @param name the name of the AWTPermission 185 * 186 * @throws NullPointerException if {@code name} is {@code null}. 187 * @throws IllegalArgumentException if {@code name} is empty. 188 */ 189 190 public AWTPermission(String name) 191 { 192 super(name); 193 } 194 195 /** 196 * Creates a new {@code AWTPermission} object with the specified name. 197 * The name is the symbolic name of the {@code AWTPermission}, and the 198 * actions string is currently unused and should be {@code null}. 199 * 200 * @param name the name of the {@code AWTPermission} 201 * @param actions should be {@code null} 202 * 203 * @throws NullPointerException if {@code name} is {@code null}. 204 * @throws IllegalArgumentException if {@code name} is empty. 205 */ 206 207 public AWTPermission(String name, String actions) 208 { 209 super(name, actions); 210 } 211 }