Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/awt/AWTPermission.java
38829 views
/*1* Copyright (c) 1997, 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 java.awt;2627import java.security.BasicPermission;2829/**30* This class is for AWT permissions.31* An <code>AWTPermission</code> contains a target name but32* no actions list; you either have the named permission33* or you don't.34*35* <P>36* The target name is the name of the AWT permission (see below). The naming37* convention follows the hierarchical property naming convention.38* Also, an asterisk could be used to represent all AWT permissions.39*40* <P>41* The following table lists all the possible <code>AWTPermission</code>42* target names, and for each provides a description of what the43* permission allows and a discussion of the risks of granting code44* the permission.45*46* <table border=1 cellpadding=5 summary="AWTPermission target names, descriptions, and associated risks.">47* <tr>48* <th>Permission Target Name</th>49* <th>What the Permission Allows</th>50* <th>Risks of Allowing this Permission</th>51* </tr>52*53* <tr>54* <td>accessClipboard</td>55* <td>Posting and retrieval of information to and from the AWT clipboard</td>56* <td>This would allow malfeasant code to share57* potentially sensitive or confidential information.</td>58* </tr>59*60* <tr>61* <td>accessEventQueue</td>62* <td>Access to the AWT event queue</td>63* <td>After retrieving the AWT event queue,64* malicious code may peek at and even remove existing events65* from its event queue, as well as post bogus events which may purposefully66* cause the application or applet to misbehave in an insecure manner.</td>67* </tr>68*69* <tr>70* <td>accessSystemTray</td>71* <td>Access to the AWT SystemTray instance</td>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 application74* (such as a firewall or anti-virus) and order a user to do something unsafe75* (with help of balloon messages). Second, the system tray may be glutted with76* tray icons so that no one could add a tray icon anymore.</td>77* </tr>78*79* <tr>80* <td>createRobot</td>81* <td>Create java.awt.Robot objects</td>82* <td>The java.awt.Robot object allows code to generate native-level83* mouse and keyboard events as well as read the screen. It could allow84* malicious code to control the system, run other programs, read the85* display, and deny mouse and keyboard access to the user.</td>86* </tr>87*88* <tr>89* <td>fullScreenExclusive</td>90* <td>Enter full-screen exclusive mode</td>91* <td>Entering full-screen exclusive mode allows direct access to92* low-level graphics card memory. This could be used to spoof the93* system, since the program is in direct control of rendering. Depending on94* the implementation, the security warning may not be shown for the windows95* used to enter the full-screen exclusive mode (assuming that the {@code96* fullScreenExclusive} permission has been granted to this application). Note97* that this behavior does not mean that the {@code98* showWindowWithoutWarningBanner} permission will be automatically granted to99* the application which has the {@code fullScreenExclusive} permission:100* non-full-screen windows will continue to be shown with the security101* warning.</td>102* </tr>103*104* <tr>105* <td>listenToAllAWTEvents</td>106* <td>Listen to all AWT events, system-wide</td>107* <td>After adding an AWT event listener,108* malicious code may scan all AWT events dispatched in the system,109* allowing it to read all user input (such as passwords). Each110* AWT event listener is called from within the context of that111* event queue's EventDispatchThread, so if the accessEventQueue112* permission is also enabled, malicious code could modify the113* contents of AWT event queues system-wide, causing the application114* or applet to misbehave in an insecure manner.</td>115* </tr>116*117* <tr>118* <td>readDisplayPixels</td>119* <td>Readback of pixels from the display screen</td>120* <td>Interfaces such as the java.awt.Composite interface or the121* java.awt.Robot class allow arbitrary code to examine pixels on the122* display enable malicious code to snoop on the activities of the user.</td>123* </tr>124*125* <tr>126* <td>replaceKeyboardFocusManager</td>127* <td>Sets the <code>KeyboardFocusManager</code> for128* a particular thread.129* <td>When <code>SecurityManager</code> is installed, the invoking130* thread must be granted this permission in order to replace131* the current <code>KeyboardFocusManager</code>. If permission132* is not granted, a <code>SecurityException</code> will be thrown.133* </tr>134*135* <tr>136* <td>setAppletStub</td>137* <td>Setting the stub which implements Applet container services</td>138* <td>Malicious code could set an applet's stub and result in unexpected139* behavior or denial of service to an applet.</td>140* </tr>141*142* <tr>143* <td>setWindowAlwaysOnTop</td>144* <td>Setting always-on-top property of the window: {@link Window#setAlwaysOnTop}</td>145* <td>The malicious window might make itself look and behave like a real full desktop, so that146* information entered by the unsuspecting user is captured and subsequently misused </td>147* </tr>148*149* <tr>150* <td>showWindowWithoutWarningBanner</td>151* <td>Display of a window without also displaying a banner warning152* that the window was created by an applet</td>153* <td>Without this warning,154* an applet may pop up windows without the user knowing that they155* belong to an applet. Since users may make security-sensitive156* decisions based on whether or not the window belongs to an applet157* (entering a username and password into a dialog box, for example),158* disabling this warning banner may allow applets to trick the user159* into entering such information.</td>160* </tr>161*162* <tr>163* <td>toolkitModality</td>164* <td>Creating {@link Dialog.ModalityType#TOOLKIT_MODAL TOOLKIT_MODAL} dialogs165* and setting the {@link Dialog.ModalExclusionType#TOOLKIT_EXCLUDE166* TOOLKIT_EXCLUDE} window property.</td>167* <td>When a toolkit-modal dialog is shown from an applet, it blocks all other168* applets in the browser. When launching applications from Java Web Start,169* its windows (such as the security dialog) may also be blocked by toolkit-modal170* dialogs, shown from these applications.</td>171* </tr>172*173* <tr>174* <td>watchMousePointer</td>175* <td>Getting the information about the mouse pointer position at any176* time</td>177* <td>Constantly watching the mouse pointer,178* an applet can make guesses about what the user is doing, i.e. moving179* the mouse to the lower left corner of the screen most likely means that180* the user is about to launch an application. If a virtual keypad is used181* so that keyboard is emulated using the mouse, an applet may guess what182* is being typed.</td>183* </tr>184* </table>185*186* @see java.security.BasicPermission187* @see java.security.Permission188* @see java.security.Permissions189* @see java.security.PermissionCollection190* @see java.lang.SecurityManager191*192*193* @author Marianne Mueller194* @author Roland Schemers195*/196197public final class AWTPermission extends BasicPermission {198199/** use serialVersionUID from the Java 2 platform for interoperability */200private static final long serialVersionUID = 8890392402588814465L;201202/**203* Creates a new <code>AWTPermission</code> with the specified name.204* The name is the symbolic name of the <code>AWTPermission</code>,205* such as "topLevelWindow", "systemClipboard", etc. An asterisk206* may be used to indicate all AWT permissions.207*208* @param name the name of the AWTPermission209*210* @throws NullPointerException if <code>name</code> is <code>null</code>.211* @throws IllegalArgumentException if <code>name</code> is empty.212*/213214public AWTPermission(String name)215{216super(name);217}218219/**220* Creates a new <code>AWTPermission</code> object with the specified name.221* The name is the symbolic name of the <code>AWTPermission</code>, and the222* actions string is currently unused and should be <code>null</code>.223*224* @param name the name of the <code>AWTPermission</code>225* @param actions should be <code>null</code>226*227* @throws NullPointerException if <code>name</code> is <code>null</code>.228* @throws IllegalArgumentException if <code>name</code> is empty.229*/230231public AWTPermission(String name, String actions)232{233super(name, actions);234}235}236237238