summaryrefslogtreecommitdiff
path: root/java/openjdk6/files/icedtea/security/20130201/7201064.patch
blob: 3ab97af24fc931344878c2dbc3f7b21775167112 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
diff --git a/src/share/classes/java/awt/Dialog.java b/src/share/classes/java/awt/Dialog.java
--- jdk/src/share/classes/java/awt/Dialog.java
+++ jdk/src/share/classes/java/awt/Dialog.java
@@ -34,6 +34,7 @@ import java.security.PrivilegedAction;
 import java.security.PrivilegedAction;
 import javax.accessibility.*;
 import sun.awt.AppContext;
+import java.security.AccessControlException;
 import sun.awt.SunToolkit;
 import sun.awt.PeerEvent;
 import sun.awt.util.IdentityArrayList;
@@ -127,6 +128,8 @@ public class Dialog extends Window {
      * @since 1.4
      */
     boolean undecorated = false;
+
+    private transient boolean initialized = false;
 
     /**
      * Modal dialogs block all input to some top-level windows.
@@ -679,6 +682,7 @@ public class Dialog extends Window {
         this.title = title;
         setModalityType(modalityType);
         SunToolkit.checkAndSetPolicy(this, false);
+        initialized = true;
     }
 
     /**
@@ -730,6 +734,7 @@ public class Dialog extends Window {
         this.title = title;
         setModalityType(modalityType);
         SunToolkit.checkAndSetPolicy(this, false);
+        initialized = true;
     }
 
     /**
@@ -859,12 +864,9 @@ public class Dialog extends Window {
         if (modalityType == type) {
             return;
         }
-        if (type == ModalityType.TOOLKIT_MODAL) {
-            SecurityManager sm = System.getSecurityManager();
-            if (sm != null) {
-                sm.checkPermission(SecurityConstants.TOOLKIT_MODALITY_PERMISSION);
-            }
-        }
+
+        checkModalityPermission(type);
+
         modalityType = type;
         modal = (modalityType != ModalityType.MODELESS);
     }
@@ -1039,6 +1041,11 @@ public class Dialog extends Window {
      */
     @Deprecated
     public void show() {
+        if (!initialized) {
+            throw new IllegalStateException("The dialog component " +
+                "has not been initialized properly");
+        }
+
         beforeFirstShow = false;
         if (!isModal()) {
             conditionalShow(null, null);
@@ -1614,18 +1621,50 @@ public class Dialog extends Window {
         }
     }
 
+    private void checkModalityPermission(ModalityType mt) {
+        if (mt == ModalityType.TOOLKIT_MODAL) {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPermission(
+                    SecurityConstants.TOOLKIT_MODALITY_PERMISSION
+                );
+            }
+        }
+    }
+
     private void readObject(ObjectInputStream s)
         throws ClassNotFoundException, IOException, HeadlessException
     {
         GraphicsEnvironment.checkHeadless();
-        s.defaultReadObject();
+
+        java.io.ObjectInputStream.GetField fields =
+            s.readFields();
+
+        ModalityType localModalityType = (ModalityType)fields.get("modalityType", null);
+
+        try {
+            checkModalityPermission(localModalityType);
+        } catch (AccessControlException ace) {
+            localModalityType = DEFAULT_MODALITY_TYPE;
+        }
 
         // in 1.5 or earlier modalityType was absent, so use "modal" instead
-        if (modalityType == null) {
+        if (localModalityType == null) {
+            this.modal = fields.get("modal", false);
             setModal(modal);
         }
 
+        this.resizable = fields.get("resizable", true);
+        this.undecorated = fields.get("undecorated", false);
+        this.title = (String)fields.get("title", "");
+        this.modalityType = localModalityType;
+
         blockedWindows = new IdentityArrayList();
+
+        SunToolkit.checkAndSetPolicy(this, false);
+
+        initialized = true;
+
     }
 
     /*