--- old/src/java.desktop/share/classes/java/awt/Desktop.java 2016-08-31 01:40:01.000000000 +0300 +++ new/src/java.desktop/share/classes/java/awt/Desktop.java 2016-08-31 01:40:00.000000000 +0300 @@ -271,6 +271,14 @@ } } + private static void checkEventsProcessingPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission( + "canProcessApplicationEvents")); + } + } + /** * Returns the {@code Desktop} instance of the current * desktop context. On some platforms the Desktop API may not be @@ -662,7 +670,8 @@ * * @throws SecurityException if a security manager exists and it * denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} * permission * * @see java.awt.desktop.AppForegroundListener @@ -674,6 +683,7 @@ * @since 9 */ public void addAppEventListener(final SystemEventListener listener) { + checkEventsProcessingPermission(); checkAWTPermission(); peer.addAppEventListener(listener); } @@ -689,7 +699,8 @@ * * @throws SecurityException if a security manager exists and it * denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} * permission * * @see java.awt.desktop.AppForegroundListener @@ -701,6 +712,7 @@ * @since 9 */ public void removeAppEventListener(final SystemEventListener listener) { + checkEventsProcessingPermission(); checkAWTPermission(); peer.removeAppEventListener(listener); } @@ -716,7 +728,8 @@ * * @throws SecurityException if a security manager exists and it * denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} * permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_ABOUT} action @@ -724,6 +737,7 @@ * @since 9 */ public void setAboutHandler(final AboutHandler aboutHandler) { + checkEventsProcessingPermission(); checkAWTPermission(); checkActionSupport(Action.APP_ABOUT); peer.setAboutHandler(aboutHandler); @@ -741,13 +755,15 @@ * * @throws SecurityException if a security manager exists and it * denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} * permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_PREFERENCES} action * @since 9 */ public void setPreferencesHandler(final PreferencesHandler preferencesHandler) { + checkEventsProcessingPermission(); checkAWTPermission(); checkActionSupport(Action.APP_PREFERENCES); peer.setPreferencesHandler(preferencesHandler); @@ -770,7 +786,8 @@ * @throws SecurityException if a security manager exists and its * {@link java.lang.SecurityManager#checkRead(java.lang.String)} * method denies read access to the files, or it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} * permission, or the calling thread is not allowed to create a * subprocess * @throws UnsupportedOperationException if the current platform @@ -778,6 +795,7 @@ * @since 9 */ public void setOpenFileHandler(final OpenFilesHandler openFileHandler) { + checkEventsProcessingPermission(); checkAWTPermission(); checkExec(); checkRead(); @@ -800,12 +818,14 @@ * @param printFileHandler handler * @throws SecurityException if a security manager exists and its * {@link java.lang.SecurityManager#checkPrintJobAccess()} method denies - * the permission to print. + * the permission to print or it denies the + * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_PRINT_FILE} action * @since 9 */ public void setPrintFileHandler(final PrintFilesHandler printFileHandler) { + checkEventsProcessingPermission(); SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPrintJobAccess(); @@ -832,7 +852,8 @@ * * @param openURIHandler handler * - * {@code AWTPermission("showWindowWithoutWarningBanner")} + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} * permission, or the calling thread is not allowed to create a * subprocess * @throws UnsupportedOperationException if the current platform @@ -840,6 +861,7 @@ * @since 9 */ public void setOpenURIHandler(final OpenURIHandler openURIHandler) { + checkEventsProcessingPermission(); checkAWTPermission(); checkExec(); checkActionSupport(Action.APP_OPEN_URI); @@ -856,12 +878,14 @@ * asked to quit * * @throws SecurityException if a security manager exists and it - * will not allow the caller to invoke {@code System.exit} + * will not allow the caller to invoke {@code System.exit} or it denies the + * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_QUIT_HANDLER} action * @since 9 */ public void setQuitHandler(final QuitHandler quitHandler) { + checkEventsProcessingPermission(); checkQuitPermission(); checkActionSupport(Action.APP_QUIT_HANDLER); peer.setQuitHandler(quitHandler); @@ -874,13 +898,15 @@ * @param strategy the way this application should be shutdown * * @throws SecurityException if a security manager exists and it - * will not allow the caller to invoke {@code System.exit} + * will not allow the caller to invoke {@code System.exit} or it denies the + * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action * @see QuitStrategy * @since 9 */ public void setQuitStrategy(final QuitStrategy strategy) { + checkEventsProcessingPermission(); checkQuitPermission(); checkActionSupport(Action.APP_QUIT_STRATEGY); peer.setQuitStrategy(strategy); @@ -901,13 +927,15 @@ * effectively "kill -KILL" your application. * * @throws SecurityException if a security manager exists and it - * will not allow the caller to invoke {@code System.exit} + * will not allow the caller to invoke {@code System.exit} or it denies the + * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action * @see #disableSuddenTermination() * @since 9 */ public void enableSuddenTermination() { + checkEventsProcessingPermission(); checkQuitPermission(); checkActionSupport(Action.APP_SUDDEN_TERMINATION); peer.enableSuddenTermination(); @@ -920,13 +948,15 @@ * may not be terminated without notification. * * @throws SecurityException if a security manager exists and it - * will not allow the caller to invoke {@code System.exit} + * will not allow the caller to invoke {@code System.exit} or it denies the + * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action * @see #enableSuddenTermination() * @since 9 */ public void disableSuddenTermination() { + checkEventsProcessingPermission(); checkQuitPermission(); checkActionSupport(Action.APP_SUDDEN_TERMINATION); peer.disableSuddenTermination(); @@ -938,12 +968,14 @@ * @param allWindows if all windows of this application should be moved to * the foreground, or only the foremost one * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_REQUEST_FOREGROUND} action * @since 9 */ public void requestForeground(final boolean allWindows) { + checkEventsProcessingPermission(); checkAWTPermission(); checkActionSupport(Action.APP_REQUEST_FOREGROUND); peer.requestForeground(allWindows); @@ -957,12 +989,14 @@ * and registered in the Info.plist with CFBundleHelpBookFolder * * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_HELP_VIEWER} action * @since 9 */ public void openHelpViewer() { + checkEventsProcessingPermission(); checkAWTPermission(); checkActionSupport(Action.APP_HELP_VIEWER); peer.openHelpViewer(); @@ -975,12 +1009,14 @@ * * @param menuBar to use when no other frames are active * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_MENU_BAR} action * @since 9 */ public void setDefaultMenuBar(final JMenuBar menuBar) { + checkEventsProcessingPermission(); checkAWTPermission(); checkActionSupport(Action.APP_MENU_BAR); peer.setDefaultMenuBar(menuBar); --- old/src/java.desktop/share/classes/java/awt/Taskbar.java 2016-08-31 01:40:01.000000000 +0300 +++ new/src/java.desktop/share/classes/java/awt/Taskbar.java 2016-08-31 01:40:01.000000000 +0300 @@ -179,17 +179,20 @@ /** * Calls to the security manager's {@code checkPermission} method with - * an {@code AWTPermission("showWindowWithoutWarningBanner")} - * permission. + * an {@code AWTPermission("showWindowWithoutWarningBanner")} and an + * {@code AWTPermission("canProcessApplicationEvents")} + * permissions. */ - private void checkAWTPermission(){ + private void checkPermissions(){ SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AWTPermission( + "canProcessApplicationEvents")); + sm.checkPermission(new AWTPermission( "showWindowWithoutWarningBanner")); } } - + private Taskbar() { Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); if (defaultToolkit instanceof SunToolkit) { @@ -262,12 +265,13 @@ * @param enabled disables this request if false * @param critical if this is an important request * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#USER_ATTENTION} feature */ public void requestUserAttention(final boolean enabled, final boolean critical) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.USER_ATTENTION); peer.requestUserAttention(enabled, critical); } @@ -279,12 +283,13 @@ * * @param w window * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#USER_ATTENTION_WINDOW} feature */ public void requestWindowUserAttention(Window w) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.USER_ATTENTION_WINDOW); peer.requestWindowUserAttention(w); } @@ -295,12 +300,13 @@ * * @param menu the PopupMenu to attach to this application * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#MENU} feature */ public void setMenu(final PopupMenu menu) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.MENU); peer.setMenu(menu); } @@ -310,12 +316,13 @@ * * @return the PopupMenu * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#MENU} feature */ public PopupMenu getMenu() { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.MENU); return peer.getMenu(); } @@ -325,12 +332,13 @@ * * @param image to change * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature */ public void setIconImage(final Image image) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.ICON_IMAGE); peer.setIconImage(image); } @@ -340,12 +348,13 @@ * * @return an image of this application's icon * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature */ public Image getIconImage() { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.ICON_IMAGE); return peer.getIconImage(); } @@ -362,13 +371,14 @@ * Passing {@code null} as parameter hides the badge. * @param badge label to affix to the icon * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER} * or {@link Taskbar.Feature#ICON_BADGE_TEXT} feature */ public void setIconBadge(final String badge) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.ICON_BADGE_NUMBER); peer.setIconBadge(badge); } @@ -381,12 +391,13 @@ * @param w window to update * @param badge image to affix to the icon * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#ICON_BADGE_IMAGE_WINDOW} feature */ public void setWindowIconBadge(Window w, final Image badge) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.ICON_BADGE_IMAGE_WINDOW); if (w != null) { peer.setWindowIconBadge(w, badge); @@ -398,11 +409,14 @@ * Affixes a small system-provided progress bar to this application's icon. * * @param value from 0 to 100, other to disable progress indication + * @throws SecurityException if a security manager exists and it denies the + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#PROGRESS_VALUE} feature */ public void setProgressValue(int value) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.PROGRESS_VALUE); peer.setProgressValue(value); } @@ -413,12 +427,13 @@ * @param w window to update * @param value from 0 to 100, other to disable progress indication * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#PROGRESS_VALUE_WINDOW} feature */ public void setWindowProgressValue(Window w, int value) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.PROGRESS_VALUE_WINDOW); if (w != null) { peer.setWindowProgressValue(w, value); @@ -436,12 +451,13 @@ * @see State#INDETERMINATE * @see State#ERROR * @throws SecurityException if a security manager exists and it denies the - * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. + * {@code AWTPermission("showWindowWithoutWarningBanner")} or the + * {@code RuntimePermission("canProcessApplicationEvents")} permission. * @throws UnsupportedOperationException if the current platform * does not support the {@link Taskbar.Feature#PROGRESS_STATE_WINDOW} feature */ public void setWindowProgressState(Window w, State state) { - checkAWTPermission(); + checkPermissions(); checkFeatureSupport(Feature.PROGRESS_STATE_WINDOW); if (w != null) { peer.setWindowProgressState(w, state);