view patches/security/20120214/7110683.patch @ 2374:7e1fcd4b6da6

Add security patches for 2012/02/14. 2012-02-08 Omair Majid <omajid@redhat.com> * NEWS: Update with security fixes. * Makefile.am (SECURITY_PATCHES): Add security patches. (SPECIAL_SECURITY_PATCH): Add new variable. (ICEDTEA_PATCHES): Add security patch that epends on backport. * patches/security/20120214/7082299.patch, * patches/security/20120214/7088367.patch, * patches/security/20120214/7110683.patch, * patches/security/20120214/7110687.patch, * patches/security/20120214/7110700.patch, * patches/security/20120214/7110704.patch, * patches/security/20120214/7112642.patch, * patches/security/20120214/7118283.patch, * patches/security/20120214/7126960.patch: New security fixes.
author Andrew John Hughes <ahughes@redhat.com>
date Thu, 09 Feb 2012 18:41:13 +0000
parents
children
line wrap: on
line source

# HG changeset patch
# User skoppar
# Date 1324575564 28800
# Node ID e05eb7bee1ce0a44f3e414454e44cd49d77ba9de
# Parent  bfaa99d5bef813217cdbc6eddcdd511cf53327e7
7110683: Issues with some KeyboardFocusManager method
7116384: backout the unallowed changes in the KeyboardFocusManager.java javadoc
Reviewed-by: ant

diff --git a/src/share/classes/java/awt/KeyboardFocusManager.java b/src/share/classes/java/awt/KeyboardFocusManager.java
--- openjdk/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
+++ openjdk/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -476,14 +476,8 @@ public abstract class KeyboardFocusManag
      */
     protected Component getGlobalFocusOwner() throws SecurityException {
         synchronized (KeyboardFocusManager.class) {
-            if (this == getCurrentKeyboardFocusManager()) {
-                return focusOwner;
-            } else {
-                if (focusLog.isLoggable(Level.FINER)) {
-                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
-                }
-                throw new SecurityException(notPrivileged);
-            }
+            checkCurrentKFMSecurity();
+            return focusOwner;
         }
     }
 
@@ -517,6 +511,7 @@ public abstract class KeyboardFocusManag
 
         if (focusOwner == null || focusOwner.isFocusable()) {
             synchronized (KeyboardFocusManager.class) {
+                checkCurrentKFMSecurity();
                 oldFocusOwner = getFocusOwner();
 
                 try {
@@ -566,6 +561,10 @@ public abstract class KeyboardFocusManag
      * @see java.awt.event.FocusEvent#FOCUS_LOST
      */
     public void clearGlobalFocusOwner() {
+        synchronized (KeyboardFocusManager.class) {
+             checkCurrentKFMSecurity();
+        } 
+
         if (!GraphicsEnvironment.isHeadless()) {
             // Toolkit must be fully initialized, otherwise
             // _clearGlobalFocusOwner will crash or throw an exception
@@ -645,14 +644,8 @@ public abstract class KeyboardFocusManag
         throws SecurityException
     {
         synchronized (KeyboardFocusManager.class) {
-            if (this == getCurrentKeyboardFocusManager()) {
-                return permanentFocusOwner;
-            } else {
-                if (focusLog.isLoggable(Level.FINER)) {
-                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
-                }
-                throw new SecurityException(notPrivileged);
-            }
+            checkCurrentKFMSecurity();
+            return permanentFocusOwner;
         }
     }
 
@@ -688,6 +681,7 @@ public abstract class KeyboardFocusManag
 
         if (permanentFocusOwner == null || permanentFocusOwner.isFocusable()) {
             synchronized (KeyboardFocusManager.class) {
+                checkCurrentKFMSecurity();
                 oldPermanentFocusOwner = getPermanentFocusOwner();
 
                 try {
@@ -753,14 +747,8 @@ public abstract class KeyboardFocusManag
      */
     protected Window getGlobalFocusedWindow() throws SecurityException {
         synchronized (KeyboardFocusManager.class) {
-            if (this == getCurrentKeyboardFocusManager()) {
-               return focusedWindow;
-            } else {
-                if (focusLog.isLoggable(Level.FINER)) {
-                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
-                }
-                throw new SecurityException(notPrivileged);
-            }
+            checkCurrentKFMSecurity();
+            return focusedWindow;
         }
     }
 
@@ -791,6 +779,7 @@ public abstract class KeyboardFocusManag
 
         if (focusedWindow == null || focusedWindow.isFocusableWindow()) {
             synchronized (KeyboardFocusManager.class) {
+                checkCurrentKFMSecurity();
                 oldFocusedWindow = getFocusedWindow();
 
                 try {
@@ -857,14 +846,8 @@ public abstract class KeyboardFocusManag
      */
     protected Window getGlobalActiveWindow() throws SecurityException {
         synchronized (KeyboardFocusManager.class) {
-            if (this == getCurrentKeyboardFocusManager()) {
-               return activeWindow;
-            } else {
-                if (focusLog.isLoggable(Level.FINER)) {
-                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
-                }
-                throw new SecurityException(notPrivileged);
-            }
+            checkCurrentKFMSecurity();
+            return activeWindow;
         }
     }
 
@@ -893,6 +876,7 @@ public abstract class KeyboardFocusManag
     protected void setGlobalActiveWindow(Window activeWindow) {
         Window oldActiveWindow;
         synchronized (KeyboardFocusManager.class) {
+            checkCurrentKFMSecurity();
             oldActiveWindow = getActiveWindow();
             if (focusLog.isLoggable(Level.FINER)) {
                 focusLog.log(Level.FINER, "Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
@@ -1187,14 +1171,8 @@ public abstract class KeyboardFocusManag
         throws SecurityException
     {
         synchronized (KeyboardFocusManager.class) {
-            if (this == getCurrentKeyboardFocusManager()) {
-                return currentFocusCycleRoot;
-            } else {
-                if (focusLog.isLoggable(Level.FINER)) {
-                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
-                }
-                throw new SecurityException(notPrivileged);
-            }
+            checkCurrentKFMSecurity();
+            return currentFocusCycleRoot;
         }
     }
 
@@ -1218,6 +1196,7 @@ public abstract class KeyboardFocusManag
         Container oldFocusCycleRoot;
 
         synchronized (KeyboardFocusManager.class) {
+            checkCurrentKFMSecurity();
             oldFocusCycleRoot  = getCurrentFocusCycleRoot();
             currentFocusCycleRoot = newFocusCycleRoot;
         }
@@ -3102,4 +3081,14 @@ public abstract class KeyboardFocusManag
                 : null;
         }
     }
+
+     private void checkCurrentKFMSecurity() {
+         if (this != getCurrentKeyboardFocusManager()) {
+             if (focusLog.isLoggable(Level.FINER)) {
+                 focusLog.finer("This manager is " + this +
+                                ", current is " + getCurrentKeyboardFocusManager());
+             }
+             throw new SecurityException(notPrivileged);
+         }
+     }
 }