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