8344667: Remove most uses of AWT Permissions from the desktop module
Reviewed-by: azvegint, kizune
This commit is contained in:
parent
8de158aefe
commit
027607968b
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
@ -62,8 +61,6 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
private static boolean oglPipelineEnabled = false;
|
||||
|
||||
|
||||
private static AWTPermission fullScreenExclusivePermission;
|
||||
|
||||
// Save/restore DisplayMode for the Full Screen mode
|
||||
private DisplayMode originalMode;
|
||||
private DisplayMode initialMode;
|
||||
@ -260,23 +257,6 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
*/
|
||||
@Override
|
||||
public boolean isFullScreenSupported() {
|
||||
return isFSExclusiveModeAllowed();
|
||||
}
|
||||
|
||||
private static boolean isFSExclusiveModeAllowed() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
if (fullScreenExclusivePermission == null) {
|
||||
fullScreenExclusivePermission =
|
||||
new AWTPermission("fullScreenExclusive");
|
||||
}
|
||||
try {
|
||||
security.checkPermission(fullScreenExclusivePermission);
|
||||
} catch (SecurityException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package java.applet;
|
||||
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
@ -127,12 +126,6 @@ public class Applet extends Panel {
|
||||
* @param stub the new stub
|
||||
*/
|
||||
public final void setStub(AppletStub stub) {
|
||||
if (this.stub != null) {
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null) {
|
||||
s.checkPermission(new AWTPermission("setAppletStub"));
|
||||
}
|
||||
}
|
||||
this.stub = stub;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@ import java.awt.peer.DialogPeer;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serial;
|
||||
import java.security.AccessControlException;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@ -42,7 +41,6 @@ import javax.accessibility.AccessibleRole;
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.util.IdentityArrayList;
|
||||
@ -844,8 +842,6 @@ public class Dialog extends Window {
|
||||
return;
|
||||
}
|
||||
|
||||
checkModalityPermission(type);
|
||||
|
||||
modalityType = type;
|
||||
modal = (modalityType != ModalityType.MODELESS);
|
||||
}
|
||||
@ -1561,16 +1557,6 @@ public class Dialog extends Window {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkModalityPermission(ModalityType mt) {
|
||||
if (mt == ModalityType.TOOLKIT_MODAL) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(AWTPermissions.TOOLKIT_MODALITY_PERMISSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads serializable fields from stream.
|
||||
*
|
||||
@ -1592,12 +1578,6 @@ public class Dialog extends Window {
|
||||
|
||||
ModalityType localModalityType = (ModalityType)fields.get("modalityType", null);
|
||||
|
||||
try {
|
||||
checkModalityPermission(localModalityType);
|
||||
} catch (@SuppressWarnings("removal") AccessControlException ace) {
|
||||
localModalityType = DEFAULT_MODALITY_TYPE;
|
||||
}
|
||||
|
||||
// in 1.5 or earlier modalityType was absent, so use "modal" instead
|
||||
if (localModalityType == null) {
|
||||
this.modal = fields.get("modal", false);
|
||||
|
@ -226,7 +226,6 @@ public abstract class KeyboardFocusManager
|
||||
* @see DefaultKeyboardFocusManager
|
||||
*/
|
||||
public static void setCurrentKeyboardFocusManager(KeyboardFocusManager newManager) {
|
||||
checkReplaceKFMPermission();
|
||||
|
||||
KeyboardFocusManager oldManager = null;
|
||||
|
||||
@ -354,12 +353,6 @@ public abstract class KeyboardFocusManager
|
||||
*/
|
||||
private static java.util.Map<Window, WeakReference<Component>> mostRecentFocusOwners = new WeakHashMap<>();
|
||||
|
||||
/**
|
||||
* We cache the permission used to verify that the calling thread is
|
||||
* permitted to access the global focus state.
|
||||
*/
|
||||
private static AWTPermission replaceKeyboardFocusManagerPermission;
|
||||
|
||||
/*
|
||||
* SequencedEvent which is currently dispatched in AppContext.
|
||||
*/
|
||||
@ -473,7 +466,6 @@ public abstract class KeyboardFocusManager
|
||||
*/
|
||||
protected Component getGlobalFocusOwner() {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
return focusOwner;
|
||||
}
|
||||
}
|
||||
@ -506,7 +498,6 @@ public abstract class KeyboardFocusManager
|
||||
|
||||
if (focusOwner == null || focusOwner.isFocusable()) {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
|
||||
oldFocusOwner = getFocusOwner();
|
||||
|
||||
@ -584,7 +575,6 @@ public abstract class KeyboardFocusManager
|
||||
* @see java.awt.event.FocusEvent#FOCUS_LOST
|
||||
*/
|
||||
public void clearGlobalFocusOwner() {
|
||||
checkReplaceKFMPermission();
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
// Toolkit must be fully initialized, otherwise
|
||||
// _clearGlobalFocusOwner will crash or throw an exception
|
||||
@ -660,7 +650,6 @@ public abstract class KeyboardFocusManager
|
||||
*/
|
||||
protected Component getGlobalPermanentFocusOwner() {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
return permanentFocusOwner;
|
||||
}
|
||||
}
|
||||
@ -694,7 +683,6 @@ public abstract class KeyboardFocusManager
|
||||
|
||||
if (permanentFocusOwner == null || permanentFocusOwner.isFocusable()) {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
|
||||
oldPermanentFocusOwner = getPermanentFocusOwner();
|
||||
|
||||
@ -755,7 +743,6 @@ public abstract class KeyboardFocusManager
|
||||
*/
|
||||
protected Window getGlobalFocusedWindow() {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
return focusedWindow;
|
||||
}
|
||||
}
|
||||
@ -785,7 +772,6 @@ public abstract class KeyboardFocusManager
|
||||
|
||||
if (focusedWindow == null || focusedWindow.isFocusableWindow()) {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
|
||||
oldFocusedWindow = getFocusedWindow();
|
||||
|
||||
@ -847,7 +833,6 @@ public abstract class KeyboardFocusManager
|
||||
*/
|
||||
protected Window getGlobalActiveWindow() {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
return activeWindow;
|
||||
}
|
||||
}
|
||||
@ -875,7 +860,6 @@ public abstract class KeyboardFocusManager
|
||||
protected void setGlobalActiveWindow(Window activeWindow) {
|
||||
Window oldActiveWindow;
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
|
||||
oldActiveWindow = getActiveWindow();
|
||||
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
@ -1152,7 +1136,6 @@ public abstract class KeyboardFocusManager
|
||||
*/
|
||||
protected Container getGlobalCurrentFocusCycleRoot() {
|
||||
synchronized (KeyboardFocusManager.class) {
|
||||
checkKFMSecurity();
|
||||
return currentFocusCycleRoot;
|
||||
}
|
||||
}
|
||||
@ -1172,7 +1155,6 @@ public abstract class KeyboardFocusManager
|
||||
* @see #getGlobalCurrentFocusCycleRoot
|
||||
*/
|
||||
public void setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot) {
|
||||
checkReplaceKFMPermission();
|
||||
|
||||
Container oldFocusCycleRoot;
|
||||
|
||||
@ -2976,40 +2958,4 @@ public abstract class KeyboardFocusManager
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkReplaceKFMPermission()
|
||||
throws SecurityException
|
||||
{
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
if (replaceKeyboardFocusManagerPermission == null) {
|
||||
replaceKeyboardFocusManagerPermission =
|
||||
new AWTPermission("replaceKeyboardFocusManager");
|
||||
}
|
||||
security.
|
||||
checkPermission(replaceKeyboardFocusManagerPermission);
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if this KeyboardFocusManager instance is the current KFM,
|
||||
// or otherwise checks if the calling thread has "replaceKeyboardFocusManager"
|
||||
// permission. Here's the reasoning to do so:
|
||||
//
|
||||
// A system KFM instance (which is the current KFM by default) may have no
|
||||
// "replaceKFM" permission when a client code is on the call stack beneath,
|
||||
// but still it should be able to execute the methods protected by this check
|
||||
// due to the system KFM is trusted (and so it does like "privileged").
|
||||
//
|
||||
// If this KFM instance is not the current KFM but the client code has all
|
||||
// permissions we can't throw SecurityException because it would contradict
|
||||
// the security concepts. In this case the trusted client code is responsible
|
||||
// for calling the secured methods from KFM instance which is not current.
|
||||
private void checkKFMSecurity()
|
||||
throws SecurityException
|
||||
{
|
||||
if (this != getCurrentKeyboardFocusManager()) {
|
||||
checkReplaceKFMPermission();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package java.awt;
|
||||
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.ComponentFactory;
|
||||
|
||||
/**
|
||||
@ -66,12 +65,6 @@ public class MouseInfo {
|
||||
throw new HeadlessException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION);
|
||||
}
|
||||
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
Point point = new Point(0, 0);
|
||||
int deviceNum = 0;
|
||||
|
@ -37,7 +37,6 @@ import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.awt.peer.RobotPeer;
|
||||
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.ComponentFactory;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.image.SunWritableRaster;
|
||||
@ -163,7 +162,6 @@ public class Robot {
|
||||
}
|
||||
|
||||
private void init(GraphicsDevice screen) throws AWTException {
|
||||
checkRobotAllowed();
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
if (toolkit instanceof ComponentFactory) {
|
||||
peer = ((ComponentFactory)toolkit).createRobot(screen);
|
||||
@ -193,15 +191,6 @@ public class Robot {
|
||||
LEGAL_BUTTON_MASK = tmpMask;
|
||||
}
|
||||
|
||||
/* determine if the security policy allows Robot's to be created */
|
||||
private static void checkRobotAllowed() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.CREATE_ROBOT_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for headless state and throw {@code AWTException} if headless.
|
||||
*/
|
||||
@ -437,7 +426,6 @@ public class Robot {
|
||||
* @return Color of the pixel
|
||||
*/
|
||||
public synchronized Color getPixelColor(int x, int y) {
|
||||
checkScreenCaptureAllowed();
|
||||
Point point = peer.useAbsoluteCoordinates() ? toDeviceSpaceAbs(x, y)
|
||||
: toDeviceSpace(x, y);
|
||||
return new Color(peer.getRGBPixel(point.x, point.y));
|
||||
@ -518,8 +506,6 @@ public class Robot {
|
||||
private synchronized BufferedImage[]
|
||||
createCompatibleImage(Rectangle screenRect, boolean isHiDPI) {
|
||||
|
||||
checkScreenCaptureAllowed();
|
||||
|
||||
checkValidRect(screenRect);
|
||||
|
||||
BufferedImage lowResolutionImage;
|
||||
@ -635,14 +621,6 @@ public class Robot {
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkScreenCaptureAllowed() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.READ_DISPLAY_PIXELS_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called after an event is generated
|
||||
*/
|
||||
|
@ -32,7 +32,6 @@ import java.beans.PropertyChangeSupport;
|
||||
import java.util.Vector;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.HeadlessToolkit;
|
||||
import sun.awt.SunToolkit;
|
||||
@ -160,7 +159,6 @@ public class SystemTray {
|
||||
* @see #isSupported
|
||||
*/
|
||||
public static SystemTray getSystemTray() {
|
||||
checkSystemTrayAllowed();
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException();
|
||||
}
|
||||
@ -494,14 +492,6 @@ public class SystemTray {
|
||||
}
|
||||
}
|
||||
|
||||
static void checkSystemTrayAllowed() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.ACCESS_SYSTEM_TRAY_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initializeSystemTrayIfNeeded() {
|
||||
synchronized (SystemTray.class) {
|
||||
if (systemTray == null) {
|
||||
|
@ -72,7 +72,6 @@ import java.util.stream.Collectors;
|
||||
import javax.accessibility.AccessibilityProvider;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.HeadlessToolkit;
|
||||
import sun.awt.PeerEvent;
|
||||
@ -1360,11 +1359,6 @@ public abstract class Toolkit {
|
||||
* @return the {@code EventQueue} object
|
||||
*/
|
||||
public final EventQueue getSystemEventQueue() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.CHECK_AWT_EVENTQUEUE_PERMISSION);
|
||||
}
|
||||
return getSystemEventQueueImpl();
|
||||
}
|
||||
|
||||
@ -1690,11 +1684,6 @@ public abstract class Toolkit {
|
||||
if (localL == null) {
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
|
||||
}
|
||||
synchronized (this) {
|
||||
SelectiveAWTEventListener selectiveListener =
|
||||
listener2SelectiveListener.get(localL);
|
||||
@ -1750,11 +1739,6 @@ public abstract class Toolkit {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
SelectiveAWTEventListener selectiveListener =
|
||||
@ -1807,11 +1791,6 @@ public abstract class Toolkit {
|
||||
* @since 1.4
|
||||
*/
|
||||
public AWTEventListener[] getAWTEventListeners() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
|
||||
}
|
||||
synchronized (this) {
|
||||
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
|
||||
|
||||
@ -1851,11 +1830,6 @@ public abstract class Toolkit {
|
||||
* @since 1.4
|
||||
*/
|
||||
public AWTEventListener[] getAWTEventListeners(long eventMask) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
|
||||
}
|
||||
synchronized (this) {
|
||||
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
|
||||
|
||||
|
@ -118,9 +118,8 @@ public class TrayIcon {
|
||||
}
|
||||
|
||||
private TrayIcon()
|
||||
throws UnsupportedOperationException, HeadlessException, SecurityException
|
||||
throws UnsupportedOperationException, HeadlessException
|
||||
{
|
||||
SystemTray.checkSystemTrayAllowed();
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException();
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.DebugSettings;
|
||||
import sun.awt.SunToolkit;
|
||||
@ -1627,13 +1626,6 @@ public class Window extends Container implements Accessible {
|
||||
if (modalExclusionType == exclusionType) {
|
||||
return;
|
||||
}
|
||||
if (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(AWTPermissions.TOOLKIT_MODALITY_PERMISSION);
|
||||
}
|
||||
}
|
||||
modalExclusionType = exclusionType;
|
||||
|
||||
// if we want on-fly changes, we need to uncomment the lines below
|
||||
@ -2169,12 +2161,6 @@ public class Window extends Container implements Accessible {
|
||||
* @since 1.5
|
||||
*/
|
||||
public final void setAlwaysOnTop(boolean alwaysOnTop) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
|
||||
}
|
||||
|
||||
boolean oldAlwaysOnTop;
|
||||
synchronized(this) {
|
||||
oldAlwaysOnTop = this.alwaysOnTop;
|
||||
|
@ -1096,12 +1096,8 @@ public class JInternalFrame extends JComponent implements
|
||||
fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
|
||||
else {
|
||||
fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
|
||||
try {
|
||||
java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
|
||||
java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
|
||||
new sun.awt.UngrabEvent(this));
|
||||
} catch (SecurityException e) {
|
||||
this.dispatchEvent(new sun.awt.UngrabEvent(this));
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
@ -1970,14 +1970,6 @@ public class SwingUtilities implements SwingConstants
|
||||
public void show() {
|
||||
// This frame can never be shown
|
||||
}
|
||||
public void dispose() {
|
||||
try {
|
||||
getToolkit().getSystemEventQueue();
|
||||
super.dispose();
|
||||
} catch (Exception e) {
|
||||
// untrusted code not allowed to dispose
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -528,12 +528,7 @@ public class BasicInternalFrameTitlePane extends JComponent
|
||||
protected void postClosingEvent(JInternalFrame frame) {
|
||||
InternalFrameEvent e = new InternalFrameEvent(
|
||||
frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING);
|
||||
// Try posting event, unless there's a SecurityManager.
|
||||
try {
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
|
||||
} catch (SecurityException se) {
|
||||
frame.dispatchEvent(e);
|
||||
}
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,28 +35,4 @@ public final class AWTPermissions {
|
||||
|
||||
public static final AWTPermission ACCESS_CLIPBOARD_PERMISSION =
|
||||
new AWTPermission("accessClipboard");
|
||||
|
||||
public static final AWTPermission CHECK_AWT_EVENTQUEUE_PERMISSION =
|
||||
new AWTPermission("accessEventQueue");
|
||||
|
||||
public static final AWTPermission TOOLKIT_MODALITY_PERMISSION =
|
||||
new AWTPermission("toolkitModality");
|
||||
|
||||
public static final AWTPermission READ_DISPLAY_PIXELS_PERMISSION =
|
||||
new AWTPermission("readDisplayPixels");
|
||||
|
||||
public static final AWTPermission CREATE_ROBOT_PERMISSION =
|
||||
new AWTPermission("createRobot");
|
||||
|
||||
public static final AWTPermission WATCH_MOUSE_PERMISSION =
|
||||
new AWTPermission("watchMousePointer");
|
||||
|
||||
public static final AWTPermission SET_WINDOW_ALWAYS_ON_TOP_PERMISSION =
|
||||
new AWTPermission("setWindowAlwaysOnTop");
|
||||
|
||||
public static final AWTPermission ALL_AWT_EVENTS_PERMISSION =
|
||||
new AWTPermission("listenToAllAWTEvents");
|
||||
|
||||
public static final AWTPermission ACCESS_SYSTEM_TRAY_PERMISSION =
|
||||
new AWTPermission("accessSystemTray");
|
||||
}
|
||||
|
@ -1082,22 +1082,9 @@ public abstract class SunToolkit extends Toolkit
|
||||
|
||||
/**
|
||||
* Returns whether popup is allowed to be shown above the task bar.
|
||||
* This is a default implementation of this method, which checks
|
||||
* corresponding security permission.
|
||||
*/
|
||||
public boolean canPopupOverlapTaskBar() {
|
||||
boolean result = true;
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
// There is no permission to show popups over the task bar
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -437,11 +437,6 @@ public class BufImgSurfaceData extends SurfaceData {
|
||||
return new Rectangle(bufImg.getWidth(), bufImg.getHeight());
|
||||
}
|
||||
|
||||
protected void checkCustomComposite() {
|
||||
// BufferedImages always allow Custom Composite objects since
|
||||
// their pixels are immediately retrievable anyway.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns destination Image associated with this SurfaceData.
|
||||
*/
|
||||
|
@ -130,15 +130,6 @@ public class NullSurfaceData extends SurfaceData {
|
||||
return new Rectangle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs Security Permissions checks to see if a Custom
|
||||
* Composite object should be allowed access to the pixels
|
||||
* of this surface.
|
||||
*/
|
||||
protected void checkCustomComposite() {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a copyarea within this surface. Returns
|
||||
* false if there is no algorithm to perform the copyarea
|
||||
|
@ -974,7 +974,6 @@ public final class SunGraphics2D
|
||||
} else if (comp == null) {
|
||||
throw new IllegalArgumentException("null Composite");
|
||||
} else {
|
||||
surfaceData.checkCustomComposite();
|
||||
newCompState = COMP_CUSTOM;
|
||||
newCompType = CompositeType.General;
|
||||
}
|
||||
|
@ -1002,25 +1002,6 @@ public abstract class SurfaceData
|
||||
*/
|
||||
public abstract Rectangle getBounds();
|
||||
|
||||
static java.security.Permission compPermission;
|
||||
|
||||
/**
|
||||
* Performs Security Permissions checks to see if a Custom
|
||||
* Composite object should be allowed access to the pixels
|
||||
* of this surface.
|
||||
*/
|
||||
protected void checkCustomComposite() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
if (compPermission == null) {
|
||||
compPermission =
|
||||
new java.awt.AWTPermission("readDisplayPixels");
|
||||
}
|
||||
sm.checkPermission(compPermission);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches private field IndexColorModel.allgrayopaque
|
||||
* which is true when all palette entries in the color
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
@ -65,7 +64,6 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
private volatile int screen;
|
||||
Map<SurfaceType, SurfaceManager.ProxyCache> x11ProxyCacheMap = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private static AWTPermission fullScreenExclusivePermission;
|
||||
private static Boolean xrandrExtSupported;
|
||||
private SunDisplayChanger topLevels = new SunDisplayChanger();
|
||||
private DisplayMode origDisplayMode;
|
||||
@ -335,23 +333,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
|
||||
@Override
|
||||
public boolean isFullScreenSupported() {
|
||||
boolean fsAvailable = isXrandrExtensionSupported();
|
||||
if (fsAvailable) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
if (fullScreenExclusivePermission == null) {
|
||||
fullScreenExclusivePermission =
|
||||
new AWTPermission("fullScreenExclusive");
|
||||
}
|
||||
try {
|
||||
security.checkPermission(fullScreenExclusivePermission);
|
||||
} catch (SecurityException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fsAvailable;
|
||||
return isXrandrExtensionSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
@ -81,7 +80,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
// pipelines which are mutually exclusive with opengl, for which
|
||||
// pixel formats were added in the first place
|
||||
protected static boolean pfDisabled;
|
||||
private static AWTPermission fullScreenExclusivePermission;
|
||||
// the original display mode we had before entering the fullscreen
|
||||
// mode
|
||||
private DisplayMode defaultDisplayMode;
|
||||
@ -349,29 +347,12 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice());
|
||||
}
|
||||
|
||||
private static boolean isFSExclusiveModeAllowed() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
if (fullScreenExclusivePermission == null) {
|
||||
fullScreenExclusivePermission =
|
||||
new AWTPermission("fullScreenExclusive");
|
||||
}
|
||||
try {
|
||||
security.checkPermission(fullScreenExclusivePermission);
|
||||
} catch (SecurityException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true unless we're not allowed to use fullscreen mode.
|
||||
*/
|
||||
@Override
|
||||
public boolean isFullScreenSupported() {
|
||||
return isFSExclusiveModeAllowed();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,11 +68,8 @@ public class ExtendedRobot extends Robot {
|
||||
* @throws AWTException if the platform configuration does not allow low-level input
|
||||
* control. This exception is always thrown when
|
||||
* GraphicsEnvironment.isHeadless() returns true
|
||||
* @throws SecurityException if {@code createRobot} permission is not granted
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see SecurityManager#checkPermission
|
||||
* @see java.awt.AWTPermission
|
||||
*/
|
||||
public ExtendedRobot() throws AWTException {
|
||||
super();
|
||||
@ -99,12 +96,9 @@ public class ExtendedRobot extends Robot {
|
||||
* GraphicsEnvironment.isHeadless() returns true.
|
||||
* @throws IllegalArgumentException if {@code screen} is not a screen
|
||||
* GraphicsDevice.
|
||||
* @throws SecurityException if {@code createRobot} permission is not granted
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see GraphicsDevice
|
||||
* @see SecurityManager#checkPermission
|
||||
* @see java.awt.AWTPermission
|
||||
*/
|
||||
public ExtendedRobot(GraphicsDevice screen) throws AWTException {
|
||||
super(screen);
|
||||
|
Loading…
Reference in New Issue
Block a user