author | sundar |
Mon, 31 Aug 2015 17:51:02 +0530 | |
changeset 32434 | 769b3d81ae69 |
parent 31803 | a359181776b2 |
child 35382 | 1f36500e84c7 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
5609
cc144006eb2a
6951599: Rename package of security tools for modularization
mchung
parents:
3483
diff
changeset
|
26 |
package sun.security.tools.policytool; |
2 | 27 |
|
28 |
import java.io.*; |
|
29 |
import java.util.LinkedList; |
|
30 |
import java.util.ListIterator; |
|
31 |
import java.util.Vector; |
|
32 |
import java.util.Enumeration; |
|
33 |
import java.net.URL; |
|
34 |
import java.net.MalformedURLException; |
|
35 |
import java.lang.reflect.*; |
|
36 |
import java.text.Collator; |
|
37 |
import java.text.MessageFormat; |
|
38 |
import sun.security.util.PropertyExpander; |
|
39 |
import sun.security.util.PropertyExpander.ExpandException; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
40 |
import java.awt.Component; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
41 |
import java.awt.Container; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
42 |
import java.awt.Dimension; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
43 |
import java.awt.FileDialog; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
44 |
import java.awt.GridBagConstraints; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
45 |
import java.awt.GridBagLayout; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
46 |
import java.awt.Insets; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
47 |
import java.awt.Point; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
48 |
import java.awt.Toolkit; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
49 |
import java.awt.Window; |
2 | 50 |
import java.awt.event.*; |
51 |
import java.security.cert.Certificate; |
|
52 |
import java.security.cert.CertificateException; |
|
53 |
import java.security.*; |
|
54 |
import sun.security.provider.*; |
|
55 |
import sun.security.util.PolicyUtil; |
|
56 |
import javax.security.auth.x500.X500Principal; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
57 |
import javax.swing.*; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
58 |
import javax.swing.border.EmptyBorder; |
2 | 59 |
|
60 |
/** |
|
61 |
* PolicyTool may be used by users and administrators to configure the |
|
62 |
* overall java security policy (currently stored in the policy file). |
|
7532 | 63 |
* Using PolicyTool administrators may add and remove policies from |
2 | 64 |
* the policy file. <p> |
65 |
* |
|
66 |
* @see java.security.Policy |
|
67 |
* @since 1.2 |
|
68 |
*/ |
|
69 |
||
70 |
public class PolicyTool { |
|
71 |
||
72 |
// for i18n |
|
73 |
static final java.util.ResourceBundle rb = |
|
14182
3041082abb40
7194449: String resources for Key Tool and Policy Tool should be in their respective packages
sflores
parents:
10336
diff
changeset
|
74 |
java.util.ResourceBundle.getBundle( |
3041082abb40
7194449: String resources for Key Tool and Policy Tool should be in their respective packages
sflores
parents:
10336
diff
changeset
|
75 |
"sun.security.tools.policytool.Resources"); |
2 | 76 |
static final Collator collator = Collator.getInstance(); |
77 |
static { |
|
78 |
// this is for case insensitive string comparisons |
|
79 |
collator.setStrength(Collator.PRIMARY); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
80 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
81 |
// Support for Apple menu bar |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
82 |
if (System.getProperty("apple.laf.useScreenMenuBar") == null) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
83 |
System.setProperty("apple.laf.useScreenMenuBar", "true"); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
84 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
85 |
System.setProperty("apple.awt.application.name", getMessage("Policy.Tool")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
86 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
87 |
// Apply the system L&F if not specified with a system property. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
88 |
if (System.getProperty("swing.defaultlaf") == null) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
89 |
try { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
90 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
91 |
} catch (Exception e) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
92 |
// ignore |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
93 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
94 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
95 |
} |
2 | 96 |
|
97 |
// anyone can add warnings |
|
98 |
Vector<String> warnings; |
|
99 |
boolean newWarning = false; |
|
100 |
||
101 |
// set to true if policy modified. |
|
102 |
// this way upon exit we know if to ask the user to save changes |
|
103 |
boolean modified = false; |
|
104 |
||
105 |
private static final boolean testing = false; |
|
20754
3d7b2fafc34b
8025967: addition of -Werror broke the old build
valeriep
parents:
17692
diff
changeset
|
106 |
private static final Class<?>[] TWOPARAMS = { String.class, String.class }; |
3d7b2fafc34b
8025967: addition of -Werror broke the old build
valeriep
parents:
17692
diff
changeset
|
107 |
private static final Class<?>[] ONEPARAMS = { String.class }; |
3d7b2fafc34b
8025967: addition of -Werror broke the old build
valeriep
parents:
17692
diff
changeset
|
108 |
private static final Class<?>[] NOPARAMS = {}; |
2 | 109 |
/* |
110 |
* All of the policy entries are read in from the |
|
111 |
* policy file and stored here. Updates to the policy entries |
|
112 |
* using addEntry() and removeEntry() are made here. To ultimately save |
|
113 |
* the policy entries back to the policy file, the SavePolicy button |
|
114 |
* must be clicked. |
|
115 |
**/ |
|
116 |
private static String policyFileName = null; |
|
117 |
private Vector<PolicyEntry> policyEntries = null; |
|
118 |
private PolicyParser parser = null; |
|
119 |
||
120 |
/* The public key alias information is stored here. */ |
|
121 |
private KeyStore keyStore = null; |
|
122 |
private String keyStoreName = " "; |
|
123 |
private String keyStoreType = " "; |
|
124 |
private String keyStoreProvider = " "; |
|
125 |
private String keyStorePwdURL = " "; |
|
126 |
||
127 |
/* standard PKCS11 KeyStore type */ |
|
128 |
private static final String P11KEYSTORE = "PKCS11"; |
|
129 |
||
130 |
/* reserved word for PKCS11 KeyStores */ |
|
131 |
private static final String NONE = "NONE"; |
|
132 |
||
133 |
/** |
|
134 |
* default constructor |
|
135 |
*/ |
|
136 |
private PolicyTool() { |
|
137 |
policyEntries = new Vector<PolicyEntry>(); |
|
138 |
parser = new PolicyParser(); |
|
139 |
warnings = new Vector<String>(); |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* get the PolicyFileName |
|
144 |
*/ |
|
145 |
String getPolicyFileName() { |
|
146 |
return policyFileName; |
|
147 |
} |
|
148 |
||
149 |
/** |
|
150 |
* set the PolicyFileName |
|
151 |
*/ |
|
152 |
void setPolicyFileName(String policyFileName) { |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
153 |
PolicyTool.policyFileName = policyFileName; |
2 | 154 |
} |
155 |
||
156 |
/** |
|
157 |
* clear keyStore info |
|
158 |
*/ |
|
159 |
void clearKeyStoreInfo() { |
|
160 |
this.keyStoreName = null; |
|
161 |
this.keyStoreType = null; |
|
162 |
this.keyStoreProvider = null; |
|
163 |
this.keyStorePwdURL = null; |
|
164 |
||
165 |
this.keyStore = null; |
|
166 |
} |
|
167 |
||
168 |
/** |
|
169 |
* get the keyStore URL name |
|
170 |
*/ |
|
171 |
String getKeyStoreName() { |
|
172 |
return keyStoreName; |
|
173 |
} |
|
174 |
||
175 |
/** |
|
176 |
* get the keyStore Type |
|
177 |
*/ |
|
178 |
String getKeyStoreType() { |
|
179 |
return keyStoreType; |
|
180 |
} |
|
181 |
||
182 |
/** |
|
183 |
* get the keyStore Provider |
|
184 |
*/ |
|
185 |
String getKeyStoreProvider() { |
|
186 |
return keyStoreProvider; |
|
187 |
} |
|
188 |
||
189 |
/** |
|
190 |
* get the keyStore password URL |
|
191 |
*/ |
|
192 |
String getKeyStorePwdURL() { |
|
193 |
return keyStorePwdURL; |
|
194 |
} |
|
195 |
||
196 |
/** |
|
197 |
* Open and read a policy file |
|
198 |
*/ |
|
199 |
void openPolicy(String filename) throws FileNotFoundException, |
|
200 |
PolicyParser.ParsingException, |
|
201 |
KeyStoreException, |
|
202 |
CertificateException, |
|
203 |
InstantiationException, |
|
204 |
MalformedURLException, |
|
205 |
IOException, |
|
206 |
NoSuchAlgorithmException, |
|
207 |
IllegalAccessException, |
|
208 |
NoSuchMethodException, |
|
209 |
UnrecoverableKeyException, |
|
210 |
NoSuchProviderException, |
|
211 |
ClassNotFoundException, |
|
212 |
PropertyExpander.ExpandException, |
|
213 |
InvocationTargetException { |
|
214 |
||
215 |
newWarning = false; |
|
216 |
||
217 |
// start fresh - blow away the current state |
|
218 |
policyEntries = new Vector<PolicyEntry>(); |
|
219 |
parser = new PolicyParser(); |
|
220 |
warnings = new Vector<String>(); |
|
221 |
setPolicyFileName(null); |
|
222 |
clearKeyStoreInfo(); |
|
223 |
||
224 |
// see if user is opening a NEW policy file |
|
225 |
if (filename == null) { |
|
226 |
modified = false; |
|
227 |
return; |
|
228 |
} |
|
229 |
||
230 |
// Read in the policy entries from the file and |
|
231 |
// populate the parser vector table. The parser vector |
|
232 |
// table only holds the entries as strings, so it only |
|
233 |
// guarantees that the policies are syntactically |
|
234 |
// correct. |
|
235 |
setPolicyFileName(filename); |
|
236 |
parser.read(new FileReader(filename)); |
|
237 |
||
238 |
// open the keystore |
|
239 |
openKeyStore(parser.getKeyStoreUrl(), parser.getKeyStoreType(), |
|
240 |
parser.getKeyStoreProvider(), parser.getStorePassURL()); |
|
241 |
||
242 |
// Update the local vector with the same policy entries. |
|
243 |
// This guarantees that the policy entries are not only |
|
244 |
// syntactically correct, but semantically valid as well. |
|
245 |
Enumeration<PolicyParser.GrantEntry> enum_ = parser.grantElements(); |
|
246 |
while (enum_.hasMoreElements()) { |
|
247 |
PolicyParser.GrantEntry ge = enum_.nextElement(); |
|
248 |
||
249 |
// see if all the signers have public keys |
|
250 |
if (ge.signedBy != null) { |
|
251 |
||
252 |
String signers[] = parseSigners(ge.signedBy); |
|
253 |
for (int i = 0; i < signers.length; i++) { |
|
254 |
PublicKey pubKey = getPublicKeyAlias(signers[i]); |
|
255 |
if (pubKey == null) { |
|
256 |
newWarning = true; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
257 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
258 |
("Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.")); |
2 | 259 |
Object[] source = {signers[i]}; |
260 |
warnings.addElement(form.format(source)); |
|
261 |
} |
|
262 |
} |
|
263 |
} |
|
264 |
||
265 |
// check to see if the Principals are valid |
|
266 |
ListIterator<PolicyParser.PrincipalEntry> prinList = |
|
267 |
ge.principals.listIterator(0); |
|
268 |
while (prinList.hasNext()) { |
|
269 |
PolicyParser.PrincipalEntry pe = prinList.next(); |
|
270 |
try { |
|
271 |
verifyPrincipal(pe.getPrincipalClass(), |
|
272 |
pe.getPrincipalName()); |
|
273 |
} catch (ClassNotFoundException fnfe) { |
|
274 |
newWarning = true; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
275 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
276 |
("Warning.Class.not.found.class")); |
2 | 277 |
Object[] source = {pe.getPrincipalClass()}; |
278 |
warnings.addElement(form.format(source)); |
|
279 |
} |
|
280 |
} |
|
281 |
||
282 |
// check to see if the Permissions are valid |
|
283 |
Enumeration<PolicyParser.PermissionEntry> perms = |
|
284 |
ge.permissionElements(); |
|
285 |
while (perms.hasMoreElements()) { |
|
286 |
PolicyParser.PermissionEntry pe = perms.nextElement(); |
|
287 |
try { |
|
288 |
verifyPermission(pe.permission, pe.name, pe.action); |
|
289 |
} catch (ClassNotFoundException fnfe) { |
|
290 |
newWarning = true; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
291 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
292 |
("Warning.Class.not.found.class")); |
2 | 293 |
Object[] source = {pe.permission}; |
294 |
warnings.addElement(form.format(source)); |
|
295 |
} catch (InvocationTargetException ite) { |
|
296 |
newWarning = true; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
297 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
298 |
("Warning.Invalid.argument.s.for.constructor.arg")); |
2 | 299 |
Object[] source = {pe.permission}; |
300 |
warnings.addElement(form.format(source)); |
|
301 |
} |
|
302 |
||
303 |
// see if all the permission signers have public keys |
|
304 |
if (pe.signedBy != null) { |
|
305 |
||
306 |
String signers[] = parseSigners(pe.signedBy); |
|
307 |
||
308 |
for (int i = 0; i < signers.length; i++) { |
|
309 |
PublicKey pubKey = getPublicKeyAlias(signers[i]); |
|
310 |
if (pubKey == null) { |
|
311 |
newWarning = true; |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
312 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
313 |
("Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.")); |
2 | 314 |
Object[] source = {signers[i]}; |
315 |
warnings.addElement(form.format(source)); |
|
316 |
} |
|
317 |
} |
|
318 |
} |
|
319 |
} |
|
320 |
PolicyEntry pEntry = new PolicyEntry(this, ge); |
|
321 |
policyEntries.addElement(pEntry); |
|
322 |
} |
|
323 |
||
324 |
// just read in the policy -- nothing has been modified yet |
|
325 |
modified = false; |
|
326 |
} |
|
327 |
||
328 |
||
329 |
/** |
|
330 |
* Save a policy to a file |
|
331 |
*/ |
|
332 |
void savePolicy(String filename) |
|
333 |
throws FileNotFoundException, IOException { |
|
334 |
// save the policy entries to a file |
|
335 |
parser.setKeyStoreUrl(keyStoreName); |
|
336 |
parser.setKeyStoreType(keyStoreType); |
|
337 |
parser.setKeyStoreProvider(keyStoreProvider); |
|
338 |
parser.setStorePassURL(keyStorePwdURL); |
|
339 |
parser.write(new FileWriter(filename)); |
|
340 |
modified = false; |
|
341 |
} |
|
342 |
||
343 |
/** |
|
344 |
* Open the KeyStore |
|
345 |
*/ |
|
346 |
void openKeyStore(String name, |
|
347 |
String type, |
|
348 |
String provider, |
|
349 |
String pwdURL) throws KeyStoreException, |
|
350 |
NoSuchAlgorithmException, |
|
351 |
UnrecoverableKeyException, |
|
352 |
IOException, |
|
353 |
CertificateException, |
|
354 |
NoSuchProviderException, |
|
355 |
ExpandException { |
|
356 |
||
357 |
if (name == null && type == null && |
|
358 |
provider == null && pwdURL == null) { |
|
359 |
||
360 |
// policy did not specify a keystore during open |
|
361 |
// or use wants to reset keystore values |
|
362 |
||
363 |
this.keyStoreName = null; |
|
364 |
this.keyStoreType = null; |
|
365 |
this.keyStoreProvider = null; |
|
366 |
this.keyStorePwdURL = null; |
|
367 |
||
368 |
// caller will set (tool.modified = true) if appropriate |
|
369 |
||
370 |
return; |
|
371 |
} |
|
372 |
||
373 |
URL policyURL = null; |
|
374 |
if (policyFileName != null) { |
|
375 |
File pfile = new File(policyFileName); |
|
376 |
policyURL = new URL("file:" + pfile.getCanonicalPath()); |
|
377 |
} |
|
378 |
||
379 |
// although PolicyUtil.getKeyStore may properly handle |
|
380 |
// defaults and property expansion, we do it here so that |
|
381 |
// if the call is successful, we can set the proper values |
|
382 |
// (PolicyUtil.getKeyStore does not return expanded values) |
|
383 |
||
384 |
if (name != null && name.length() > 0) { |
|
385 |
name = PropertyExpander.expand(name).replace |
|
386 |
(File.separatorChar, '/'); |
|
387 |
} |
|
388 |
if (type == null || type.length() == 0) { |
|
389 |
type = KeyStore.getDefaultType(); |
|
390 |
} |
|
391 |
if (pwdURL != null && pwdURL.length() > 0) { |
|
392 |
pwdURL = PropertyExpander.expand(pwdURL).replace |
|
393 |
(File.separatorChar, '/'); |
|
394 |
} |
|
395 |
||
396 |
try { |
|
397 |
this.keyStore = PolicyUtil.getKeyStore(policyURL, |
|
398 |
name, |
|
399 |
type, |
|
400 |
provider, |
|
401 |
pwdURL, |
|
402 |
null); |
|
403 |
} catch (IOException ioe) { |
|
404 |
||
405 |
// copied from sun.security.pkcs11.SunPKCS11 |
|
406 |
String MSG = "no password provided, and no callback handler " + |
|
407 |
"available for retrieving password"; |
|
408 |
||
409 |
Throwable cause = ioe.getCause(); |
|
410 |
if (cause != null && |
|
411 |
cause instanceof javax.security.auth.login.LoginException && |
|
412 |
MSG.equals(cause.getMessage())) { |
|
413 |
||
414 |
// throw a more friendly exception message |
|
415 |
throw new IOException(MSG); |
|
416 |
} else { |
|
417 |
throw ioe; |
|
418 |
} |
|
419 |
} |
|
420 |
||
421 |
this.keyStoreName = name; |
|
422 |
this.keyStoreType = type; |
|
423 |
this.keyStoreProvider = provider; |
|
424 |
this.keyStorePwdURL = pwdURL; |
|
425 |
||
426 |
// caller will set (tool.modified = true) |
|
427 |
} |
|
428 |
||
429 |
/** |
|
430 |
* Add a Grant entry to the overall policy at the specified index. |
|
431 |
* A policy entry consists of a CodeSource. |
|
432 |
*/ |
|
433 |
boolean addEntry(PolicyEntry pe, int index) { |
|
434 |
||
435 |
if (index < 0) { |
|
436 |
// new entry -- just add it to the end |
|
437 |
policyEntries.addElement(pe); |
|
438 |
parser.add(pe.getGrantEntry()); |
|
439 |
} else { |
|
440 |
// existing entry -- replace old one |
|
441 |
PolicyEntry origPe = policyEntries.elementAt(index); |
|
442 |
parser.replace(origPe.getGrantEntry(), pe.getGrantEntry()); |
|
443 |
policyEntries.setElementAt(pe, index); |
|
444 |
} |
|
445 |
return true; |
|
446 |
} |
|
447 |
||
448 |
/** |
|
449 |
* Add a Principal entry to an existing PolicyEntry at the specified index. |
|
450 |
* A Principal entry consists of a class, and name. |
|
451 |
* |
|
452 |
* If the principal already exists, it is not added again. |
|
453 |
*/ |
|
454 |
boolean addPrinEntry(PolicyEntry pe, |
|
455 |
PolicyParser.PrincipalEntry newPrin, |
|
456 |
int index) { |
|
457 |
||
458 |
// first add the principal to the Policy Parser entry |
|
459 |
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry(); |
|
460 |
if (grantEntry.contains(newPrin) == true) |
|
461 |
return false; |
|
462 |
||
463 |
LinkedList<PolicyParser.PrincipalEntry> prinList = |
|
464 |
grantEntry.principals; |
|
465 |
if (index != -1) |
|
466 |
prinList.set(index, newPrin); |
|
467 |
else |
|
468 |
prinList.add(newPrin); |
|
469 |
||
470 |
modified = true; |
|
471 |
return true; |
|
472 |
} |
|
473 |
||
474 |
/** |
|
475 |
* Add a Permission entry to an existing PolicyEntry at the specified index. |
|
476 |
* A Permission entry consists of a permission, name, and actions. |
|
477 |
* |
|
478 |
* If the permission already exists, it is not added again. |
|
479 |
*/ |
|
480 |
boolean addPermEntry(PolicyEntry pe, |
|
481 |
PolicyParser.PermissionEntry newPerm, |
|
482 |
int index) { |
|
483 |
||
484 |
// first add the permission to the Policy Parser Vector |
|
485 |
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry(); |
|
486 |
if (grantEntry.contains(newPerm) == true) |
|
487 |
return false; |
|
488 |
||
489 |
Vector<PolicyParser.PermissionEntry> permList = |
|
490 |
grantEntry.permissionEntries; |
|
491 |
if (index != -1) |
|
492 |
permList.setElementAt(newPerm, index); |
|
493 |
else |
|
494 |
permList.addElement(newPerm); |
|
495 |
||
496 |
modified = true; |
|
497 |
return true; |
|
498 |
} |
|
499 |
||
500 |
/** |
|
501 |
* Remove a Permission entry from an existing PolicyEntry. |
|
502 |
*/ |
|
503 |
boolean removePermEntry(PolicyEntry pe, |
|
504 |
PolicyParser.PermissionEntry perm) { |
|
505 |
||
506 |
// remove the Permission from the GrantEntry |
|
507 |
PolicyParser.GrantEntry ppge = pe.getGrantEntry(); |
|
508 |
modified = ppge.remove(perm); |
|
509 |
return modified; |
|
510 |
} |
|
511 |
||
512 |
/** |
|
513 |
* remove an entry from the overall policy |
|
514 |
*/ |
|
515 |
boolean removeEntry(PolicyEntry pe) { |
|
516 |
||
517 |
parser.remove(pe.getGrantEntry()); |
|
518 |
modified = true; |
|
519 |
return (policyEntries.removeElement(pe)); |
|
520 |
} |
|
521 |
||
522 |
/** |
|
523 |
* retrieve all Policy Entries |
|
524 |
*/ |
|
525 |
PolicyEntry[] getEntry() { |
|
526 |
||
527 |
if (policyEntries.size() > 0) { |
|
528 |
PolicyEntry entries[] = new PolicyEntry[policyEntries.size()]; |
|
529 |
for (int i = 0; i < policyEntries.size(); i++) |
|
530 |
entries[i] = policyEntries.elementAt(i); |
|
531 |
return entries; |
|
532 |
} |
|
533 |
return null; |
|
534 |
} |
|
535 |
||
536 |
/** |
|
537 |
* Retrieve the public key mapped to a particular name. |
|
538 |
* If the key has expired, a KeyException is thrown. |
|
539 |
*/ |
|
540 |
PublicKey getPublicKeyAlias(String name) throws KeyStoreException { |
|
541 |
if (keyStore == null) { |
|
542 |
return null; |
|
543 |
} |
|
544 |
||
545 |
Certificate cert = keyStore.getCertificate(name); |
|
546 |
if (cert == null) { |
|
547 |
return null; |
|
548 |
} |
|
549 |
PublicKey pubKey = cert.getPublicKey(); |
|
550 |
return pubKey; |
|
551 |
} |
|
552 |
||
553 |
/** |
|
554 |
* Retrieve all the alias names stored in the certificate database |
|
555 |
*/ |
|
556 |
String[] getPublicKeyAlias() throws KeyStoreException { |
|
557 |
||
558 |
int numAliases = 0; |
|
559 |
String aliases[] = null; |
|
560 |
||
561 |
if (keyStore == null) { |
|
562 |
return null; |
|
563 |
} |
|
564 |
Enumeration<String> enum_ = keyStore.aliases(); |
|
565 |
||
566 |
// first count the number of elements |
|
567 |
while (enum_.hasMoreElements()) { |
|
568 |
enum_.nextElement(); |
|
569 |
numAliases++; |
|
570 |
} |
|
571 |
||
572 |
if (numAliases > 0) { |
|
573 |
// now copy them into an array |
|
574 |
aliases = new String[numAliases]; |
|
575 |
numAliases = 0; |
|
576 |
enum_ = keyStore.aliases(); |
|
577 |
while (enum_.hasMoreElements()) { |
|
578 |
aliases[numAliases] = new String(enum_.nextElement()); |
|
579 |
numAliases++; |
|
580 |
} |
|
581 |
} |
|
582 |
return aliases; |
|
583 |
} |
|
584 |
||
585 |
/** |
|
586 |
* This method parses a single string of signers separated by commas |
|
587 |
* ("jordan, duke, pippen") into an array of individual strings. |
|
588 |
*/ |
|
589 |
String[] parseSigners(String signedBy) { |
|
590 |
||
591 |
String signers[] = null; |
|
592 |
int numSigners = 1; |
|
593 |
int signedByIndex = 0; |
|
594 |
int commaIndex = 0; |
|
595 |
int signerNum = 0; |
|
596 |
||
597 |
// first pass thru "signedBy" counts the number of signers |
|
598 |
while (commaIndex >= 0) { |
|
599 |
commaIndex = signedBy.indexOf(',', signedByIndex); |
|
600 |
if (commaIndex >= 0) { |
|
601 |
numSigners++; |
|
602 |
signedByIndex = commaIndex + 1; |
|
603 |
} |
|
604 |
} |
|
605 |
signers = new String[numSigners]; |
|
606 |
||
607 |
// second pass thru "signedBy" transfers signers to array |
|
608 |
commaIndex = 0; |
|
609 |
signedByIndex = 0; |
|
610 |
while (commaIndex >= 0) { |
|
611 |
if ((commaIndex = signedBy.indexOf(',', signedByIndex)) >= 0) { |
|
612 |
// transfer signer and ignore trailing part of the string |
|
613 |
signers[signerNum] = |
|
614 |
signedBy.substring(signedByIndex, commaIndex).trim(); |
|
615 |
signerNum++; |
|
616 |
signedByIndex = commaIndex + 1; |
|
617 |
} else { |
|
618 |
// we are at the end of the string -- transfer signer |
|
619 |
signers[signerNum] = signedBy.substring(signedByIndex).trim(); |
|
620 |
} |
|
621 |
} |
|
622 |
return signers; |
|
623 |
} |
|
624 |
||
625 |
/** |
|
626 |
* Check to see if the Principal contents are OK |
|
627 |
*/ |
|
628 |
void verifyPrincipal(String type, String name) |
|
629 |
throws ClassNotFoundException, |
|
630 |
InstantiationException |
|
631 |
{ |
|
632 |
if (type.equals(PolicyParser.PrincipalEntry.WILDCARD_CLASS) || |
|
15013
4a17ca431caf
7019834: Eliminate dependency from PolicyFile to com.sun.security.auth.PrincipalComparator
mullan
parents:
14182
diff
changeset
|
633 |
type.equals(PolicyParser.PrincipalEntry.REPLACE_NAME)) { |
2 | 634 |
return; |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
635 |
} |
2 | 636 |
Class<?> pc = Class.forName(type, true, |
637 |
Thread.currentThread().getContextClassLoader()); |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
638 |
if (!Principal.class.isAssignableFrom(pc)) { |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
639 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
640 |
("Illegal.Principal.Type.type")); |
2 | 641 |
Object[] source = {type}; |
642 |
throw new InstantiationException(form.format(source)); |
|
643 |
} |
|
644 |
||
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
645 |
if (X500Principal.class.getName().equals(pc.getName())) { |
2 | 646 |
// PolicyParser checks validity of X500Principal name |
647 |
// - PolicyTool needs to as well so that it doesn't store |
|
648 |
// an invalid name that can't be read in later |
|
649 |
// |
|
650 |
// this can throw an IllegalArgumentException |
|
651 |
X500Principal newP = new X500Principal(name); |
|
652 |
} |
|
653 |
} |
|
654 |
||
655 |
/** |
|
656 |
* Check to see if the Permission contents are OK |
|
657 |
*/ |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
658 |
@SuppressWarnings("fallthrough") |
2 | 659 |
void verifyPermission(String type, |
660 |
String name, |
|
661 |
String actions) |
|
662 |
throws ClassNotFoundException, |
|
663 |
InstantiationException, |
|
664 |
IllegalAccessException, |
|
665 |
NoSuchMethodException, |
|
666 |
InvocationTargetException |
|
667 |
{ |
|
668 |
||
669 |
//XXX we might want to keep a hash of created factories... |
|
670 |
Class<?> pc = Class.forName(type, true, |
|
671 |
Thread.currentThread().getContextClassLoader()); |
|
672 |
Constructor<?> c = null; |
|
7977
f47f211cd627
7008713: diamond conversion of kerberos5 and security tools
smarks
parents:
7532
diff
changeset
|
673 |
Vector<String> objects = new Vector<>(2); |
2 | 674 |
if (name != null) objects.add(name); |
675 |
if (actions != null) objects.add(actions); |
|
676 |
switch (objects.size()) { |
|
677 |
case 0: |
|
678 |
try { |
|
679 |
c = pc.getConstructor(NOPARAMS); |
|
680 |
break; |
|
681 |
} catch (NoSuchMethodException ex) { |
|
682 |
// proceed to the one-param constructor |
|
683 |
objects.add(null); |
|
684 |
} |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
685 |
/* fall through */ |
2 | 686 |
case 1: |
687 |
try { |
|
688 |
c = pc.getConstructor(ONEPARAMS); |
|
689 |
break; |
|
690 |
} catch (NoSuchMethodException ex) { |
|
691 |
// proceed to the two-param constructor |
|
692 |
objects.add(null); |
|
693 |
} |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
694 |
/* fall through */ |
2 | 695 |
case 2: |
696 |
c = pc.getConstructor(TWOPARAMS); |
|
697 |
break; |
|
698 |
} |
|
699 |
Object parameters[] = objects.toArray(); |
|
700 |
Permission p = (Permission)c.newInstance(parameters); |
|
701 |
} |
|
702 |
||
703 |
/* |
|
704 |
* Parse command line arguments. |
|
705 |
*/ |
|
706 |
static void parseArgs(String args[]) { |
|
707 |
/* parse flags */ |
|
708 |
int n = 0; |
|
709 |
||
710 |
for (n=0; (n < args.length) && args[n].startsWith("-"); n++) { |
|
711 |
||
712 |
String flags = args[n]; |
|
713 |
||
714 |
if (collator.compare(flags, "-file") == 0) { |
|
715 |
if (++n == args.length) usage(); |
|
716 |
policyFileName = args[n]; |
|
717 |
} else { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
718 |
MessageFormat form = new MessageFormat(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
719 |
("Illegal.option.option")); |
2 | 720 |
Object[] source = { flags }; |
721 |
System.err.println(form.format(source)); |
|
722 |
usage(); |
|
723 |
} |
|
724 |
} |
|
725 |
} |
|
726 |
||
727 |
static void usage() { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
728 |
System.out.println(getMessage("Usage.policytool.options.")); |
2 | 729 |
System.out.println(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
730 |
System.out.println(getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
731 |
(".file.file.policy.file.location")); |
2 | 732 |
System.out.println(); |
733 |
||
734 |
System.exit(1); |
|
735 |
} |
|
736 |
||
737 |
/** |
|
738 |
* run the PolicyTool |
|
739 |
*/ |
|
740 |
public static void main(String args[]) { |
|
741 |
parseArgs(args); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
742 |
SwingUtilities.invokeLater(new Runnable() { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
743 |
public void run() { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
744 |
ToolWindow tw = new ToolWindow(new PolicyTool()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
745 |
tw.displayToolWindow(args); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
746 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
747 |
}); |
2 | 748 |
} |
749 |
||
750 |
// split instr to words according to capitalization, |
|
751 |
// like, AWTControl -> A W T Control |
|
752 |
// this method is for easy pronounciation |
|
753 |
static String splitToWords(String instr) { |
|
754 |
return instr.replaceAll("([A-Z])", " $1"); |
|
755 |
} |
|
756 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
757 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
758 |
* Returns the message corresponding to the key in the bundle. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
759 |
* This is preferred over {@link #getString} because it removes |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
760 |
* any mnemonic '&' character in the string. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
761 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
762 |
* @param key the key |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
763 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
764 |
* @return the message |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
765 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
766 |
static String getMessage(String key) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
767 |
return removeMnemonicAmpersand(rb.getString(key)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
768 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
769 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
770 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
771 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
772 |
* Returns the mnemonic for a message. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
773 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
774 |
* @param key the key |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
775 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
776 |
* @return the mnemonic <code>int</code> |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
777 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
778 |
static int getMnemonicInt(String key) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
779 |
String message = rb.getString(key); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
780 |
return (findMnemonicInt(message)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
781 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
782 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
783 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
784 |
* Returns the mnemonic display index for a message. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
785 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
786 |
* @param key the key |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
787 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
788 |
* @return the mnemonic display index |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
789 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
790 |
static int getDisplayedMnemonicIndex(String key) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
791 |
String message = rb.getString(key); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
792 |
return (findMnemonicIndex(message)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
793 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
794 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
795 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
796 |
* Finds the mnemonic character in a message. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
797 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
798 |
* The mnemonic character is the first character followed by the first |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
799 |
* <code>&</code> that is not followed by another <code>&</code>. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
800 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
801 |
* @return the mnemonic as an <code>int</code>, or <code>0</code> if it |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
802 |
* can't be found. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
803 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
804 |
private static int findMnemonicInt(String s) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
805 |
for (int i = 0; i < s.length() - 1; i++) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
806 |
if (s.charAt(i) == '&') { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
807 |
if (s.charAt(i + 1) != '&') { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
808 |
return KeyEvent.getExtendedKeyCodeForChar(s.charAt(i + 1)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
809 |
} else { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
810 |
i++; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
811 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
812 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
813 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
814 |
return 0; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
815 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
816 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
817 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
818 |
* Finds the index of the mnemonic character in a message. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
819 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
820 |
* The mnemonic character is the first character followed by the first |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
821 |
* <code>&</code> that is not followed by another <code>&</code>. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
822 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
823 |
* @return the mnemonic character index as an <code>int</code>, or <code>-1</code> if it |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
824 |
* can't be found. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
825 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
826 |
private static int findMnemonicIndex(String s) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
827 |
for (int i = 0; i < s.length() - 1; i++) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
828 |
if (s.charAt(i) == '&') { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
829 |
if (s.charAt(i + 1) != '&') { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
830 |
// Return the index of the '&' since it will be removed |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
831 |
return i; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
832 |
} else { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
833 |
i++; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
834 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
835 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
836 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
837 |
return -1; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
838 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
839 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
840 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
841 |
* Removes the mnemonic identifier (<code>&</code>) from a string unless |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
842 |
* it's escaped by <code>&&</code> or placed at the end. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
843 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
844 |
* @param message the message |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
845 |
* |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
846 |
* @return a message with the mnemonic identifier removed |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
847 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
848 |
private static String removeMnemonicAmpersand(String message) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
849 |
StringBuilder s = new StringBuilder(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
850 |
for (int i = 0; i < message.length(); i++) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
851 |
char current = message.charAt(i); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
852 |
if (current != '&' || i == message.length() - 1 |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
853 |
|| message.charAt(i + 1) == '&') { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
854 |
s.append(current); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
855 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
856 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
857 |
return s.toString(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
858 |
} |
2 | 859 |
} |
860 |
||
861 |
/** |
|
862 |
* Each entry in the policy configuration file is represented by a |
|
863 |
* PolicyEntry object. |
|
864 |
* |
|
865 |
* A PolicyEntry is a (CodeSource,Permission) pair. The |
|
866 |
* CodeSource contains the (URL, PublicKey) that together identify |
|
867 |
* where the Java bytecodes come from and who (if anyone) signed |
|
868 |
* them. The URL could refer to localhost. The URL could also be |
|
869 |
* null, meaning that this policy entry is given to all comers, as |
|
870 |
* long as they match the signer field. The signer could be null, |
|
871 |
* meaning the code is not signed. |
|
872 |
* |
|
873 |
* The Permission contains the (Type, Name, Action) triplet. |
|
874 |
* |
|
875 |
*/ |
|
876 |
class PolicyEntry { |
|
877 |
||
878 |
private CodeSource codesource; |
|
879 |
private PolicyTool tool; |
|
880 |
private PolicyParser.GrantEntry grantEntry; |
|
881 |
private boolean testing = false; |
|
882 |
||
883 |
/** |
|
884 |
* Create a PolicyEntry object from the information read in |
|
885 |
* from a policy file. |
|
886 |
*/ |
|
887 |
PolicyEntry(PolicyTool tool, PolicyParser.GrantEntry ge) |
|
888 |
throws MalformedURLException, NoSuchMethodException, |
|
889 |
ClassNotFoundException, InstantiationException, IllegalAccessException, |
|
890 |
InvocationTargetException, CertificateException, |
|
891 |
IOException, NoSuchAlgorithmException, UnrecoverableKeyException { |
|
892 |
||
893 |
this.tool = tool; |
|
894 |
||
895 |
URL location = null; |
|
896 |
||
897 |
// construct the CodeSource |
|
898 |
if (ge.codeBase != null) |
|
899 |
location = new URL(ge.codeBase); |
|
900 |
this.codesource = new CodeSource(location, |
|
901 |
(java.security.cert.Certificate[]) null); |
|
902 |
||
903 |
if (testing) { |
|
904 |
System.out.println("Adding Policy Entry:"); |
|
905 |
System.out.println(" CodeBase = " + location); |
|
906 |
System.out.println(" Signers = " + ge.signedBy); |
|
907 |
System.out.println(" with " + ge.principals.size() + |
|
908 |
" Principals"); |
|
909 |
} |
|
910 |
||
911 |
this.grantEntry = ge; |
|
912 |
} |
|
913 |
||
914 |
/** |
|
915 |
* get the codesource associated with this PolicyEntry |
|
916 |
*/ |
|
917 |
CodeSource getCodeSource() { |
|
918 |
return codesource; |
|
919 |
} |
|
920 |
||
921 |
/** |
|
922 |
* get the GrantEntry associated with this PolicyEntry |
|
923 |
*/ |
|
924 |
PolicyParser.GrantEntry getGrantEntry() { |
|
925 |
return grantEntry; |
|
926 |
} |
|
927 |
||
928 |
/** |
|
929 |
* convert the header portion, i.e. codebase, signer, principals, of |
|
930 |
* this policy entry into a string |
|
931 |
*/ |
|
932 |
String headerToString() { |
|
933 |
String pString = principalsToString(); |
|
934 |
if (pString.length() == 0) { |
|
935 |
return codebaseToString(); |
|
936 |
} else { |
|
937 |
return codebaseToString() + ", " + pString; |
|
938 |
} |
|
939 |
} |
|
940 |
||
941 |
/** |
|
942 |
* convert the Codebase/signer portion of this policy entry into a string |
|
943 |
*/ |
|
944 |
String codebaseToString() { |
|
945 |
||
946 |
String stringEntry = new String(); |
|
947 |
||
948 |
if (grantEntry.codeBase != null && |
|
949 |
grantEntry.codeBase.equals("") == false) |
|
950 |
stringEntry = stringEntry.concat |
|
951 |
("CodeBase \"" + |
|
952 |
grantEntry.codeBase + |
|
953 |
"\""); |
|
954 |
||
955 |
if (grantEntry.signedBy != null && |
|
956 |
grantEntry.signedBy.equals("") == false) |
|
957 |
stringEntry = ((stringEntry.length() > 0) ? |
|
958 |
stringEntry.concat(", SignedBy \"" + |
|
959 |
grantEntry.signedBy + |
|
960 |
"\"") : |
|
961 |
stringEntry.concat("SignedBy \"" + |
|
962 |
grantEntry.signedBy + |
|
963 |
"\"")); |
|
964 |
||
965 |
if (stringEntry.length() == 0) |
|
966 |
return new String("CodeBase <ALL>"); |
|
967 |
return stringEntry; |
|
968 |
} |
|
969 |
||
970 |
/** |
|
971 |
* convert the Principals portion of this policy entry into a string |
|
972 |
*/ |
|
973 |
String principalsToString() { |
|
974 |
String result = ""; |
|
975 |
if ((grantEntry.principals != null) && |
|
976 |
(!grantEntry.principals.isEmpty())) { |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
23333
diff
changeset
|
977 |
StringBuilder sb = new StringBuilder(200); |
2 | 978 |
ListIterator<PolicyParser.PrincipalEntry> list = |
979 |
grantEntry.principals.listIterator(); |
|
980 |
while (list.hasNext()) { |
|
981 |
PolicyParser.PrincipalEntry pppe = list.next(); |
|
27957
24b4e6082f19
8055723: Replace concat String to append in StringBuilder parameters (dev)
weijun
parents:
27499
diff
changeset
|
982 |
sb.append(" Principal ").append(pppe.getDisplayClass()) |
24b4e6082f19
8055723: Replace concat String to append in StringBuilder parameters (dev)
weijun
parents:
27499
diff
changeset
|
983 |
.append(' ') |
24b4e6082f19
8055723: Replace concat String to append in StringBuilder parameters (dev)
weijun
parents:
27499
diff
changeset
|
984 |
.append(pppe.getDisplayName(true)); |
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
23333
diff
changeset
|
985 |
if (list.hasNext()) sb.append(", "); |
2 | 986 |
} |
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
23333
diff
changeset
|
987 |
result = sb.toString(); |
2 | 988 |
} |
989 |
return result; |
|
990 |
} |
|
991 |
||
992 |
/** |
|
993 |
* convert this policy entry into a PolicyParser.PermissionEntry |
|
994 |
*/ |
|
995 |
PolicyParser.PermissionEntry toPermissionEntry(Permission perm) { |
|
996 |
||
997 |
String actions = null; |
|
998 |
||
999 |
// get the actions |
|
1000 |
if (perm.getActions() != null && |
|
1001 |
perm.getActions().trim() != "") |
|
1002 |
actions = perm.getActions(); |
|
1003 |
||
1004 |
PolicyParser.PermissionEntry pe = new PolicyParser.PermissionEntry |
|
1005 |
(perm.getClass().getName(), |
|
1006 |
perm.getName(), |
|
1007 |
actions); |
|
1008 |
return pe; |
|
1009 |
} |
|
1010 |
} |
|
1011 |
||
1012 |
/** |
|
1013 |
* The main window for the PolicyTool |
|
1014 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1015 |
class ToolWindow extends JFrame { |
2 | 1016 |
// use serialVersionUID from JDK 1.2.2 for interoperability |
1017 |
private static final long serialVersionUID = 5682568601210376777L; |
|
1018 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1019 |
/* ESCAPE key */ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1020 |
static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1021 |
|
2 | 1022 |
/* external paddings */ |
1023 |
public static final Insets TOP_PADDING = new Insets(25,0,0,0); |
|
1024 |
public static final Insets BOTTOM_PADDING = new Insets(0,0,25,0); |
|
1025 |
public static final Insets LITE_BOTTOM_PADDING = new Insets(0,0,10,0); |
|
1026 |
public static final Insets LR_PADDING = new Insets(0,10,0,10); |
|
1027 |
public static final Insets TOP_BOTTOM_PADDING = new Insets(15, 0, 15, 0); |
|
1028 |
public static final Insets L_TOP_BOTTOM_PADDING = new Insets(5,10,15,0); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1029 |
public static final Insets LR_TOP_BOTTOM_PADDING = new Insets(15, 4, 15, 4); |
2 | 1030 |
public static final Insets LR_BOTTOM_PADDING = new Insets(0,10,5,10); |
1031 |
public static final Insets L_BOTTOM_PADDING = new Insets(0,10,5,0); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1032 |
public static final Insets R_BOTTOM_PADDING = new Insets(0, 0, 25, 5); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1033 |
public static final Insets R_PADDING = new Insets(0, 0, 0, 5); |
2 | 1034 |
|
1035 |
/* buttons and menus */ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1036 |
public static final String NEW_POLICY_FILE = "New"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1037 |
public static final String OPEN_POLICY_FILE = "Open"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1038 |
public static final String SAVE_POLICY_FILE = "Save"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1039 |
public static final String SAVE_AS_POLICY_FILE = "Save.As"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1040 |
public static final String VIEW_WARNINGS = "View.Warning.Log"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1041 |
public static final String QUIT = "Exit"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1042 |
public static final String ADD_POLICY_ENTRY = "Add.Policy.Entry"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1043 |
public static final String EDIT_POLICY_ENTRY = "Edit.Policy.Entry"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1044 |
public static final String REMOVE_POLICY_ENTRY = "Remove.Policy.Entry"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1045 |
public static final String EDIT_KEYSTORE = "Edit"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1046 |
public static final String ADD_PUBKEY_ALIAS = "Add.Public.Key.Alias"; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1047 |
public static final String REMOVE_PUBKEY_ALIAS = "Remove.Public.Key.Alias"; |
2 | 1048 |
|
1049 |
/* gridbag index for components in the main window (MW) */ |
|
1050 |
public static final int MW_FILENAME_LABEL = 0; |
|
1051 |
public static final int MW_FILENAME_TEXTFIELD = 1; |
|
1052 |
public static final int MW_PANEL = 2; |
|
1053 |
public static final int MW_ADD_BUTTON = 0; |
|
1054 |
public static final int MW_EDIT_BUTTON = 1; |
|
1055 |
public static final int MW_REMOVE_BUTTON = 2; |
|
1056 |
public static final int MW_POLICY_LIST = 3; // follows MW_PANEL |
|
1057 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1058 |
/* The preferred height of JTextField should match JComboBox. */ |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1059 |
static final int TEXTFIELD_HEIGHT = new JComboBox<>().getPreferredSize().height; |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1060 |
|
2 | 1061 |
private PolicyTool tool; |
1062 |
||
1063 |
/** |
|
1064 |
* Constructor |
|
1065 |
*/ |
|
1066 |
ToolWindow(PolicyTool tool) { |
|
1067 |
this.tool = tool; |
|
1068 |
} |
|
1069 |
||
1070 |
/** |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1071 |
* Don't call getComponent directly on the window |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1072 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1073 |
public Component getComponent(int n) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1074 |
Component c = getContentPane().getComponent(n); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1075 |
if (c instanceof JScrollPane) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1076 |
c = ((JScrollPane)c).getViewport().getView(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1077 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1078 |
return c; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1079 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1080 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1081 |
/** |
2 | 1082 |
* Initialize the PolicyTool window with the necessary components |
1083 |
*/ |
|
1084 |
private void initWindow() { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1085 |
// The ToolWindowListener will handle closing the window. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1086 |
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
2 | 1087 |
|
1088 |
// create the top menu bar |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1089 |
JMenuBar menuBar = new JMenuBar(); |
2 | 1090 |
|
1091 |
// create a File menu |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1092 |
JMenu menu = new JMenu(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1093 |
configureButton(menu, "File"); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1094 |
ActionListener actionListener = new FileMenuListener(tool, this); |
21365
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1095 |
addMenuItem(menu, NEW_POLICY_FILE, actionListener, "N"); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1096 |
addMenuItem(menu, OPEN_POLICY_FILE, actionListener, "O"); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1097 |
addMenuItem(menu, SAVE_POLICY_FILE, actionListener, "S"); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1098 |
addMenuItem(menu, SAVE_AS_POLICY_FILE, actionListener, null); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1099 |
addMenuItem(menu, VIEW_WARNINGS, actionListener, null); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1100 |
addMenuItem(menu, QUIT, actionListener, null); |
2 | 1101 |
menuBar.add(menu); |
1102 |
||
1103 |
// create a KeyStore menu |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1104 |
menu = new JMenu(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1105 |
configureButton(menu, "KeyStore"); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1106 |
actionListener = new MainWindowListener(tool, this); |
21365
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1107 |
addMenuItem(menu, EDIT_KEYSTORE, actionListener, null); |
2 | 1108 |
menuBar.add(menu); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1109 |
setJMenuBar(menuBar); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1110 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1111 |
// Create some space around components |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1112 |
((JPanel)getContentPane()).setBorder(new EmptyBorder(6, 6, 6, 6)); |
2 | 1113 |
|
1114 |
// policy entry listing |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1115 |
JLabel label = new JLabel(PolicyTool.getMessage("Policy.File.")); |
2 | 1116 |
addNewComponent(this, label, MW_FILENAME_LABEL, |
1117 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1118 |
LR_TOP_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1119 |
JTextField tf = new JTextField(50); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1120 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 1121 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1122 |
PolicyTool.getMessage("Policy.File.")); |
2 | 1123 |
tf.setEditable(false); |
1124 |
addNewComponent(this, tf, MW_FILENAME_TEXTFIELD, |
|
1125 |
1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1126 |
LR_TOP_BOTTOM_PADDING); |
2 | 1127 |
|
1128 |
||
1129 |
// add ADD/REMOVE/EDIT buttons in a new panel |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1130 |
JPanel panel = new JPanel(); |
2 | 1131 |
panel.setLayout(new GridBagLayout()); |
1132 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1133 |
JButton button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1134 |
configureButton(button, ADD_POLICY_ENTRY); |
2 | 1135 |
button.addActionListener(new MainWindowListener(tool, this)); |
1136 |
addNewComponent(panel, button, MW_ADD_BUTTON, |
|
1137 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1138 |
LR_PADDING); |
|
1139 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1140 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1141 |
configureButton(button, EDIT_POLICY_ENTRY); |
2 | 1142 |
button.addActionListener(new MainWindowListener(tool, this)); |
1143 |
addNewComponent(panel, button, MW_EDIT_BUTTON, |
|
1144 |
1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1145 |
LR_PADDING); |
|
1146 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1147 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1148 |
configureButton(button, REMOVE_POLICY_ENTRY); |
2 | 1149 |
button.addActionListener(new MainWindowListener(tool, this)); |
1150 |
addNewComponent(panel, button, MW_REMOVE_BUTTON, |
|
1151 |
2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1152 |
LR_PADDING); |
|
1153 |
||
1154 |
addNewComponent(this, panel, MW_PANEL, |
|
1155 |
0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1156 |
BOTTOM_PADDING); |
|
1157 |
||
1158 |
||
1159 |
String policyFile = tool.getPolicyFileName(); |
|
1160 |
if (policyFile == null) { |
|
1161 |
String userHome; |
|
1162 |
userHome = java.security.AccessController.doPrivileged( |
|
23333
b0af2c7c8c91
8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents:
22059
diff
changeset
|
1163 |
(PrivilegedAction<String>) () -> System.getProperty("user.home")); |
2 | 1164 |
policyFile = userHome + File.separatorChar + ".java.policy"; |
1165 |
} |
|
1166 |
||
1167 |
try { |
|
1168 |
// open the policy file |
|
1169 |
tool.openPolicy(policyFile); |
|
1170 |
||
1171 |
// display the policy entries via the policy list textarea |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1172 |
DefaultListModel<String> listModel = new DefaultListModel<>(); |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1173 |
JList<String> list = new JList<>(listModel); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1174 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1175 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1176 |
list.addMouseListener(new PolicyListListener(tool, this)); |
2 | 1177 |
PolicyEntry entries[] = tool.getEntry(); |
1178 |
if (entries != null) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1179 |
for (int i = 0; i < entries.length; i++) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1180 |
listModel.addElement(entries[i].headerToString()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1181 |
} |
2 | 1182 |
} |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1183 |
JTextField newFilename = (JTextField) |
2 | 1184 |
getComponent(MW_FILENAME_TEXTFIELD); |
1185 |
newFilename.setText(policyFile); |
|
1186 |
initPolicyList(list); |
|
1187 |
||
1188 |
} catch (FileNotFoundException fnfe) { |
|
1189 |
// add blank policy listing |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1190 |
JList<String> list = new JList<>(new DefaultListModel<>()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1191 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1192 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1193 |
list.addMouseListener(new PolicyListListener(tool, this)); |
2 | 1194 |
initPolicyList(list); |
1195 |
tool.setPolicyFileName(null); |
|
1196 |
tool.modified = false; |
|
1197 |
||
1198 |
// just add warning |
|
1199 |
tool.warnings.addElement(fnfe.toString()); |
|
1200 |
||
1201 |
} catch (Exception e) { |
|
1202 |
// add blank policy listing |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1203 |
JList<String> list = new JList<>(new DefaultListModel<>()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1204 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1205 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1206 |
list.addMouseListener(new PolicyListListener(tool, this)); |
2 | 1207 |
initPolicyList(list); |
1208 |
tool.setPolicyFileName(null); |
|
1209 |
tool.modified = false; |
|
1210 |
||
1211 |
// display the error |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1212 |
MessageFormat form = new MessageFormat(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
1213 |
("Could.not.open.policy.file.policyFile.e.toString.")); |
2 | 1214 |
Object[] source = {policyFile, e.toString()}; |
1215 |
displayErrorDialog(null, form.format(source)); |
|
1216 |
} |
|
1217 |
} |
|
1218 |
||
1219 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1220 |
// Platform specific modifier (control / command). |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1221 |
private int shortCutModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1222 |
|
21365
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1223 |
private void addMenuItem(JMenu menu, String key, ActionListener actionListener, String accelerator) { |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1224 |
JMenuItem menuItem = new JMenuItem(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1225 |
configureButton(menuItem, key); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1226 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1227 |
if (PolicyTool.rb.containsKey(key + ".accelerator")) { |
21365
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1228 |
// Accelerator from resources takes precedence |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1229 |
accelerator = PolicyTool.getMessage(key + ".accelerator"); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1230 |
} |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1231 |
|
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1232 |
if (accelerator != null && !accelerator.isEmpty()) { |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1233 |
KeyStroke keyStroke; |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1234 |
if (accelerator.length() == 1) { |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1235 |
keyStroke = KeyStroke.getKeyStroke(KeyEvent.getExtendedKeyCodeForChar(accelerator.charAt(0)), |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1236 |
shortCutModifier); |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1237 |
} else { |
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1238 |
keyStroke = KeyStroke.getKeyStroke(accelerator); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1239 |
} |
21365
2a7be11ae905
8026929: remove accelerators from policytool resources
weijun
parents:
20886
diff
changeset
|
1240 |
menuItem.setAccelerator(keyStroke); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1241 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1242 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1243 |
menuItem.addActionListener(actionListener); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1244 |
menu.add(menuItem); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1245 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1246 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1247 |
static void configureButton(AbstractButton button, String key) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1248 |
button.setText(PolicyTool.getMessage(key)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1249 |
button.setActionCommand(key); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1250 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1251 |
int mnemonicInt = PolicyTool.getMnemonicInt(key); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1252 |
if (mnemonicInt > 0) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1253 |
button.setMnemonic(mnemonicInt); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1254 |
button.setDisplayedMnemonicIndex(PolicyTool.getDisplayedMnemonicIndex(key)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1255 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1256 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1257 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1258 |
static void configureLabelFor(JLabel label, JComponent component, String key) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1259 |
label.setText(PolicyTool.getMessage(key)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1260 |
label.setLabelFor(component); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1261 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1262 |
int mnemonicInt = PolicyTool.getMnemonicInt(key); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1263 |
if (mnemonicInt > 0) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1264 |
label.setDisplayedMnemonic(mnemonicInt); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1265 |
label.setDisplayedMnemonicIndex(PolicyTool.getDisplayedMnemonicIndex(key)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1266 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1267 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1268 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1269 |
|
2 | 1270 |
/** |
1271 |
* Add a component to the PolicyTool window |
|
1272 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1273 |
void addNewComponent(Container container, JComponent component, |
2 | 1274 |
int index, int gridx, int gridy, int gridwidth, int gridheight, |
1275 |
double weightx, double weighty, int fill, Insets is) { |
|
1276 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1277 |
if (container instanceof JFrame) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1278 |
container = ((JFrame)container).getContentPane(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1279 |
} else if (container instanceof JDialog) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1280 |
container = ((JDialog)container).getContentPane(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1281 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1282 |
|
2 | 1283 |
// add the component at the specified gridbag index |
1284 |
container.add(component, index); |
|
1285 |
||
1286 |
// set the constraints |
|
1287 |
GridBagLayout gbl = (GridBagLayout)container.getLayout(); |
|
1288 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
1289 |
gbc.gridx = gridx; |
|
1290 |
gbc.gridy = gridy; |
|
1291 |
gbc.gridwidth = gridwidth; |
|
1292 |
gbc.gridheight = gridheight; |
|
1293 |
gbc.weightx = weightx; |
|
1294 |
gbc.weighty = weighty; |
|
1295 |
gbc.fill = fill; |
|
1296 |
if (is != null) gbc.insets = is; |
|
1297 |
gbl.setConstraints(component, gbc); |
|
1298 |
} |
|
1299 |
||
1300 |
||
1301 |
/** |
|
1302 |
* Add a component to the PolicyTool window without external padding |
|
1303 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1304 |
void addNewComponent(Container container, JComponent component, |
2 | 1305 |
int index, int gridx, int gridy, int gridwidth, int gridheight, |
1306 |
double weightx, double weighty, int fill) { |
|
1307 |
||
1308 |
// delegate with "null" external padding |
|
1309 |
addNewComponent(container, component, index, gridx, gridy, |
|
1310 |
gridwidth, gridheight, weightx, weighty, |
|
1311 |
fill, null); |
|
1312 |
} |
|
1313 |
||
1314 |
||
1315 |
/** |
|
1316 |
* Init the policy_entry_list TEXTAREA component in the |
|
1317 |
* PolicyTool window |
|
1318 |
*/ |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1319 |
void initPolicyList(JList<String> policyList) { |
2 | 1320 |
|
1321 |
// add the policy list to the window |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1322 |
//policyList.setPreferredSize(new Dimension(500, 350)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1323 |
JScrollPane scrollPane = new JScrollPane(policyList); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1324 |
addNewComponent(this, scrollPane, MW_POLICY_LIST, |
2 | 1325 |
0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.BOTH); |
1326 |
} |
|
1327 |
||
1328 |
/** |
|
1329 |
* Replace the policy_entry_list TEXTAREA component in the |
|
1330 |
* PolicyTool window with an updated one. |
|
1331 |
*/ |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1332 |
void replacePolicyList(JList<String> policyList) { |
2 | 1333 |
|
1334 |
// remove the original list of Policy Entries |
|
1335 |
// and add the new list of entries |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1336 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1337 |
JList<String> list = (JList<String>)getComponent(MW_POLICY_LIST); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1338 |
list.setModel(policyList.getModel()); |
2 | 1339 |
} |
1340 |
||
1341 |
/** |
|
1342 |
* display the main PolicyTool window |
|
1343 |
*/ |
|
1344 |
void displayToolWindow(String args[]) { |
|
1345 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1346 |
setTitle(PolicyTool.getMessage("Policy.Tool")); |
2 | 1347 |
setResizable(true); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1348 |
addWindowListener(new ToolWindowListener(tool, this)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1349 |
//setBounds(135, 80, 500, 500); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1350 |
getContentPane().setLayout(new GridBagLayout()); |
2 | 1351 |
|
1352 |
initWindow(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1353 |
pack(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1354 |
setLocationRelativeTo(null); |
2 | 1355 |
|
1356 |
// display it |
|
1357 |
setVisible(true); |
|
1358 |
||
1359 |
if (tool.newWarning == true) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1360 |
displayStatusDialog(this, PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
1361 |
("Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.")); |
2 | 1362 |
} |
1363 |
} |
|
1364 |
||
1365 |
/** |
|
1366 |
* displays a dialog box describing an error which occurred. |
|
1367 |
*/ |
|
1368 |
void displayErrorDialog(Window w, String error) { |
|
1369 |
ToolDialog ed = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1370 |
(PolicyTool.getMessage("Error"), tool, this, true); |
2 | 1371 |
|
1372 |
// find where the PolicyTool gui is |
|
1373 |
Point location = ((w == null) ? |
|
1374 |
getLocationOnScreen() : w.getLocationOnScreen()); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1375 |
//ed.setBounds(location.x + 50, location.y + 50, 600, 100); |
2 | 1376 |
ed.setLayout(new GridBagLayout()); |
1377 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1378 |
JLabel label = new JLabel(error); |
2 | 1379 |
addNewComponent(ed, label, 0, |
1380 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
|
1381 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1382 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1383 |
ActionListener okListener = new ErrorOKButtonListener(ed); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1384 |
okButton.addActionListener(okListener); |
2 | 1385 |
addNewComponent(ed, okButton, 1, |
1386 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
1387 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1388 |
ed.getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1389 |
ed.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1390 |
|
2 | 1391 |
ed.pack(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1392 |
ed.setLocationRelativeTo(w); |
2 | 1393 |
ed.setVisible(true); |
1394 |
} |
|
1395 |
||
1396 |
/** |
|
1397 |
* displays a dialog box describing an error which occurred. |
|
1398 |
*/ |
|
1399 |
void displayErrorDialog(Window w, Throwable t) { |
|
1400 |
if (t instanceof NoDisplayException) { |
|
1401 |
return; |
|
1402 |
} |
|
27499
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1403 |
if (t.getClass() == Exception.class) { |
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1404 |
// Exception is usually thrown inside policytool for user |
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1405 |
// interaction error. There is no need to show the type. |
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1406 |
displayErrorDialog(w, t.getLocalizedMessage()); |
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1407 |
} else { |
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1408 |
displayErrorDialog(w, t.toString()); |
10c5f7509a99
8063087: policytool reports error message with prefix of "java.lang.Exception"
weijun
parents:
26204
diff
changeset
|
1409 |
} |
2 | 1410 |
} |
1411 |
||
1412 |
/** |
|
1413 |
* displays a dialog box describing the status of an event |
|
1414 |
*/ |
|
1415 |
void displayStatusDialog(Window w, String status) { |
|
1416 |
ToolDialog sd = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1417 |
(PolicyTool.getMessage("Status"), tool, this, true); |
2 | 1418 |
|
1419 |
// find the location of the PolicyTool gui |
|
1420 |
Point location = ((w == null) ? |
|
1421 |
getLocationOnScreen() : w.getLocationOnScreen()); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1422 |
//sd.setBounds(location.x + 50, location.y + 50, 500, 100); |
2 | 1423 |
sd.setLayout(new GridBagLayout()); |
1424 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1425 |
JLabel label = new JLabel(status); |
2 | 1426 |
addNewComponent(sd, label, 0, |
1427 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
|
1428 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1429 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1430 |
ActionListener okListener = new StatusOKButtonListener(sd); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1431 |
okButton.addActionListener(okListener); |
2 | 1432 |
addNewComponent(sd, okButton, 1, |
1433 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1434 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1435 |
sd.getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1436 |
sd.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1437 |
|
2 | 1438 |
sd.pack(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1439 |
sd.setLocationRelativeTo(w); |
2 | 1440 |
sd.setVisible(true); |
1441 |
} |
|
1442 |
||
1443 |
/** |
|
1444 |
* display the warning log |
|
1445 |
*/ |
|
1446 |
void displayWarningLog(Window w) { |
|
1447 |
||
1448 |
ToolDialog wd = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1449 |
(PolicyTool.getMessage("Warning"), tool, this, true); |
2 | 1450 |
|
1451 |
// find the location of the PolicyTool gui |
|
1452 |
Point location = ((w == null) ? |
|
1453 |
getLocationOnScreen() : w.getLocationOnScreen()); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1454 |
//wd.setBounds(location.x + 50, location.y + 50, 500, 100); |
2 | 1455 |
wd.setLayout(new GridBagLayout()); |
1456 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1457 |
JTextArea ta = new JTextArea(); |
2 | 1458 |
ta.setEditable(false); |
1459 |
for (int i = 0; i < tool.warnings.size(); i++) { |
|
1460 |
ta.append(tool.warnings.elementAt(i)); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1461 |
ta.append(PolicyTool.getMessage("NEWLINE")); |
2 | 1462 |
} |
1463 |
addNewComponent(wd, ta, 0, |
|
1464 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1465 |
BOTTOM_PADDING); |
|
1466 |
ta.setFocusable(false); |
|
1467 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1468 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1469 |
ActionListener okListener = new CancelButtonListener(wd); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1470 |
okButton.addActionListener(okListener); |
2 | 1471 |
addNewComponent(wd, okButton, 1, |
1472 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
1473 |
LR_PADDING); |
|
1474 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1475 |
wd.getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1476 |
wd.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1477 |
|
2 | 1478 |
wd.pack(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1479 |
wd.setLocationRelativeTo(w); |
2 | 1480 |
wd.setVisible(true); |
1481 |
} |
|
1482 |
||
1483 |
char displayYesNoDialog(Window w, String title, String prompt, String yes, String no) { |
|
1484 |
||
1485 |
final ToolDialog tw = new ToolDialog |
|
1486 |
(title, tool, this, true); |
|
1487 |
Point location = ((w == null) ? |
|
1488 |
getLocationOnScreen() : w.getLocationOnScreen()); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1489 |
//tw.setBounds(location.x + 75, location.y + 100, 400, 150); |
2 | 1490 |
tw.setLayout(new GridBagLayout()); |
1491 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1492 |
JTextArea ta = new JTextArea(prompt, 10, 50); |
2 | 1493 |
ta.setEditable(false); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1494 |
ta.setLineWrap(true); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1495 |
ta.setWrapStyleWord(true); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1496 |
JScrollPane scrollPane = new JScrollPane(ta, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1497 |
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1498 |
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1499 |
addNewComponent(tw, scrollPane, 0, |
2 | 1500 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1501 |
ta.setFocusable(false); |
|
1502 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1503 |
JPanel panel = new JPanel(); |
2 | 1504 |
panel.setLayout(new GridBagLayout()); |
1505 |
||
1506 |
// StringBuffer to store button press. Must be final. |
|
1507 |
final StringBuffer chooseResult = new StringBuffer(); |
|
1508 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1509 |
JButton button = new JButton(yes); |
2 | 1510 |
button.addActionListener(new ActionListener() { |
1511 |
public void actionPerformed(ActionEvent e) { |
|
1512 |
chooseResult.append('Y'); |
|
1513 |
tw.setVisible(false); |
|
1514 |
tw.dispose(); |
|
1515 |
} |
|
1516 |
}); |
|
1517 |
addNewComponent(panel, button, 0, |
|
1518 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
1519 |
LR_PADDING); |
|
1520 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1521 |
button = new JButton(no); |
2 | 1522 |
button.addActionListener(new ActionListener() { |
1523 |
public void actionPerformed(ActionEvent e) { |
|
1524 |
chooseResult.append('N'); |
|
1525 |
tw.setVisible(false); |
|
1526 |
tw.dispose(); |
|
1527 |
} |
|
1528 |
}); |
|
1529 |
addNewComponent(panel, button, 1, |
|
1530 |
1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
1531 |
LR_PADDING); |
|
1532 |
||
1533 |
addNewComponent(tw, panel, 1, |
|
1534 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
1535 |
||
1536 |
tw.pack(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1537 |
tw.setLocationRelativeTo(w); |
2 | 1538 |
tw.setVisible(true); |
1539 |
if (chooseResult.length() > 0) { |
|
1540 |
return chooseResult.charAt(0); |
|
1541 |
} else { |
|
1542 |
// I did encounter this once, don't why. |
|
1543 |
return 'N'; |
|
1544 |
} |
|
1545 |
} |
|
1546 |
||
1547 |
} |
|
1548 |
||
1549 |
/** |
|
1550 |
* General dialog window |
|
1551 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1552 |
class ToolDialog extends JDialog { |
2 | 1553 |
// use serialVersionUID from JDK 1.2.2 for interoperability |
1554 |
private static final long serialVersionUID = -372244357011301190L; |
|
1555 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1556 |
/* ESCAPE key */ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1557 |
static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1558 |
|
2 | 1559 |
/* necessary constants */ |
1560 |
public static final int NOACTION = 0; |
|
1561 |
public static final int QUIT = 1; |
|
1562 |
public static final int NEW = 2; |
|
1563 |
public static final int OPEN = 3; |
|
1564 |
||
1565 |
/* popup menus */ |
|
1566 |
public static final String PERM = |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1567 |
PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
1568 |
("Permission."); |
2 | 1569 |
|
1570 |
public static final String PRIN_TYPE = |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1571 |
PolicyTool.getMessage("Principal.Type."); |
2 | 1572 |
public static final String PRIN_NAME = |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1573 |
PolicyTool.getMessage("Principal.Name."); |
2 | 1574 |
|
1575 |
/* more popu menus */ |
|
1576 |
public static final String PERM_NAME = |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1577 |
PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
1578 |
("Target.Name."); |
2 | 1579 |
|
1580 |
/* and more popup menus */ |
|
1581 |
public static final String PERM_ACTIONS = |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1582 |
PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
1583 |
("Actions."); |
2 | 1584 |
|
1585 |
/* gridbag index for display PolicyEntry (PE) components */ |
|
1586 |
public static final int PE_CODEBASE_LABEL = 0; |
|
1587 |
public static final int PE_CODEBASE_TEXTFIELD = 1; |
|
1588 |
public static final int PE_SIGNEDBY_LABEL = 2; |
|
1589 |
public static final int PE_SIGNEDBY_TEXTFIELD = 3; |
|
1590 |
||
1591 |
public static final int PE_PANEL0 = 4; |
|
1592 |
public static final int PE_ADD_PRIN_BUTTON = 0; |
|
1593 |
public static final int PE_EDIT_PRIN_BUTTON = 1; |
|
1594 |
public static final int PE_REMOVE_PRIN_BUTTON = 2; |
|
1595 |
||
1596 |
public static final int PE_PRIN_LABEL = 5; |
|
1597 |
public static final int PE_PRIN_LIST = 6; |
|
1598 |
||
1599 |
public static final int PE_PANEL1 = 7; |
|
1600 |
public static final int PE_ADD_PERM_BUTTON = 0; |
|
1601 |
public static final int PE_EDIT_PERM_BUTTON = 1; |
|
1602 |
public static final int PE_REMOVE_PERM_BUTTON = 2; |
|
1603 |
||
1604 |
public static final int PE_PERM_LIST = 8; |
|
1605 |
||
1606 |
public static final int PE_PANEL2 = 9; |
|
1607 |
public static final int PE_CANCEL_BUTTON = 1; |
|
1608 |
public static final int PE_DONE_BUTTON = 0; |
|
1609 |
||
1610 |
/* the gridbag index for components in the Principal Dialog (PRD) */ |
|
1611 |
public static final int PRD_DESC_LABEL = 0; |
|
1612 |
public static final int PRD_PRIN_CHOICE = 1; |
|
1613 |
public static final int PRD_PRIN_TEXTFIELD = 2; |
|
1614 |
public static final int PRD_NAME_LABEL = 3; |
|
1615 |
public static final int PRD_NAME_TEXTFIELD = 4; |
|
1616 |
public static final int PRD_CANCEL_BUTTON = 6; |
|
1617 |
public static final int PRD_OK_BUTTON = 5; |
|
1618 |
||
1619 |
/* the gridbag index for components in the Permission Dialog (PD) */ |
|
1620 |
public static final int PD_DESC_LABEL = 0; |
|
1621 |
public static final int PD_PERM_CHOICE = 1; |
|
1622 |
public static final int PD_PERM_TEXTFIELD = 2; |
|
1623 |
public static final int PD_NAME_CHOICE = 3; |
|
1624 |
public static final int PD_NAME_TEXTFIELD = 4; |
|
1625 |
public static final int PD_ACTIONS_CHOICE = 5; |
|
1626 |
public static final int PD_ACTIONS_TEXTFIELD = 6; |
|
1627 |
public static final int PD_SIGNEDBY_LABEL = 7; |
|
1628 |
public static final int PD_SIGNEDBY_TEXTFIELD = 8; |
|
1629 |
public static final int PD_CANCEL_BUTTON = 10; |
|
1630 |
public static final int PD_OK_BUTTON = 9; |
|
1631 |
||
1632 |
/* modes for KeyStore */ |
|
1633 |
public static final int EDIT_KEYSTORE = 0; |
|
1634 |
||
1635 |
/* the gridbag index for components in the Change KeyStore Dialog (KSD) */ |
|
1636 |
public static final int KSD_NAME_LABEL = 0; |
|
1637 |
public static final int KSD_NAME_TEXTFIELD = 1; |
|
1638 |
public static final int KSD_TYPE_LABEL = 2; |
|
1639 |
public static final int KSD_TYPE_TEXTFIELD = 3; |
|
1640 |
public static final int KSD_PROVIDER_LABEL = 4; |
|
1641 |
public static final int KSD_PROVIDER_TEXTFIELD = 5; |
|
1642 |
public static final int KSD_PWD_URL_LABEL = 6; |
|
1643 |
public static final int KSD_PWD_URL_TEXTFIELD = 7; |
|
1644 |
public static final int KSD_CANCEL_BUTTON = 9; |
|
1645 |
public static final int KSD_OK_BUTTON = 8; |
|
1646 |
||
1647 |
/* the gridbag index for components in the User Save Changes Dialog (USC) */ |
|
1648 |
public static final int USC_LABEL = 0; |
|
1649 |
public static final int USC_PANEL = 1; |
|
1650 |
public static final int USC_YES_BUTTON = 0; |
|
1651 |
public static final int USC_NO_BUTTON = 1; |
|
1652 |
public static final int USC_CANCEL_BUTTON = 2; |
|
1653 |
||
1654 |
/* gridbag index for the ConfirmRemovePolicyEntryDialog (CRPE) */ |
|
1655 |
public static final int CRPE_LABEL1 = 0; |
|
1656 |
public static final int CRPE_LABEL2 = 1; |
|
1657 |
public static final int CRPE_PANEL = 2; |
|
1658 |
public static final int CRPE_PANEL_OK = 0; |
|
1659 |
public static final int CRPE_PANEL_CANCEL = 1; |
|
1660 |
||
1661 |
/* some private static finals */ |
|
1662 |
private static final int PERMISSION = 0; |
|
1663 |
private static final int PERMISSION_NAME = 1; |
|
1664 |
private static final int PERMISSION_ACTIONS = 2; |
|
1665 |
private static final int PERMISSION_SIGNEDBY = 3; |
|
1666 |
private static final int PRINCIPAL_TYPE = 4; |
|
1667 |
private static final int PRINCIPAL_NAME = 5; |
|
1668 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1669 |
/* The preferred height of JTextField should match JComboBox. */ |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1670 |
static final int TEXTFIELD_HEIGHT = new JComboBox<>().getPreferredSize().height; |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1671 |
|
2 | 1672 |
public static java.util.ArrayList<Perm> PERM_ARRAY; |
1673 |
public static java.util.ArrayList<Prin> PRIN_ARRAY; |
|
1674 |
PolicyTool tool; |
|
1675 |
ToolWindow tw; |
|
1676 |
||
1677 |
static { |
|
1678 |
||
1679 |
// set up permission objects |
|
1680 |
||
1681 |
PERM_ARRAY = new java.util.ArrayList<Perm>(); |
|
1682 |
PERM_ARRAY.add(new AllPerm()); |
|
1683 |
PERM_ARRAY.add(new AudioPerm()); |
|
1684 |
PERM_ARRAY.add(new AuthPerm()); |
|
1685 |
PERM_ARRAY.add(new AWTPerm()); |
|
1686 |
PERM_ARRAY.add(new DelegationPerm()); |
|
1687 |
PERM_ARRAY.add(new FilePerm()); |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
20754
diff
changeset
|
1688 |
PERM_ARRAY.add(new URLPerm()); |
3482
4aaa66ce712d
6710360: export Kerberos session key to applications
weijun
parents:
715
diff
changeset
|
1689 |
PERM_ARRAY.add(new InqSecContextPerm()); |
2 | 1690 |
PERM_ARRAY.add(new LogPerm()); |
1691 |
PERM_ARRAY.add(new MgmtPerm()); |
|
1692 |
PERM_ARRAY.add(new MBeanPerm()); |
|
1693 |
PERM_ARRAY.add(new MBeanSvrPerm()); |
|
1694 |
PERM_ARRAY.add(new MBeanTrustPerm()); |
|
1695 |
PERM_ARRAY.add(new NetPerm()); |
|
26204
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
1696 |
PERM_ARRAY.add(new NetworkPerm()); |
2 | 1697 |
PERM_ARRAY.add(new PrivCredPerm()); |
1698 |
PERM_ARRAY.add(new PropPerm()); |
|
1699 |
PERM_ARRAY.add(new ReflectPerm()); |
|
1700 |
PERM_ARRAY.add(new RuntimePerm()); |
|
1701 |
PERM_ARRAY.add(new SecurityPerm()); |
|
1702 |
PERM_ARRAY.add(new SerialPerm()); |
|
1703 |
PERM_ARRAY.add(new ServicePerm()); |
|
1704 |
PERM_ARRAY.add(new SocketPerm()); |
|
1705 |
PERM_ARRAY.add(new SQLPerm()); |
|
1706 |
PERM_ARRAY.add(new SSLPerm()); |
|
1707 |
PERM_ARRAY.add(new SubjDelegPerm()); |
|
1708 |
||
1709 |
// set up principal objects |
|
1710 |
||
1711 |
PRIN_ARRAY = new java.util.ArrayList<Prin>(); |
|
1712 |
PRIN_ARRAY.add(new KrbPrin()); |
|
1713 |
PRIN_ARRAY.add(new X500Prin()); |
|
1714 |
} |
|
1715 |
||
1716 |
ToolDialog(String title, PolicyTool tool, ToolWindow tw, boolean modal) { |
|
1717 |
super(tw, modal); |
|
1718 |
setTitle(title); |
|
1719 |
this.tool = tool; |
|
1720 |
this.tw = tw; |
|
1721 |
addWindowListener(new ChildWindowListener(this)); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1722 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1723 |
// Create some space around components |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1724 |
((JPanel)getContentPane()).setBorder(new EmptyBorder(6, 6, 6, 6)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1725 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1726 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1727 |
/** |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1728 |
* Don't call getComponent directly on the window |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1729 |
*/ |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1730 |
public Component getComponent(int n) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1731 |
Component c = getContentPane().getComponent(n); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1732 |
if (c instanceof JScrollPane) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1733 |
c = ((JScrollPane)c).getViewport().getView(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1734 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1735 |
return c; |
2 | 1736 |
} |
1737 |
||
1738 |
/** |
|
1739 |
* get the Perm instance based on either the (shortened) class name |
|
1740 |
* or the fully qualified class name |
|
1741 |
*/ |
|
1742 |
static Perm getPerm(String clazz, boolean fullClassName) { |
|
1743 |
for (int i = 0; i < PERM_ARRAY.size(); i++) { |
|
1744 |
Perm next = PERM_ARRAY.get(i); |
|
1745 |
if (fullClassName) { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
1746 |
if (next.getName().equals(clazz)) { |
2 | 1747 |
return next; |
1748 |
} |
|
1749 |
} else { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
1750 |
if (next.getSimpleName().equals(clazz)) { |
2 | 1751 |
return next; |
1752 |
} |
|
1753 |
} |
|
1754 |
} |
|
1755 |
return null; |
|
1756 |
} |
|
1757 |
||
1758 |
/** |
|
1759 |
* get the Prin instance based on either the (shortened) class name |
|
1760 |
* or the fully qualified class name |
|
1761 |
*/ |
|
1762 |
static Prin getPrin(String clazz, boolean fullClassName) { |
|
1763 |
for (int i = 0; i < PRIN_ARRAY.size(); i++) { |
|
1764 |
Prin next = PRIN_ARRAY.get(i); |
|
1765 |
if (fullClassName) { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
1766 |
if (next.getName().equals(clazz)) { |
2 | 1767 |
return next; |
1768 |
} |
|
1769 |
} else { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
1770 |
if (next.getSimpleName().equals(clazz)) { |
2 | 1771 |
return next; |
1772 |
} |
|
1773 |
} |
|
1774 |
} |
|
1775 |
return null; |
|
1776 |
} |
|
1777 |
||
1778 |
/** |
|
1779 |
* pop up a dialog so the user can enter info to add a new PolicyEntry |
|
1780 |
* - if edit is TRUE, then the user is editing an existing entry |
|
1781 |
* and we should display the original info as well. |
|
1782 |
* |
|
1783 |
* - the other reason we need the 'edit' boolean is we need to know |
|
1784 |
* when we are adding a NEW policy entry. in this case, we can |
|
1785 |
* not simply update the existing entry, because it doesn't exist. |
|
1786 |
* we ONLY update the GUI listing/info, and then when the user |
|
1787 |
* finally clicks 'OK' or 'DONE', then we can collect that info |
|
1788 |
* and add it to the policy. |
|
1789 |
*/ |
|
1790 |
void displayPolicyEntryDialog(boolean edit) { |
|
1791 |
||
1792 |
int listIndex = 0; |
|
1793 |
PolicyEntry entries[] = null; |
|
1794 |
TaggedList prinList = new TaggedList(3, false); |
|
1795 |
prinList.getAccessibleContext().setAccessibleName( |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1796 |
PolicyTool.getMessage("Principal.List")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1797 |
prinList.addMouseListener |
2 | 1798 |
(new EditPrinButtonListener(tool, tw, this, edit)); |
1799 |
TaggedList permList = new TaggedList(10, false); |
|
1800 |
permList.getAccessibleContext().setAccessibleName( |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1801 |
PolicyTool.getMessage("Permission.List")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1802 |
permList.addMouseListener |
2 | 1803 |
(new EditPermButtonListener(tool, tw, this, edit)); |
1804 |
||
1805 |
// find where the PolicyTool gui is |
|
1806 |
Point location = tw.getLocationOnScreen(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1807 |
//setBounds(location.x + 75, location.y + 200, 650, 500); |
2 | 1808 |
setLayout(new GridBagLayout()); |
1809 |
setResizable(true); |
|
1810 |
||
1811 |
if (edit) { |
|
1812 |
// get the selected item |
|
1813 |
entries = tool.getEntry(); |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1814 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
1815 |
JList<String> policyList = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2 | 1816 |
listIndex = policyList.getSelectedIndex(); |
1817 |
||
1818 |
// get principal list |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1819 |
LinkedList<PolicyParser.PrincipalEntry> principals = |
2 | 1820 |
entries[listIndex].getGrantEntry().principals; |
1821 |
for (int i = 0; i < principals.size(); i++) { |
|
1822 |
String prinString = null; |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1823 |
PolicyParser.PrincipalEntry nextPrin = principals.get(i); |
2 | 1824 |
prinList.addTaggedItem(PrincipalEntryToUserFriendlyString(nextPrin), nextPrin); |
1825 |
} |
|
1826 |
||
1827 |
// get permission list |
|
1828 |
Vector<PolicyParser.PermissionEntry> permissions = |
|
1829 |
entries[listIndex].getGrantEntry().permissionEntries; |
|
1830 |
for (int i = 0; i < permissions.size(); i++) { |
|
1831 |
String permString = null; |
|
1832 |
PolicyParser.PermissionEntry nextPerm = |
|
1833 |
permissions.elementAt(i); |
|
1834 |
permList.addTaggedItem(ToolDialog.PermissionEntryToUserFriendlyString(nextPerm), nextPerm); |
|
1835 |
} |
|
1836 |
} |
|
1837 |
||
1838 |
// codebase label and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1839 |
JLabel label = new JLabel(); |
2 | 1840 |
tw.addNewComponent(this, label, PE_CODEBASE_LABEL, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1841 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1842 |
ToolWindow.R_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1843 |
JTextField tf; |
2 | 1844 |
tf = (edit ? |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1845 |
new JTextField(entries[listIndex].getGrantEntry().codeBase) : |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1846 |
new JTextField()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1847 |
ToolWindow.configureLabelFor(label, tf, "CodeBase."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1848 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 1849 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1850 |
PolicyTool.getMessage("Code.Base")); |
2 | 1851 |
tw.addNewComponent(this, tf, PE_CODEBASE_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1852 |
1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH); |
2 | 1853 |
|
1854 |
// signedby label and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1855 |
label = new JLabel(); |
2 | 1856 |
tw.addNewComponent(this, label, PE_SIGNEDBY_LABEL, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1857 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1858 |
ToolWindow.R_PADDING); |
2 | 1859 |
tf = (edit ? |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1860 |
new JTextField(entries[listIndex].getGrantEntry().signedBy) : |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1861 |
new JTextField()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1862 |
ToolWindow.configureLabelFor(label, tf, "SignedBy."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1863 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 1864 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1865 |
PolicyTool.getMessage("Signed.By.")); |
2 | 1866 |
tw.addNewComponent(this, tf, PE_SIGNEDBY_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1867 |
1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH); |
2 | 1868 |
|
1869 |
// panel for principal buttons |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1870 |
JPanel panel = new JPanel(); |
2 | 1871 |
panel.setLayout(new GridBagLayout()); |
1872 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1873 |
JButton button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1874 |
ToolWindow.configureButton(button, "Add.Principal"); |
2 | 1875 |
button.addActionListener |
1876 |
(new AddPrinButtonListener(tool, tw, this, edit)); |
|
1877 |
tw.addNewComponent(panel, button, PE_ADD_PRIN_BUTTON, |
|
1878 |
0, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
|
1879 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1880 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1881 |
ToolWindow.configureButton(button, "Edit.Principal"); |
2 | 1882 |
button.addActionListener(new EditPrinButtonListener |
1883 |
(tool, tw, this, edit)); |
|
1884 |
tw.addNewComponent(panel, button, PE_EDIT_PRIN_BUTTON, |
|
1885 |
1, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
|
1886 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1887 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1888 |
ToolWindow.configureButton(button, "Remove.Principal"); |
2 | 1889 |
button.addActionListener(new RemovePrinButtonListener |
1890 |
(tool, tw, this, edit)); |
|
1891 |
tw.addNewComponent(panel, button, PE_REMOVE_PRIN_BUTTON, |
|
1892 |
2, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
|
1893 |
||
1894 |
tw.addNewComponent(this, panel, PE_PANEL0, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1895 |
1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.HORIZONTAL, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1896 |
ToolWindow.LITE_BOTTOM_PADDING); |
2 | 1897 |
|
1898 |
// principal label and list |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1899 |
label = new JLabel(); |
2 | 1900 |
tw.addNewComponent(this, label, PE_PRIN_LABEL, |
1901 |
0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1902 |
ToolWindow.R_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1903 |
JScrollPane scrollPane = new JScrollPane(prinList); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1904 |
ToolWindow.configureLabelFor(label, scrollPane, "Principals."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1905 |
tw.addNewComponent(this, scrollPane, PE_PRIN_LIST, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1906 |
1, 3, 3, 1, 0.0, prinList.getVisibleRowCount(), GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1907 |
ToolWindow.BOTTOM_PADDING); |
2 | 1908 |
|
1909 |
// panel for permission buttons |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1910 |
panel = new JPanel(); |
2 | 1911 |
panel.setLayout(new GridBagLayout()); |
1912 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1913 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1914 |
ToolWindow.configureButton(button, ".Add.Permission"); |
2 | 1915 |
button.addActionListener(new AddPermButtonListener |
1916 |
(tool, tw, this, edit)); |
|
1917 |
tw.addNewComponent(panel, button, PE_ADD_PERM_BUTTON, |
|
1918 |
0, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
|
1919 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1920 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1921 |
ToolWindow.configureButton(button, ".Edit.Permission"); |
2 | 1922 |
button.addActionListener(new EditPermButtonListener |
1923 |
(tool, tw, this, edit)); |
|
1924 |
tw.addNewComponent(panel, button, PE_EDIT_PERM_BUTTON, |
|
1925 |
1, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
|
1926 |
||
1927 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1928 |
button = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1929 |
ToolWindow.configureButton(button, "Remove.Permission"); |
2 | 1930 |
button.addActionListener(new RemovePermButtonListener |
1931 |
(tool, tw, this, edit)); |
|
1932 |
tw.addNewComponent(panel, button, PE_REMOVE_PERM_BUTTON, |
|
1933 |
2, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
|
1934 |
||
1935 |
tw.addNewComponent(this, panel, PE_PANEL1, |
|
1936 |
0, 4, 2, 1, 0.0, 0.0, GridBagConstraints.HORIZONTAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1937 |
ToolWindow.LITE_BOTTOM_PADDING); |
2 | 1938 |
|
1939 |
// permission list |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1940 |
scrollPane = new JScrollPane(permList); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1941 |
tw.addNewComponent(this, scrollPane, PE_PERM_LIST, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1942 |
0, 5, 3, 1, 0.0, permList.getVisibleRowCount(), GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1943 |
ToolWindow.BOTTOM_PADDING); |
2 | 1944 |
|
1945 |
||
1946 |
// panel for Done and Cancel buttons |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1947 |
panel = new JPanel(); |
2 | 1948 |
panel.setLayout(new GridBagLayout()); |
1949 |
||
1950 |
// Done Button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1951 |
JButton okButton = new JButton(PolicyTool.getMessage("Done")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1952 |
okButton.addActionListener |
2 | 1953 |
(new AddEntryDoneButtonListener(tool, tw, this, edit)); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1954 |
tw.addNewComponent(panel, okButton, PE_DONE_BUTTON, |
2 | 1955 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1956 |
ToolWindow.LR_PADDING); |
2 | 1957 |
|
1958 |
// Cancel Button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1959 |
JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1960 |
ActionListener cancelListener = new CancelButtonListener(this); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1961 |
cancelButton.addActionListener(cancelListener); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1962 |
tw.addNewComponent(panel, cancelButton, PE_CANCEL_BUTTON, |
2 | 1963 |
1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
1964 |
ToolWindow.LR_PADDING); |
2 | 1965 |
|
1966 |
// add the panel |
|
1967 |
tw.addNewComponent(this, panel, PE_PANEL2, |
|
1968 |
0, 6, 2, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
1969 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1970 |
getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1971 |
getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1972 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1973 |
pack(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1974 |
setLocationRelativeTo(tw); |
2 | 1975 |
setVisible(true); |
1976 |
} |
|
1977 |
||
1978 |
/** |
|
1979 |
* Read all the Policy information data in the dialog box |
|
1980 |
* and construct a PolicyEntry object with it. |
|
1981 |
*/ |
|
1982 |
PolicyEntry getPolicyEntryFromDialog() |
|
1983 |
throws InvalidParameterException, MalformedURLException, |
|
1984 |
NoSuchMethodException, ClassNotFoundException, InstantiationException, |
|
1985 |
IllegalAccessException, InvocationTargetException, |
|
1986 |
CertificateException, IOException, Exception { |
|
1987 |
||
1988 |
// get the Codebase |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1989 |
JTextField tf = (JTextField)getComponent(PE_CODEBASE_TEXTFIELD); |
2 | 1990 |
String codebase = null; |
1991 |
if (tf.getText().trim().equals("") == false) |
|
1992 |
codebase = new String(tf.getText().trim()); |
|
1993 |
||
1994 |
// get the SignedBy |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
1995 |
tf = (JTextField)getComponent(PE_SIGNEDBY_TEXTFIELD); |
2 | 1996 |
String signedby = null; |
1997 |
if (tf.getText().trim().equals("") == false) |
|
1998 |
signedby = new String(tf.getText().trim()); |
|
1999 |
||
2000 |
// construct a new GrantEntry |
|
2001 |
PolicyParser.GrantEntry ge = |
|
2002 |
new PolicyParser.GrantEntry(signedby, codebase); |
|
2003 |
||
2004 |
// get the new Principals |
|
7977
f47f211cd627
7008713: diamond conversion of kerberos5 and security tools
smarks
parents:
7532
diff
changeset
|
2005 |
LinkedList<PolicyParser.PrincipalEntry> prins = new LinkedList<>(); |
2 | 2006 |
TaggedList prinList = (TaggedList)getComponent(PE_PRIN_LIST); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2007 |
for (int i = 0; i < prinList.getModel().getSize(); i++) { |
2 | 2008 |
prins.add((PolicyParser.PrincipalEntry)prinList.getObject(i)); |
2009 |
} |
|
2010 |
ge.principals = prins; |
|
2011 |
||
2012 |
// get the new Permissions |
|
7977
f47f211cd627
7008713: diamond conversion of kerberos5 and security tools
smarks
parents:
7532
diff
changeset
|
2013 |
Vector<PolicyParser.PermissionEntry> perms = new Vector<>(); |
2 | 2014 |
TaggedList permList = (TaggedList)getComponent(PE_PERM_LIST); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2015 |
for (int i = 0; i < permList.getModel().getSize(); i++) { |
2 | 2016 |
perms.addElement((PolicyParser.PermissionEntry)permList.getObject(i)); |
2017 |
} |
|
2018 |
ge.permissionEntries = perms; |
|
2019 |
||
2020 |
// construct a new PolicyEntry object |
|
2021 |
PolicyEntry entry = new PolicyEntry(tool, ge); |
|
2022 |
||
2023 |
return entry; |
|
2024 |
} |
|
2025 |
||
2026 |
/** |
|
2027 |
* display a dialog box for the user to enter KeyStore information |
|
2028 |
*/ |
|
2029 |
void keyStoreDialog(int mode) { |
|
2030 |
||
2031 |
// find where the PolicyTool gui is |
|
2032 |
Point location = tw.getLocationOnScreen(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2033 |
//setBounds(location.x + 25, location.y + 100, 500, 300); |
2 | 2034 |
setLayout(new GridBagLayout()); |
2035 |
||
2036 |
if (mode == EDIT_KEYSTORE) { |
|
2037 |
||
2038 |
// KeyStore label and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2039 |
JLabel label = new JLabel(); |
2 | 2040 |
tw.addNewComponent(this, label, KSD_NAME_LABEL, |
2041 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2042 |
ToolWindow.R_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2043 |
JTextField tf = new JTextField(tool.getKeyStoreName(), 30); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2044 |
ToolWindow.configureLabelFor(label, tf, "KeyStore.URL."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2045 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2046 |
|
2047 |
// URL to U R L, so that accessibility reader will pronounce well |
|
2048 |
tf.getAccessibleContext().setAccessibleName( |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2049 |
PolicyTool.getMessage("KeyStore.U.R.L.")); |
2 | 2050 |
tw.addNewComponent(this, tf, KSD_NAME_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2051 |
1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2052 |
ToolWindow.BOTTOM_PADDING); |
2 | 2053 |
|
2054 |
// KeyStore type and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2055 |
label = new JLabel(); |
2 | 2056 |
tw.addNewComponent(this, label, KSD_TYPE_LABEL, |
2057 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2058 |
ToolWindow.R_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2059 |
tf = new JTextField(tool.getKeyStoreType(), 30); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2060 |
ToolWindow.configureLabelFor(label, tf, "KeyStore.Type."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2061 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2062 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2063 |
PolicyTool.getMessage("KeyStore.Type.")); |
2 | 2064 |
tw.addNewComponent(this, tf, KSD_TYPE_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2065 |
1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2066 |
ToolWindow.BOTTOM_PADDING); |
2 | 2067 |
|
2068 |
// KeyStore provider and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2069 |
label = new JLabel(); |
2 | 2070 |
tw.addNewComponent(this, label, KSD_PROVIDER_LABEL, |
2071 |
0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2072 |
ToolWindow.R_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2073 |
tf = new JTextField(tool.getKeyStoreProvider(), 30); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2074 |
ToolWindow.configureLabelFor(label, tf, "KeyStore.Provider."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2075 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2076 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2077 |
PolicyTool.getMessage("KeyStore.Provider.")); |
2 | 2078 |
tw.addNewComponent(this, tf, KSD_PROVIDER_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2079 |
1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2080 |
ToolWindow.BOTTOM_PADDING); |
2 | 2081 |
|
2082 |
// KeyStore password URL and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2083 |
label = new JLabel(); |
2 | 2084 |
tw.addNewComponent(this, label, KSD_PWD_URL_LABEL, |
2085 |
0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2086 |
ToolWindow.R_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2087 |
tf = new JTextField(tool.getKeyStorePwdURL(), 30); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2088 |
ToolWindow.configureLabelFor(label, tf, "KeyStore.Password.URL."); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2089 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2090 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2091 |
PolicyTool.getMessage("KeyStore.Password.U.R.L.")); |
2 | 2092 |
tw.addNewComponent(this, tf, KSD_PWD_URL_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2093 |
1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2094 |
ToolWindow.BOTTOM_PADDING); |
2 | 2095 |
|
2096 |
// OK button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2097 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
2 | 2098 |
okButton.addActionListener |
2099 |
(new ChangeKeyStoreOKButtonListener(tool, tw, this)); |
|
2100 |
tw.addNewComponent(this, okButton, KSD_OK_BUTTON, |
|
2101 |
0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
2102 |
||
2103 |
// cancel button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2104 |
JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2105 |
ActionListener cancelListener = new CancelButtonListener(this); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2106 |
cancelButton.addActionListener(cancelListener); |
2 | 2107 |
tw.addNewComponent(this, cancelButton, KSD_CANCEL_BUTTON, |
2108 |
1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
2109 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2110 |
getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2111 |
getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
2 | 2112 |
} |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2113 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2114 |
pack(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2115 |
setLocationRelativeTo(tw); |
2 | 2116 |
setVisible(true); |
2117 |
} |
|
2118 |
||
2119 |
/** |
|
2120 |
* display a dialog box for the user to input Principal info |
|
2121 |
* |
|
2122 |
* if editPolicyEntry is false, then we are adding Principals to |
|
2123 |
* a new PolicyEntry, and we only update the GUI listing |
|
2124 |
* with the new Principal. |
|
2125 |
* |
|
2126 |
* if edit is true, then we are editing an existing Policy entry. |
|
2127 |
*/ |
|
2128 |
void displayPrincipalDialog(boolean editPolicyEntry, boolean edit) { |
|
2129 |
||
2130 |
PolicyParser.PrincipalEntry editMe = null; |
|
2131 |
||
2132 |
// get the Principal selected from the Principal List |
|
2133 |
TaggedList prinList = (TaggedList)getComponent(PE_PRIN_LIST); |
|
2134 |
int prinIndex = prinList.getSelectedIndex(); |
|
2135 |
||
2136 |
if (edit) { |
|
2137 |
editMe = (PolicyParser.PrincipalEntry)prinList.getObject(prinIndex); |
|
2138 |
} |
|
2139 |
||
2140 |
ToolDialog newTD = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2141 |
(PolicyTool.getMessage("Principals"), tool, tw, true); |
2 | 2142 |
newTD.addWindowListener(new ChildWindowListener(newTD)); |
2143 |
||
2144 |
// find where the PolicyTool gui is |
|
2145 |
Point location = getLocationOnScreen(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2146 |
//newTD.setBounds(location.x + 50, location.y + 100, 650, 190); |
2 | 2147 |
newTD.setLayout(new GridBagLayout()); |
2148 |
newTD.setResizable(true); |
|
2149 |
||
2150 |
// description label |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2151 |
JLabel label = (edit ? |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2152 |
new JLabel(PolicyTool.getMessage(".Edit.Principal.")) : |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2153 |
new JLabel(PolicyTool.getMessage(".Add.New.Principal."))); |
2 | 2154 |
tw.addNewComponent(newTD, label, PRD_DESC_LABEL, |
2155 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2156 |
ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2157 |
|
2158 |
// principal choice |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2159 |
JComboBox<String> choice = new JComboBox<>(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2160 |
choice.addItem(PRIN_TYPE); |
2 | 2161 |
choice.getAccessibleContext().setAccessibleName(PRIN_TYPE); |
2162 |
for (int i = 0; i < PRIN_ARRAY.size(); i++) { |
|
2163 |
Prin next = PRIN_ARRAY.get(i); |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2164 |
choice.addItem(next.getSimpleName()); |
2 | 2165 |
} |
2166 |
||
2167 |
if (edit) { |
|
2168 |
if (PolicyParser.PrincipalEntry.WILDCARD_CLASS.equals |
|
2169 |
(editMe.getPrincipalClass())) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2170 |
choice.setSelectedItem(PRIN_TYPE); |
2 | 2171 |
} else { |
2172 |
Prin inputPrin = getPrin(editMe.getPrincipalClass(), true); |
|
2173 |
if (inputPrin != null) { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2174 |
choice.setSelectedItem(inputPrin.getSimpleName()); |
2 | 2175 |
} |
2176 |
} |
|
2177 |
} |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2178 |
// Add listener after selected item is set |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2179 |
choice.addItemListener(new PrincipalTypeMenuListener(newTD)); |
2 | 2180 |
|
2181 |
tw.addNewComponent(newTD, choice, PRD_PRIN_CHOICE, |
|
2182 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2183 |
ToolWindow.LR_PADDING); |
2 | 2184 |
|
2185 |
// principal textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2186 |
JTextField tf; |
2 | 2187 |
tf = (edit ? |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2188 |
new JTextField(editMe.getDisplayClass(), 30) : |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2189 |
new JTextField(30)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2190 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2191 |
tf.getAccessibleContext().setAccessibleName(PRIN_TYPE); |
2192 |
tw.addNewComponent(newTD, tf, PRD_PRIN_TEXTFIELD, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2193 |
1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2194 |
ToolWindow.LR_PADDING); |
2 | 2195 |
|
2196 |
// name label and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2197 |
label = new JLabel(PRIN_NAME); |
2 | 2198 |
tf = (edit ? |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2199 |
new JTextField(editMe.getDisplayName(), 40) : |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2200 |
new JTextField(40)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2201 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2202 |
tf.getAccessibleContext().setAccessibleName(PRIN_NAME); |
2203 |
||
2204 |
tw.addNewComponent(newTD, label, PRD_NAME_LABEL, |
|
2205 |
0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2206 |
ToolWindow.LR_PADDING); |
2 | 2207 |
tw.addNewComponent(newTD, tf, PRD_NAME_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2208 |
1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2209 |
ToolWindow.LR_PADDING); |
2 | 2210 |
|
2211 |
// OK button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2212 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
2 | 2213 |
okButton.addActionListener( |
2214 |
new NewPolicyPrinOKButtonListener |
|
2215 |
(tool, tw, this, newTD, edit)); |
|
2216 |
tw.addNewComponent(newTD, okButton, PRD_OK_BUTTON, |
|
2217 |
0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2218 |
ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2219 |
// cancel button |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2220 |
JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2221 |
ActionListener cancelListener = new CancelButtonListener(newTD); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2222 |
cancelButton.addActionListener(cancelListener); |
2 | 2223 |
tw.addNewComponent(newTD, cancelButton, PRD_CANCEL_BUTTON, |
2224 |
1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2225 |
ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2226 |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2227 |
newTD.getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2228 |
newTD.getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2229 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2230 |
newTD.pack(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2231 |
newTD.setLocationRelativeTo(tw); |
2 | 2232 |
newTD.setVisible(true); |
2233 |
} |
|
2234 |
||
2235 |
/** |
|
2236 |
* display a dialog box for the user to input Permission info |
|
2237 |
* |
|
2238 |
* if editPolicyEntry is false, then we are adding Permissions to |
|
2239 |
* a new PolicyEntry, and we only update the GUI listing |
|
2240 |
* with the new Permission. |
|
2241 |
* |
|
2242 |
* if edit is true, then we are editing an existing Permission entry. |
|
2243 |
*/ |
|
2244 |
void displayPermissionDialog(boolean editPolicyEntry, boolean edit) { |
|
2245 |
||
2246 |
PolicyParser.PermissionEntry editMe = null; |
|
2247 |
||
2248 |
// get the Permission selected from the Permission List |
|
2249 |
TaggedList permList = (TaggedList)getComponent(PE_PERM_LIST); |
|
2250 |
int permIndex = permList.getSelectedIndex(); |
|
2251 |
||
2252 |
if (edit) { |
|
2253 |
editMe = (PolicyParser.PermissionEntry)permList.getObject(permIndex); |
|
2254 |
} |
|
2255 |
||
2256 |
ToolDialog newTD = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2257 |
(PolicyTool.getMessage("Permissions"), tool, tw, true); |
2 | 2258 |
newTD.addWindowListener(new ChildWindowListener(newTD)); |
2259 |
||
2260 |
// find where the PolicyTool gui is |
|
2261 |
Point location = getLocationOnScreen(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2262 |
//newTD.setBounds(location.x + 50, location.y + 100, 700, 250); |
2 | 2263 |
newTD.setLayout(new GridBagLayout()); |
2264 |
newTD.setResizable(true); |
|
2265 |
||
2266 |
// description label |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2267 |
JLabel label = (edit ? |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2268 |
new JLabel(PolicyTool.getMessage(".Edit.Permission.")) : |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2269 |
new JLabel(PolicyTool.getMessage(".Add.New.Permission."))); |
2 | 2270 |
tw.addNewComponent(newTD, label, PD_DESC_LABEL, |
2271 |
0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2272 |
ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2273 |
|
2274 |
// permission choice (added in alphabetical order) |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2275 |
JComboBox<String> choice = new JComboBox<>(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2276 |
choice.addItem(PERM); |
2 | 2277 |
choice.getAccessibleContext().setAccessibleName(PERM); |
2278 |
for (int i = 0; i < PERM_ARRAY.size(); i++) { |
|
2279 |
Perm next = PERM_ARRAY.get(i); |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2280 |
choice.addItem(next.getSimpleName()); |
2 | 2281 |
} |
2282 |
tw.addNewComponent(newTD, choice, PD_PERM_CHOICE, |
|
2283 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2284 |
ToolWindow.LR_BOTTOM_PADDING); |
2 | 2285 |
|
2286 |
// permission textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2287 |
JTextField tf; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2288 |
tf = (edit ? new JTextField(editMe.permission, 30) : new JTextField(30)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2289 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2290 |
tf.getAccessibleContext().setAccessibleName(PERM); |
2291 |
if (edit) { |
|
2292 |
Perm inputPerm = getPerm(editMe.permission, true); |
|
2293 |
if (inputPerm != null) { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2294 |
choice.setSelectedItem(inputPerm.getSimpleName()); |
2 | 2295 |
} |
2296 |
} |
|
2297 |
tw.addNewComponent(newTD, tf, PD_PERM_TEXTFIELD, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2298 |
1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2299 |
ToolWindow.LR_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2300 |
choice.addItemListener(new PermissionMenuListener(newTD)); |
2 | 2301 |
|
2302 |
// name label and textfield |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2303 |
choice = new JComboBox<>(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2304 |
choice.addItem(PERM_NAME); |
2 | 2305 |
choice.getAccessibleContext().setAccessibleName(PERM_NAME); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2306 |
tf = (edit ? new JTextField(editMe.name, 40) : new JTextField(40)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2307 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2308 |
tf.getAccessibleContext().setAccessibleName(PERM_NAME); |
2309 |
if (edit) { |
|
2310 |
setPermissionNames(getPerm(editMe.permission, true), choice, tf); |
|
2311 |
} |
|
2312 |
tw.addNewComponent(newTD, choice, PD_NAME_CHOICE, |
|
2313 |
0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2314 |
ToolWindow.LR_BOTTOM_PADDING); |
2 | 2315 |
tw.addNewComponent(newTD, tf, PD_NAME_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2316 |
1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2317 |
ToolWindow.LR_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2318 |
choice.addItemListener(new PermissionNameMenuListener(newTD)); |
2 | 2319 |
|
2320 |
// actions label and textfield |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2321 |
choice = new JComboBox<>(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2322 |
choice.addItem(PERM_ACTIONS); |
2 | 2323 |
choice.getAccessibleContext().setAccessibleName(PERM_ACTIONS); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2324 |
tf = (edit ? new JTextField(editMe.action, 40) : new JTextField(40)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2325 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2326 |
tf.getAccessibleContext().setAccessibleName(PERM_ACTIONS); |
2327 |
if (edit) { |
|
2328 |
setPermissionActions(getPerm(editMe.permission, true), choice, tf); |
|
2329 |
} |
|
2330 |
tw.addNewComponent(newTD, choice, PD_ACTIONS_CHOICE, |
|
2331 |
0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2332 |
ToolWindow.LR_BOTTOM_PADDING); |
2 | 2333 |
tw.addNewComponent(newTD, tf, PD_ACTIONS_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2334 |
1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2335 |
ToolWindow.LR_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2336 |
choice.addItemListener(new PermissionActionsMenuListener(newTD)); |
2 | 2337 |
|
2338 |
// signedby label and textfield |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2339 |
label = new JLabel(PolicyTool.getMessage("Signed.By.")); |
2 | 2340 |
tw.addNewComponent(newTD, label, PD_SIGNEDBY_LABEL, |
2341 |
0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2342 |
ToolWindow.LR_BOTTOM_PADDING); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2343 |
tf = (edit ? new JTextField(editMe.signedBy, 40) : new JTextField(40)); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2344 |
tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2 | 2345 |
tf.getAccessibleContext().setAccessibleName( |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2346 |
PolicyTool.getMessage("Signed.By.")); |
2 | 2347 |
tw.addNewComponent(newTD, tf, PD_SIGNEDBY_TEXTFIELD, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2348 |
1, 4, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2349 |
ToolWindow.LR_BOTTOM_PADDING); |
2 | 2350 |
|
2351 |
// OK button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2352 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
2 | 2353 |
okButton.addActionListener( |
2354 |
new NewPolicyPermOKButtonListener |
|
2355 |
(tool, tw, this, newTD, edit)); |
|
2356 |
tw.addNewComponent(newTD, okButton, PD_OK_BUTTON, |
|
2357 |
0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2358 |
ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2359 |
|
2360 |
// cancel button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2361 |
JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2362 |
ActionListener cancelListener = new CancelButtonListener(newTD); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2363 |
cancelButton.addActionListener(cancelListener); |
2 | 2364 |
tw.addNewComponent(newTD, cancelButton, PD_CANCEL_BUTTON, |
2365 |
1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2366 |
ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2367 |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2368 |
newTD.getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2369 |
newTD.getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2370 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2371 |
newTD.pack(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2372 |
newTD.setLocationRelativeTo(tw); |
2 | 2373 |
newTD.setVisible(true); |
2374 |
} |
|
2375 |
||
2376 |
/** |
|
2377 |
* construct a Principal object from the Principal Info Dialog Box |
|
2378 |
*/ |
|
2379 |
PolicyParser.PrincipalEntry getPrinFromDialog() throws Exception { |
|
2380 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2381 |
JTextField tf = (JTextField)getComponent(PRD_PRIN_TEXTFIELD); |
2 | 2382 |
String pclass = new String(tf.getText().trim()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2383 |
tf = (JTextField)getComponent(PRD_NAME_TEXTFIELD); |
2 | 2384 |
String pname = new String(tf.getText().trim()); |
2385 |
if (pclass.equals("*")) { |
|
2386 |
pclass = PolicyParser.PrincipalEntry.WILDCARD_CLASS; |
|
2387 |
} |
|
2388 |
if (pname.equals("*")) { |
|
2389 |
pname = PolicyParser.PrincipalEntry.WILDCARD_NAME; |
|
2390 |
} |
|
2391 |
||
2392 |
PolicyParser.PrincipalEntry pppe = null; |
|
2393 |
||
2394 |
if ((pclass.equals(PolicyParser.PrincipalEntry.WILDCARD_CLASS)) && |
|
2395 |
(!pname.equals(PolicyParser.PrincipalEntry.WILDCARD_NAME))) { |
|
2396 |
throw new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2397 |
(PolicyTool.getMessage("Cannot.Specify.Principal.with.a.Wildcard.Class.without.a.Wildcard.Name")); |
2 | 2398 |
} else if (pname.equals("")) { |
2399 |
throw new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2400 |
(PolicyTool.getMessage("Cannot.Specify.Principal.without.a.Name")); |
2 | 2401 |
} else if (pclass.equals("")) { |
2402 |
// make this consistent with what PolicyParser does |
|
2403 |
// when it sees an empty principal class |
|
15013
4a17ca431caf
7019834: Eliminate dependency from PolicyFile to com.sun.security.auth.PrincipalComparator
mullan
parents:
14182
diff
changeset
|
2404 |
pclass = PolicyParser.PrincipalEntry.REPLACE_NAME; |
2 | 2405 |
tool.warnings.addElement( |
2406 |
"Warning: Principal name '" + pname + |
|
2407 |
"' specified without a Principal class.\n" + |
|
2408 |
"\t'" + pname + "' will be interpreted " + |
|
2409 |
"as a key store alias.\n" + |
|
2410 |
"\tThe final principal class will be " + |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2411 |
X500Principal.class.getName() + ".\n" + |
2 | 2412 |
"\tThe final principal name will be " + |
2413 |
"determined by the following:\n" + |
|
2414 |
"\n" + |
|
2415 |
"\tIf the key store entry identified by '" |
|
2416 |
+ pname + "'\n" + |
|
2417 |
"\tis a key entry, then the principal name will be\n" + |
|
2418 |
"\tthe subject distinguished name from the first\n" + |
|
2419 |
"\tcertificate in the entry's certificate chain.\n" + |
|
2420 |
"\n" + |
|
2421 |
"\tIf the key store entry identified by '" + |
|
2422 |
pname + "'\n" + |
|
2423 |
"\tis a trusted certificate entry, then the\n" + |
|
2424 |
"\tprincipal name will be the subject distinguished\n" + |
|
2425 |
"\tname from the trusted public key certificate."); |
|
2426 |
tw.displayStatusDialog(this, |
|
2427 |
"'" + pname + "' will be interpreted as a key " + |
|
2428 |
"store alias. View Warning Log for details."); |
|
2429 |
} |
|
2430 |
return new PolicyParser.PrincipalEntry(pclass, pname); |
|
2431 |
} |
|
2432 |
||
2433 |
||
2434 |
/** |
|
2435 |
* construct a Permission object from the Permission Info Dialog Box |
|
2436 |
*/ |
|
2437 |
PolicyParser.PermissionEntry getPermFromDialog() { |
|
2438 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2439 |
JTextField tf = (JTextField)getComponent(PD_PERM_TEXTFIELD); |
2 | 2440 |
String permission = new String(tf.getText().trim()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2441 |
tf = (JTextField)getComponent(PD_NAME_TEXTFIELD); |
2 | 2442 |
String name = null; |
2443 |
if (tf.getText().trim().equals("") == false) |
|
2444 |
name = new String(tf.getText().trim()); |
|
2445 |
if (permission.equals("") || |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2446 |
(!permission.equals(AllPermission.class.getName()) && name == null)) { |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2447 |
throw new InvalidParameterException(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
2448 |
("Permission.and.Target.Name.must.have.a.value")); |
2 | 2449 |
} |
2450 |
||
2451 |
// When the permission is FilePermission, we need to check the name |
|
2452 |
// to make sure it's not escaped. We believe -- |
|
2453 |
// |
|
2454 |
// String name.lastIndexOf("\\\\") |
|
2455 |
// ---------------- ------------------------ |
|
2456 |
// c:\foo\bar -1, legal |
|
2457 |
// c:\\foo\\bar 2, illegal |
|
2458 |
// \\server\share 0, legal |
|
2459 |
// \\\\server\share 2, illegal |
|
2460 |
||
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2461 |
if (permission.equals(FilePermission.class.getName()) |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
2462 |
&& name.lastIndexOf("\\\\") > 0) { |
2 | 2463 |
char result = tw.displayYesNoDialog(this, |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2464 |
PolicyTool.getMessage("Warning"), |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2465 |
PolicyTool.getMessage( |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
2466 |
"Warning.File.name.may.include.escaped.backslash.characters.It.is.not.necessary.to.escape.backslash.characters.the.tool.escapes"), |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2467 |
PolicyTool.getMessage("Retain"), |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2468 |
PolicyTool.getMessage("Edit") |
2 | 2469 |
); |
2470 |
if (result != 'Y') { |
|
2471 |
// an invisible exception |
|
2472 |
throw new NoDisplayException(); |
|
2473 |
} |
|
2474 |
} |
|
2475 |
// get the Actions |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2476 |
tf = (JTextField)getComponent(PD_ACTIONS_TEXTFIELD); |
2 | 2477 |
String actions = null; |
2478 |
if (tf.getText().trim().equals("") == false) |
|
2479 |
actions = new String(tf.getText().trim()); |
|
2480 |
||
2481 |
// get the Signed By |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2482 |
tf = (JTextField)getComponent(PD_SIGNEDBY_TEXTFIELD); |
2 | 2483 |
String signedBy = null; |
2484 |
if (tf.getText().trim().equals("") == false) |
|
2485 |
signedBy = new String(tf.getText().trim()); |
|
2486 |
||
2487 |
PolicyParser.PermissionEntry pppe = new PolicyParser.PermissionEntry |
|
2488 |
(permission, name, actions); |
|
2489 |
pppe.signedBy = signedBy; |
|
2490 |
||
2491 |
// see if the signers have public keys |
|
2492 |
if (signedBy != null) { |
|
2493 |
String signers[] = tool.parseSigners(pppe.signedBy); |
|
2494 |
for (int i = 0; i < signers.length; i++) { |
|
2495 |
try { |
|
2496 |
PublicKey pubKey = tool.getPublicKeyAlias(signers[i]); |
|
2497 |
if (pubKey == null) { |
|
2498 |
MessageFormat form = new MessageFormat |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2499 |
(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
2500 |
("Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.")); |
2 | 2501 |
Object[] source = {signers[i]}; |
2502 |
tool.warnings.addElement(form.format(source)); |
|
2503 |
tw.displayStatusDialog(this, form.format(source)); |
|
2504 |
} |
|
2505 |
} catch (Exception e) { |
|
2506 |
tw.displayErrorDialog(this, e); |
|
2507 |
} |
|
2508 |
} |
|
2509 |
} |
|
2510 |
return pppe; |
|
2511 |
} |
|
2512 |
||
2513 |
/** |
|
2514 |
* confirm that the user REALLY wants to remove the Policy Entry |
|
2515 |
*/ |
|
2516 |
void displayConfirmRemovePolicyEntry() { |
|
2517 |
||
2518 |
// find the entry to be removed |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2519 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2520 |
JList<String> list = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2 | 2521 |
int index = list.getSelectedIndex(); |
2522 |
PolicyEntry entries[] = tool.getEntry(); |
|
2523 |
||
2524 |
// find where the PolicyTool gui is |
|
2525 |
Point location = tw.getLocationOnScreen(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2526 |
//setBounds(location.x + 25, location.y + 100, 600, 400); |
2 | 2527 |
setLayout(new GridBagLayout()); |
2528 |
||
2529 |
// ask the user do they really want to do this? |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2530 |
JLabel label = new JLabel |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2531 |
(PolicyTool.getMessage("Remove.this.Policy.Entry.")); |
2 | 2532 |
tw.addNewComponent(this, label, CRPE_LABEL1, |
2533 |
0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2534 |
ToolWindow.BOTTOM_PADDING); |
2 | 2535 |
|
2536 |
// display the policy entry |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2537 |
label = new JLabel(entries[index].codebaseToString()); |
2 | 2538 |
tw.addNewComponent(this, label, CRPE_LABEL2, |
2539 |
0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2540 |
label = new JLabel(entries[index].principalsToString().trim()); |
2 | 2541 |
tw.addNewComponent(this, label, CRPE_LABEL2+1, |
2542 |
0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
|
2543 |
Vector<PolicyParser.PermissionEntry> perms = |
|
2544 |
entries[index].getGrantEntry().permissionEntries; |
|
2545 |
for (int i = 0; i < perms.size(); i++) { |
|
2546 |
PolicyParser.PermissionEntry nextPerm = perms.elementAt(i); |
|
2547 |
String permString = ToolDialog.PermissionEntryToUserFriendlyString(nextPerm); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2548 |
label = new JLabel(" " + permString); |
2 | 2549 |
if (i == (perms.size()-1)) { |
2550 |
tw.addNewComponent(this, label, CRPE_LABEL2 + 2 + i, |
|
2551 |
1, 3 + i, 1, 1, 0.0, 0.0, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2552 |
GridBagConstraints.BOTH, |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2553 |
ToolWindow.BOTTOM_PADDING); |
2 | 2554 |
} else { |
2555 |
tw.addNewComponent(this, label, CRPE_LABEL2 + 2 + i, |
|
2556 |
1, 3 + i, 1, 1, 0.0, 0.0, |
|
2557 |
GridBagConstraints.BOTH); |
|
2558 |
} |
|
2559 |
} |
|
2560 |
||
2561 |
||
2562 |
// add OK/CANCEL buttons in a new panel |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2563 |
JPanel panel = new JPanel(); |
2 | 2564 |
panel.setLayout(new GridBagLayout()); |
2565 |
||
2566 |
// OK button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2567 |
JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
2 | 2568 |
okButton.addActionListener |
2569 |
(new ConfirmRemovePolicyEntryOKButtonListener(tool, tw, this)); |
|
2570 |
tw.addNewComponent(panel, okButton, CRPE_PANEL_OK, |
|
2571 |
0, 0, 1, 1, 0.0, 0.0, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2572 |
GridBagConstraints.VERTICAL, ToolWindow.LR_PADDING); |
2 | 2573 |
|
2574 |
// cancel button |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2575 |
JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2576 |
ActionListener cancelListener = new CancelButtonListener(this); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2577 |
cancelButton.addActionListener(cancelListener); |
2 | 2578 |
tw.addNewComponent(panel, cancelButton, CRPE_PANEL_CANCEL, |
2579 |
1, 0, 1, 1, 0.0, 0.0, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2580 |
GridBagConstraints.VERTICAL, ToolWindow.LR_PADDING); |
2 | 2581 |
|
2582 |
tw.addNewComponent(this, panel, CRPE_LABEL2 + 2 + perms.size(), |
|
2583 |
0, 3 + perms.size(), 2, 1, 0.0, 0.0, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2584 |
GridBagConstraints.VERTICAL, ToolWindow.TOP_BOTTOM_PADDING); |
2 | 2585 |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2586 |
getRootPane().setDefaultButton(okButton); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2587 |
getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2588 |
|
2 | 2589 |
pack(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2590 |
setLocationRelativeTo(tw); |
2 | 2591 |
setVisible(true); |
2592 |
} |
|
2593 |
||
2594 |
/** |
|
2595 |
* perform SAVE AS |
|
2596 |
*/ |
|
2597 |
void displaySaveAsDialog(int nextEvent) { |
|
2598 |
||
2599 |
// pop up a dialog box for the user to enter a filename. |
|
2600 |
FileDialog fd = new FileDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2601 |
(tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE); |
2 | 2602 |
fd.addWindowListener(new WindowAdapter() { |
2603 |
public void windowClosing(WindowEvent e) { |
|
2604 |
e.getWindow().setVisible(false); |
|
2605 |
} |
|
2606 |
}); |
|
2607 |
fd.setVisible(true); |
|
2608 |
||
2609 |
// see if the user hit cancel |
|
2610 |
if (fd.getFile() == null || |
|
2611 |
fd.getFile().equals("")) |
|
2612 |
return; |
|
2613 |
||
2614 |
// get the entered filename |
|
7532 | 2615 |
File saveAsFile = new File(fd.getDirectory(), fd.getFile()); |
2616 |
String filename = saveAsFile.getPath(); |
|
2 | 2617 |
fd.dispose(); |
2618 |
||
7532 | 2619 |
try { |
2620 |
// save the policy entries to a file |
|
2621 |
tool.savePolicy(filename); |
|
2622 |
||
2623 |
// display status |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2624 |
MessageFormat form = new MessageFormat(PolicyTool.getMessage |
7532 | 2625 |
("Policy.successfully.written.to.filename")); |
2626 |
Object[] source = {filename}; |
|
2627 |
tw.displayStatusDialog(null, form.format(source)); |
|
2628 |
||
2629 |
// display the new policy filename |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2630 |
JTextField newFilename = (JTextField)tw.getComponent |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2631 |
(ToolWindow.MW_FILENAME_TEXTFIELD); |
7532 | 2632 |
newFilename.setText(filename); |
2633 |
tw.setVisible(true); |
|
2634 |
||
2635 |
// now continue with the originally requested command |
|
2636 |
// (QUIT, NEW, or OPEN) |
|
2637 |
userSaveContinue(tool, tw, this, nextEvent); |
|
2638 |
||
2639 |
} catch (FileNotFoundException fnfe) { |
|
2640 |
if (filename == null || filename.equals("")) { |
|
2641 |
tw.displayErrorDialog(null, new FileNotFoundException |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2642 |
(PolicyTool.getMessage("null.filename"))); |
7532 | 2643 |
} else { |
2644 |
tw.displayErrorDialog(null, fnfe); |
|
2 | 2645 |
} |
7532 | 2646 |
} catch (Exception ee) { |
2647 |
tw.displayErrorDialog(null, ee); |
|
2 | 2648 |
} |
2649 |
} |
|
2650 |
||
2651 |
/** |
|
2652 |
* ask user if they want to save changes |
|
2653 |
*/ |
|
2654 |
void displayUserSave(int select) { |
|
2655 |
||
2656 |
if (tool.modified == true) { |
|
2657 |
||
2658 |
// find where the PolicyTool gui is |
|
2659 |
Point location = tw.getLocationOnScreen(); |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2660 |
//setBounds(location.x + 75, location.y + 100, 400, 150); |
2 | 2661 |
setLayout(new GridBagLayout()); |
2662 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2663 |
JLabel label = new JLabel |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2664 |
(PolicyTool.getMessage("Save.changes.")); |
2 | 2665 |
tw.addNewComponent(this, label, USC_LABEL, |
2666 |
0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2667 |
ToolWindow.L_TOP_BOTTOM_PADDING); |
2 | 2668 |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2669 |
JPanel panel = new JPanel(); |
2 | 2670 |
panel.setLayout(new GridBagLayout()); |
2671 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2672 |
JButton yesButton = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2673 |
ToolWindow.configureButton(yesButton, "Yes"); |
2 | 2674 |
yesButton.addActionListener |
2675 |
(new UserSaveYesButtonListener(this, tool, tw, select)); |
|
2676 |
tw.addNewComponent(panel, yesButton, USC_YES_BUTTON, |
|
2677 |
0, 0, 1, 1, 0.0, 0.0, |
|
2678 |
GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2679 |
ToolWindow.LR_BOTTOM_PADDING); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2680 |
JButton noButton = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2681 |
ToolWindow.configureButton(noButton, "No"); |
2 | 2682 |
noButton.addActionListener |
2683 |
(new UserSaveNoButtonListener(this, tool, tw, select)); |
|
2684 |
tw.addNewComponent(panel, noButton, USC_NO_BUTTON, |
|
2685 |
1, 0, 1, 1, 0.0, 0.0, |
|
2686 |
GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2687 |
ToolWindow.LR_BOTTOM_PADDING); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2688 |
JButton cancelButton = new JButton(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2689 |
ToolWindow.configureButton(cancelButton, "Cancel"); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2690 |
ActionListener cancelListener = new CancelButtonListener(this); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2691 |
cancelButton.addActionListener(cancelListener); |
2 | 2692 |
tw.addNewComponent(panel, cancelButton, USC_CANCEL_BUTTON, |
2693 |
2, 0, 1, 1, 0.0, 0.0, |
|
2694 |
GridBagConstraints.VERTICAL, |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2695 |
ToolWindow.LR_BOTTOM_PADDING); |
2 | 2696 |
|
2697 |
tw.addNewComponent(this, panel, USC_PANEL, |
|
2698 |
0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
|
2699 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2700 |
getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2701 |
|
2 | 2702 |
pack(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2703 |
setLocationRelativeTo(tw); |
2 | 2704 |
setVisible(true); |
2705 |
} else { |
|
2706 |
// just do the original request (QUIT, NEW, or OPEN) |
|
2707 |
userSaveContinue(tool, tw, this, select); |
|
2708 |
} |
|
2709 |
} |
|
2710 |
||
2711 |
/** |
|
2712 |
* when the user sees the 'YES', 'NO', 'CANCEL' buttons on the |
|
2713 |
* displayUserSave dialog, and the click on one of them, |
|
2714 |
* we need to continue the originally requested action |
|
2715 |
* (either QUITting, opening NEW policy file, or OPENing an existing |
|
2716 |
* policy file. do that now. |
|
2717 |
*/ |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2718 |
@SuppressWarnings("fallthrough") |
2 | 2719 |
void userSaveContinue(PolicyTool tool, ToolWindow tw, |
2720 |
ToolDialog us, int select) { |
|
2721 |
||
2722 |
// now either QUIT, open a NEW policy file, or OPEN an existing policy |
|
2723 |
switch(select) { |
|
2724 |
case ToolDialog.QUIT: |
|
2725 |
||
2726 |
tw.setVisible(false); |
|
2727 |
tw.dispose(); |
|
2728 |
System.exit(0); |
|
2729 |
||
2730 |
case ToolDialog.NEW: |
|
2731 |
||
2732 |
try { |
|
2733 |
tool.openPolicy(null); |
|
2734 |
} catch (Exception ee) { |
|
2735 |
tool.modified = false; |
|
2736 |
tw.displayErrorDialog(null, ee); |
|
2737 |
} |
|
2738 |
||
2739 |
// display the policy entries via the policy list textarea |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2740 |
JList<String> list = new JList<>(new DefaultListModel<>()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2741 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2742 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2743 |
list.addMouseListener(new PolicyListListener(tool, tw)); |
2 | 2744 |
tw.replacePolicyList(list); |
2745 |
||
2746 |
// display null policy filename and keystore |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2747 |
JTextField newFilename = (JTextField)tw.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2748 |
ToolWindow.MW_FILENAME_TEXTFIELD); |
2 | 2749 |
newFilename.setText(""); |
2750 |
tw.setVisible(true); |
|
2751 |
break; |
|
2752 |
||
2753 |
case ToolDialog.OPEN: |
|
2754 |
||
2755 |
// pop up a dialog box for the user to enter a filename. |
|
2756 |
FileDialog fd = new FileDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2757 |
(tw, PolicyTool.getMessage("Open"), FileDialog.LOAD); |
2 | 2758 |
fd.addWindowListener(new WindowAdapter() { |
2759 |
public void windowClosing(WindowEvent e) { |
|
2760 |
e.getWindow().setVisible(false); |
|
2761 |
} |
|
2762 |
}); |
|
2763 |
fd.setVisible(true); |
|
2764 |
||
2765 |
// see if the user hit 'cancel' |
|
2766 |
if (fd.getFile() == null || |
|
2767 |
fd.getFile().equals("")) |
|
2768 |
return; |
|
2769 |
||
2770 |
// get the entered filename |
|
7532 | 2771 |
String policyFile = new File(fd.getDirectory(), fd.getFile()).getPath(); |
2 | 2772 |
|
2773 |
try { |
|
2774 |
// open the policy file |
|
2775 |
tool.openPolicy(policyFile); |
|
2776 |
||
2777 |
// display the policy entries via the policy list textarea |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2778 |
DefaultListModel<String> listModel = new DefaultListModel<>(); |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2779 |
list = new JList<>(listModel); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2780 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2781 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2782 |
list.addMouseListener(new PolicyListListener(tool, tw)); |
2 | 2783 |
PolicyEntry entries[] = tool.getEntry(); |
2784 |
if (entries != null) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2785 |
for (int i = 0; i < entries.length; i++) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2786 |
listModel.addElement(entries[i].headerToString()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2787 |
} |
2 | 2788 |
} |
2789 |
tw.replacePolicyList(list); |
|
2790 |
tool.modified = false; |
|
2791 |
||
2792 |
// display the new policy filename |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2793 |
newFilename = (JTextField)tw.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2794 |
ToolWindow.MW_FILENAME_TEXTFIELD); |
2 | 2795 |
newFilename.setText(policyFile); |
2796 |
tw.setVisible(true); |
|
2797 |
||
2798 |
// inform user of warnings |
|
2799 |
if (tool.newWarning == true) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2800 |
tw.displayStatusDialog(null, PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
2801 |
("Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.")); |
2 | 2802 |
} |
2803 |
||
2804 |
} catch (Exception e) { |
|
2805 |
// add blank policy listing |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2806 |
list = new JList<>(new DefaultListModel<>()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2807 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2808 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2809 |
list.addMouseListener(new PolicyListListener(tool, tw)); |
2 | 2810 |
tw.replacePolicyList(list); |
2811 |
tool.setPolicyFileName(null); |
|
2812 |
tool.modified = false; |
|
2813 |
||
2814 |
// display a null policy filename |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2815 |
newFilename = (JTextField)tw.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
2816 |
ToolWindow.MW_FILENAME_TEXTFIELD); |
2 | 2817 |
newFilename.setText(""); |
2818 |
tw.setVisible(true); |
|
2819 |
||
2820 |
// display the error |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2821 |
MessageFormat form = new MessageFormat(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
2822 |
("Could.not.open.policy.file.policyFile.e.toString.")); |
2 | 2823 |
Object[] source = {policyFile, e.toString()}; |
2824 |
tw.displayErrorDialog(null, form.format(source)); |
|
2825 |
} |
|
2826 |
break; |
|
2827 |
} |
|
2828 |
} |
|
2829 |
||
2830 |
/** |
|
2831 |
* Return a Menu list of names for a given permission |
|
2832 |
* |
|
2833 |
* If inputPerm's TARGETS are null, then this means TARGETS are |
|
2834 |
* not allowed to be entered (and the TextField is set to be |
|
2835 |
* non-editable). |
|
2836 |
* |
|
2837 |
* If TARGETS are valid but there are no standard ones |
|
2838 |
* (user must enter them by hand) then the TARGETS array may be empty |
|
2839 |
* (and of course non-null). |
|
2840 |
*/ |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2841 |
void setPermissionNames(Perm inputPerm, JComboBox<String> names, JTextField field) { |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2842 |
names.removeAllItems(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2843 |
names.addItem(PERM_NAME); |
2 | 2844 |
|
2845 |
if (inputPerm == null) { |
|
2846 |
// custom permission |
|
2847 |
field.setEditable(true); |
|
2848 |
} else if (inputPerm.TARGETS == null) { |
|
2849 |
// standard permission with no targets |
|
2850 |
field.setEditable(false); |
|
2851 |
} else { |
|
2852 |
// standard permission with standard targets |
|
2853 |
field.setEditable(true); |
|
2854 |
for (int i = 0; i < inputPerm.TARGETS.length; i++) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2855 |
names.addItem(inputPerm.TARGETS[i]); |
2 | 2856 |
} |
2857 |
} |
|
2858 |
} |
|
2859 |
||
2860 |
/** |
|
2861 |
* Return a Menu list of actions for a given permission |
|
2862 |
* |
|
2863 |
* If inputPerm's ACTIONS are null, then this means ACTIONS are |
|
2864 |
* not allowed to be entered (and the TextField is set to be |
|
2865 |
* non-editable). This is typically true for BasicPermissions. |
|
2866 |
* |
|
2867 |
* If ACTIONS are valid but there are no standard ones |
|
2868 |
* (user must enter them by hand) then the ACTIONS array may be empty |
|
2869 |
* (and of course non-null). |
|
2870 |
*/ |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
2871 |
void setPermissionActions(Perm inputPerm, JComboBox<String> actions, JTextField field) { |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2872 |
actions.removeAllItems(); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2873 |
actions.addItem(PERM_ACTIONS); |
2 | 2874 |
|
2875 |
if (inputPerm == null) { |
|
2876 |
// custom permission |
|
2877 |
field.setEditable(true); |
|
2878 |
} else if (inputPerm.ACTIONS == null) { |
|
2879 |
// standard permission with no actions |
|
2880 |
field.setEditable(false); |
|
2881 |
} else { |
|
2882 |
// standard permission with standard actions |
|
2883 |
field.setEditable(true); |
|
2884 |
for (int i = 0; i < inputPerm.ACTIONS.length; i++) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2885 |
actions.addItem(inputPerm.ACTIONS[i]); |
2 | 2886 |
} |
2887 |
} |
|
2888 |
} |
|
2889 |
||
2890 |
static String PermissionEntryToUserFriendlyString(PolicyParser.PermissionEntry pppe) { |
|
2891 |
String result = pppe.permission; |
|
2892 |
if (pppe.name != null) { |
|
2893 |
result += " " + pppe.name; |
|
2894 |
} |
|
2895 |
if (pppe.action != null) { |
|
2896 |
result += ", \"" + pppe.action + "\""; |
|
2897 |
} |
|
2898 |
if (pppe.signedBy != null) { |
|
2899 |
result += ", signedBy " + pppe.signedBy; |
|
2900 |
} |
|
2901 |
return result; |
|
2902 |
} |
|
2903 |
||
2904 |
static String PrincipalEntryToUserFriendlyString(PolicyParser.PrincipalEntry pppe) { |
|
2905 |
StringWriter sw = new StringWriter(); |
|
2906 |
PrintWriter pw = new PrintWriter(sw); |
|
2907 |
pppe.write(pw); |
|
2908 |
return sw.toString(); |
|
2909 |
} |
|
2910 |
} |
|
2911 |
||
2912 |
/** |
|
2913 |
* Event handler for the PolicyTool window |
|
2914 |
*/ |
|
2915 |
class ToolWindowListener implements WindowListener { |
|
2916 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2917 |
private PolicyTool tool; |
2 | 2918 |
private ToolWindow tw; |
2919 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2920 |
ToolWindowListener(PolicyTool tool, ToolWindow tw) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2921 |
this.tool = tool; |
2 | 2922 |
this.tw = tw; |
2923 |
} |
|
2924 |
||
2925 |
public void windowOpened(WindowEvent we) { |
|
2926 |
} |
|
2927 |
||
2928 |
public void windowClosing(WindowEvent we) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2929 |
// Closing the window acts the same as choosing Menu->Exit. |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2930 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2931 |
// ask user if they want to save changes |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2932 |
ToolDialog td = new ToolDialog(PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2933 |
td.displayUserSave(ToolDialog.QUIT); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2934 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2935 |
// the above method will perform the QUIT as long as the |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2936 |
// user does not CANCEL the request |
2 | 2937 |
} |
2938 |
||
2939 |
public void windowClosed(WindowEvent we) { |
|
2940 |
System.exit(0); |
|
2941 |
} |
|
2942 |
||
2943 |
public void windowIconified(WindowEvent we) { |
|
2944 |
} |
|
2945 |
||
2946 |
public void windowDeiconified(WindowEvent we) { |
|
2947 |
} |
|
2948 |
||
2949 |
public void windowActivated(WindowEvent we) { |
|
2950 |
} |
|
2951 |
||
2952 |
public void windowDeactivated(WindowEvent we) { |
|
2953 |
} |
|
2954 |
} |
|
2955 |
||
2956 |
/** |
|
2957 |
* Event handler for the Policy List |
|
2958 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2959 |
class PolicyListListener extends MouseAdapter implements ActionListener { |
2 | 2960 |
|
2961 |
private PolicyTool tool; |
|
2962 |
private ToolWindow tw; |
|
2963 |
||
2964 |
PolicyListListener(PolicyTool tool, ToolWindow tw) { |
|
2965 |
this.tool = tool; |
|
2966 |
this.tw = tw; |
|
2967 |
||
2968 |
} |
|
2969 |
||
2970 |
public void actionPerformed(ActionEvent e) { |
|
2971 |
||
2972 |
// display the permission list for a policy entry |
|
2973 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2974 |
(PolicyTool.getMessage("Policy.Entry"), tool, tw, true); |
2 | 2975 |
td.displayPolicyEntryDialog(true); |
2976 |
} |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2977 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2978 |
public void mouseClicked(MouseEvent evt) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2979 |
if (evt.getClickCount() == 2) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2980 |
actionPerformed(null); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2981 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
2982 |
} |
2 | 2983 |
} |
2984 |
||
2985 |
/** |
|
2986 |
* Event handler for the File Menu |
|
2987 |
*/ |
|
2988 |
class FileMenuListener implements ActionListener { |
|
2989 |
||
2990 |
private PolicyTool tool; |
|
2991 |
private ToolWindow tw; |
|
2992 |
||
2993 |
FileMenuListener(PolicyTool tool, ToolWindow tw) { |
|
2994 |
this.tool = tool; |
|
2995 |
this.tw = tw; |
|
2996 |
} |
|
2997 |
||
2998 |
public void actionPerformed(ActionEvent e) { |
|
2999 |
||
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3000 |
if (PolicyTool.collator.compare(e.getActionCommand(), |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3001 |
ToolWindow.QUIT) == 0) { |
2 | 3002 |
|
3003 |
// ask user if they want to save changes |
|
3004 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3005 |
(PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3006 |
td.displayUserSave(ToolDialog.QUIT); |
2 | 3007 |
|
3008 |
// the above method will perform the QUIT as long as the |
|
3009 |
// user does not CANCEL the request |
|
3010 |
||
3011 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3012 |
ToolWindow.NEW_POLICY_FILE) == 0) { |
2 | 3013 |
|
3014 |
// ask user if they want to save changes |
|
3015 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3016 |
(PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3017 |
td.displayUserSave(ToolDialog.NEW); |
2 | 3018 |
|
3019 |
// the above method will perform the NEW as long as the |
|
3020 |
// user does not CANCEL the request |
|
3021 |
||
3022 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3023 |
ToolWindow.OPEN_POLICY_FILE) == 0) { |
2 | 3024 |
|
3025 |
// ask user if they want to save changes |
|
3026 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3027 |
(PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3028 |
td.displayUserSave(ToolDialog.OPEN); |
2 | 3029 |
|
3030 |
// the above method will perform the OPEN as long as the |
|
3031 |
// user does not CANCEL the request |
|
3032 |
||
3033 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3034 |
ToolWindow.SAVE_POLICY_FILE) == 0) { |
2 | 3035 |
|
3036 |
// get the previously entered filename |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3037 |
String filename = ((JTextField)tw.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3038 |
ToolWindow.MW_FILENAME_TEXTFIELD)).getText(); |
2 | 3039 |
|
3040 |
// if there is no filename, do a SAVE_AS |
|
3041 |
if (filename == null || filename.length() == 0) { |
|
3042 |
// user wants to SAVE AS |
|
3043 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3044 |
(PolicyTool.getMessage("Save.As"), tool, tw, true); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3045 |
td.displaySaveAsDialog(ToolDialog.NOACTION); |
2 | 3046 |
} else { |
3047 |
try { |
|
3048 |
// save the policy entries to a file |
|
3049 |
tool.savePolicy(filename); |
|
3050 |
||
3051 |
// display status |
|
3052 |
MessageFormat form = new MessageFormat |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3053 |
(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3054 |
("Policy.successfully.written.to.filename")); |
2 | 3055 |
Object[] source = {filename}; |
3056 |
tw.displayStatusDialog(null, form.format(source)); |
|
3057 |
} catch (FileNotFoundException fnfe) { |
|
3058 |
if (filename == null || filename.equals("")) { |
|
3059 |
tw.displayErrorDialog(null, new FileNotFoundException |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3060 |
(PolicyTool.getMessage("null.filename"))); |
2 | 3061 |
} else { |
3062 |
tw.displayErrorDialog(null, fnfe); |
|
3063 |
} |
|
3064 |
} catch (Exception ee) { |
|
3065 |
tw.displayErrorDialog(null, ee); |
|
3066 |
} |
|
3067 |
} |
|
3068 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3069 |
ToolWindow.SAVE_AS_POLICY_FILE) == 0) { |
2 | 3070 |
|
3071 |
// user wants to SAVE AS |
|
3072 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3073 |
(PolicyTool.getMessage("Save.As"), tool, tw, true); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3074 |
td.displaySaveAsDialog(ToolDialog.NOACTION); |
2 | 3075 |
|
3076 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3077 |
ToolWindow.VIEW_WARNINGS) == 0) { |
2 | 3078 |
tw.displayWarningLog(null); |
3079 |
} |
|
3080 |
} |
|
3081 |
} |
|
3082 |
||
3083 |
/** |
|
3084 |
* Event handler for the main window buttons and Edit Menu |
|
3085 |
*/ |
|
3086 |
class MainWindowListener implements ActionListener { |
|
3087 |
||
3088 |
private PolicyTool tool; |
|
3089 |
private ToolWindow tw; |
|
3090 |
||
3091 |
MainWindowListener(PolicyTool tool, ToolWindow tw) { |
|
3092 |
this.tool = tool; |
|
3093 |
this.tw = tw; |
|
3094 |
} |
|
3095 |
||
3096 |
public void actionPerformed(ActionEvent e) { |
|
3097 |
||
3098 |
if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3099 |
ToolWindow.ADD_POLICY_ENTRY) == 0) { |
2 | 3100 |
|
3101 |
// display a dialog box for the user to enter policy info |
|
3102 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3103 |
(PolicyTool.getMessage("Policy.Entry"), tool, tw, true); |
2 | 3104 |
td.displayPolicyEntryDialog(false); |
3105 |
||
3106 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3107 |
ToolWindow.REMOVE_POLICY_ENTRY) == 0) { |
2 | 3108 |
|
3109 |
// get the selected entry |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3110 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3111 |
JList<String> list = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2 | 3112 |
int index = list.getSelectedIndex(); |
3113 |
if (index < 0) { |
|
3114 |
tw.displayErrorDialog(null, new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3115 |
(PolicyTool.getMessage("No.Policy.Entry.selected"))); |
2 | 3116 |
return; |
3117 |
} |
|
3118 |
||
3119 |
// ask the user if they really want to remove the policy entry |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3120 |
ToolDialog td = new ToolDialog(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3121 |
("Remove.Policy.Entry"), tool, tw, true); |
2 | 3122 |
td.displayConfirmRemovePolicyEntry(); |
3123 |
||
3124 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3125 |
ToolWindow.EDIT_POLICY_ENTRY) == 0) { |
2 | 3126 |
|
3127 |
// get the selected entry |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3128 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3129 |
JList<String> list = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2 | 3130 |
int index = list.getSelectedIndex(); |
3131 |
if (index < 0) { |
|
3132 |
tw.displayErrorDialog(null, new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3133 |
(PolicyTool.getMessage("No.Policy.Entry.selected"))); |
2 | 3134 |
return; |
3135 |
} |
|
3136 |
||
3137 |
// display the permission list for a policy entry |
|
3138 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3139 |
(PolicyTool.getMessage("Policy.Entry"), tool, tw, true); |
2 | 3140 |
td.displayPolicyEntryDialog(true); |
3141 |
||
3142 |
} else if (PolicyTool.collator.compare(e.getActionCommand(), |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3143 |
ToolWindow.EDIT_KEYSTORE) == 0) { |
2 | 3144 |
|
3145 |
// display a dialog box for the user to enter keystore info |
|
3146 |
ToolDialog td = new ToolDialog |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3147 |
(PolicyTool.getMessage("KeyStore"), tool, tw, true); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3148 |
td.keyStoreDialog(ToolDialog.EDIT_KEYSTORE); |
2 | 3149 |
} |
3150 |
} |
|
3151 |
} |
|
3152 |
||
3153 |
/** |
|
3154 |
* Event handler for AddEntryDoneButton button |
|
3155 |
* |
|
3156 |
* -- if edit is TRUE, then we are EDITing an existing PolicyEntry |
|
3157 |
* and we need to update both the policy and the GUI listing. |
|
3158 |
* if edit is FALSE, then we are ADDing a new PolicyEntry, |
|
3159 |
* so we only need to update the GUI listing. |
|
3160 |
*/ |
|
3161 |
class AddEntryDoneButtonListener implements ActionListener { |
|
3162 |
||
3163 |
private PolicyTool tool; |
|
3164 |
private ToolWindow tw; |
|
3165 |
private ToolDialog td; |
|
3166 |
private boolean edit; |
|
3167 |
||
3168 |
AddEntryDoneButtonListener(PolicyTool tool, ToolWindow tw, |
|
3169 |
ToolDialog td, boolean edit) { |
|
3170 |
this.tool = tool; |
|
3171 |
this.tw = tw; |
|
3172 |
this.td = td; |
|
3173 |
this.edit = edit; |
|
3174 |
} |
|
3175 |
||
3176 |
public void actionPerformed(ActionEvent e) { |
|
3177 |
||
3178 |
try { |
|
3179 |
// get a PolicyEntry object from the dialog policy info |
|
3180 |
PolicyEntry newEntry = td.getPolicyEntryFromDialog(); |
|
3181 |
PolicyParser.GrantEntry newGe = newEntry.getGrantEntry(); |
|
3182 |
||
3183 |
// see if all the signers have public keys |
|
3184 |
if (newGe.signedBy != null) { |
|
3185 |
String signers[] = tool.parseSigners(newGe.signedBy); |
|
3186 |
for (int i = 0; i < signers.length; i++) { |
|
3187 |
PublicKey pubKey = tool.getPublicKeyAlias(signers[i]); |
|
3188 |
if (pubKey == null) { |
|
3189 |
MessageFormat form = new MessageFormat |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3190 |
(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3191 |
("Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.")); |
2 | 3192 |
Object[] source = {signers[i]}; |
3193 |
tool.warnings.addElement(form.format(source)); |
|
3194 |
tw.displayStatusDialog(td, form.format(source)); |
|
3195 |
} |
|
3196 |
} |
|
3197 |
} |
|
3198 |
||
3199 |
// add the entry |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3200 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3201 |
JList<String> policyList = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2 | 3202 |
if (edit) { |
3203 |
int listIndex = policyList.getSelectedIndex(); |
|
3204 |
tool.addEntry(newEntry, listIndex); |
|
3205 |
String newCodeBaseStr = newEntry.headerToString(); |
|
3206 |
if (PolicyTool.collator.compare |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3207 |
(newCodeBaseStr, policyList.getModel().getElementAt(listIndex)) != 0) |
2 | 3208 |
tool.modified = true; |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3209 |
((DefaultListModel<String>)policyList.getModel()).set(listIndex, newCodeBaseStr); |
2 | 3210 |
} else { |
3211 |
tool.addEntry(newEntry, -1); |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3212 |
((DefaultListModel<String>)policyList.getModel()).addElement(newEntry.headerToString()); |
2 | 3213 |
tool.modified = true; |
3214 |
} |
|
3215 |
td.setVisible(false); |
|
3216 |
td.dispose(); |
|
3217 |
||
3218 |
} catch (Exception eee) { |
|
3219 |
tw.displayErrorDialog(td, eee); |
|
3220 |
} |
|
3221 |
} |
|
3222 |
} |
|
3223 |
||
3224 |
/** |
|
3225 |
* Event handler for ChangeKeyStoreOKButton button |
|
3226 |
*/ |
|
3227 |
class ChangeKeyStoreOKButtonListener implements ActionListener { |
|
3228 |
||
3229 |
private PolicyTool tool; |
|
3230 |
private ToolWindow tw; |
|
3231 |
private ToolDialog td; |
|
3232 |
||
3233 |
ChangeKeyStoreOKButtonListener(PolicyTool tool, ToolWindow tw, |
|
3234 |
ToolDialog td) { |
|
3235 |
this.tool = tool; |
|
3236 |
this.tw = tw; |
|
3237 |
this.td = td; |
|
3238 |
} |
|
3239 |
||
3240 |
public void actionPerformed(ActionEvent e) { |
|
3241 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3242 |
String URLString = ((JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3243 |
ToolDialog.KSD_NAME_TEXTFIELD)).getText().trim(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3244 |
String type = ((JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3245 |
ToolDialog.KSD_TYPE_TEXTFIELD)).getText().trim(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3246 |
String provider = ((JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3247 |
ToolDialog.KSD_PROVIDER_TEXTFIELD)).getText().trim(); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3248 |
String pwdURL = ((JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3249 |
ToolDialog.KSD_PWD_URL_TEXTFIELD)).getText().trim(); |
2 | 3250 |
|
3251 |
try { |
|
3252 |
tool.openKeyStore |
|
3253 |
((URLString.length() == 0 ? null : URLString), |
|
3254 |
(type.length() == 0 ? null : type), |
|
3255 |
(provider.length() == 0 ? null : provider), |
|
3256 |
(pwdURL.length() == 0 ? null : pwdURL)); |
|
3257 |
tool.modified = true; |
|
3258 |
} catch (Exception ex) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3259 |
MessageFormat form = new MessageFormat(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3260 |
("Unable.to.open.KeyStore.ex.toString.")); |
2 | 3261 |
Object[] source = {ex.toString()}; |
3262 |
tw.displayErrorDialog(td, form.format(source)); |
|
3263 |
return; |
|
3264 |
} |
|
3265 |
||
3266 |
td.dispose(); |
|
3267 |
} |
|
3268 |
} |
|
3269 |
||
3270 |
/** |
|
3271 |
* Event handler for AddPrinButton button |
|
3272 |
*/ |
|
3273 |
class AddPrinButtonListener implements ActionListener { |
|
3274 |
||
3275 |
private PolicyTool tool; |
|
3276 |
private ToolWindow tw; |
|
3277 |
private ToolDialog td; |
|
3278 |
private boolean editPolicyEntry; |
|
3279 |
||
3280 |
AddPrinButtonListener(PolicyTool tool, ToolWindow tw, |
|
3281 |
ToolDialog td, boolean editPolicyEntry) { |
|
3282 |
this.tool = tool; |
|
3283 |
this.tw = tw; |
|
3284 |
this.td = td; |
|
3285 |
this.editPolicyEntry = editPolicyEntry; |
|
3286 |
} |
|
3287 |
||
3288 |
public void actionPerformed(ActionEvent e) { |
|
3289 |
||
3290 |
// display a dialog box for the user to enter principal info |
|
3291 |
td.displayPrincipalDialog(editPolicyEntry, false); |
|
3292 |
} |
|
3293 |
} |
|
3294 |
||
3295 |
/** |
|
3296 |
* Event handler for AddPermButton button |
|
3297 |
*/ |
|
3298 |
class AddPermButtonListener implements ActionListener { |
|
3299 |
||
3300 |
private PolicyTool tool; |
|
3301 |
private ToolWindow tw; |
|
3302 |
private ToolDialog td; |
|
3303 |
private boolean editPolicyEntry; |
|
3304 |
||
3305 |
AddPermButtonListener(PolicyTool tool, ToolWindow tw, |
|
3306 |
ToolDialog td, boolean editPolicyEntry) { |
|
3307 |
this.tool = tool; |
|
3308 |
this.tw = tw; |
|
3309 |
this.td = td; |
|
3310 |
this.editPolicyEntry = editPolicyEntry; |
|
3311 |
} |
|
3312 |
||
3313 |
public void actionPerformed(ActionEvent e) { |
|
3314 |
||
3315 |
// display a dialog box for the user to enter permission info |
|
3316 |
td.displayPermissionDialog(editPolicyEntry, false); |
|
3317 |
} |
|
3318 |
} |
|
3319 |
||
3320 |
/** |
|
3321 |
* Event handler for AddPrinOKButton button |
|
3322 |
*/ |
|
3323 |
class NewPolicyPrinOKButtonListener implements ActionListener { |
|
3324 |
||
3325 |
private PolicyTool tool; |
|
3326 |
private ToolWindow tw; |
|
3327 |
private ToolDialog listDialog; |
|
3328 |
private ToolDialog infoDialog; |
|
3329 |
private boolean edit; |
|
3330 |
||
3331 |
NewPolicyPrinOKButtonListener(PolicyTool tool, |
|
3332 |
ToolWindow tw, |
|
3333 |
ToolDialog listDialog, |
|
3334 |
ToolDialog infoDialog, |
|
3335 |
boolean edit) { |
|
3336 |
this.tool = tool; |
|
3337 |
this.tw = tw; |
|
3338 |
this.listDialog = listDialog; |
|
3339 |
this.infoDialog = infoDialog; |
|
3340 |
this.edit = edit; |
|
3341 |
} |
|
3342 |
||
3343 |
public void actionPerformed(ActionEvent e) { |
|
3344 |
||
3345 |
try { |
|
3346 |
// read in the new principal info from Dialog Box |
|
3347 |
PolicyParser.PrincipalEntry pppe = |
|
3348 |
infoDialog.getPrinFromDialog(); |
|
3349 |
if (pppe != null) { |
|
3350 |
try { |
|
3351 |
tool.verifyPrincipal(pppe.getPrincipalClass(), |
|
3352 |
pppe.getPrincipalName()); |
|
3353 |
} catch (ClassNotFoundException cnfe) { |
|
3354 |
MessageFormat form = new MessageFormat |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3355 |
(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3356 |
("Warning.Class.not.found.class")); |
2 | 3357 |
Object[] source = {pppe.getPrincipalClass()}; |
3358 |
tool.warnings.addElement(form.format(source)); |
|
3359 |
tw.displayStatusDialog(infoDialog, form.format(source)); |
|
3360 |
} |
|
3361 |
||
3362 |
// add the principal to the GUI principal list |
|
3363 |
TaggedList prinList = |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3364 |
(TaggedList)listDialog.getComponent(ToolDialog.PE_PRIN_LIST); |
2 | 3365 |
|
3366 |
String prinString = ToolDialog.PrincipalEntryToUserFriendlyString(pppe); |
|
3367 |
if (edit) { |
|
3368 |
// if editing, replace the original principal |
|
3369 |
int index = prinList.getSelectedIndex(); |
|
3370 |
prinList.replaceTaggedItem(prinString, pppe, index); |
|
3371 |
} else { |
|
3372 |
// if adding, just add it to the end |
|
3373 |
prinList.addTaggedItem(prinString, pppe); |
|
3374 |
} |
|
3375 |
} |
|
3376 |
infoDialog.dispose(); |
|
3377 |
} catch (Exception ee) { |
|
3378 |
tw.displayErrorDialog(infoDialog, ee); |
|
3379 |
} |
|
3380 |
} |
|
3381 |
} |
|
3382 |
||
3383 |
/** |
|
3384 |
* Event handler for AddPermOKButton button |
|
3385 |
*/ |
|
3386 |
class NewPolicyPermOKButtonListener implements ActionListener { |
|
3387 |
||
3388 |
private PolicyTool tool; |
|
3389 |
private ToolWindow tw; |
|
3390 |
private ToolDialog listDialog; |
|
3391 |
private ToolDialog infoDialog; |
|
3392 |
private boolean edit; |
|
3393 |
||
3394 |
NewPolicyPermOKButtonListener(PolicyTool tool, |
|
3395 |
ToolWindow tw, |
|
3396 |
ToolDialog listDialog, |
|
3397 |
ToolDialog infoDialog, |
|
3398 |
boolean edit) { |
|
3399 |
this.tool = tool; |
|
3400 |
this.tw = tw; |
|
3401 |
this.listDialog = listDialog; |
|
3402 |
this.infoDialog = infoDialog; |
|
3403 |
this.edit = edit; |
|
3404 |
} |
|
3405 |
||
3406 |
public void actionPerformed(ActionEvent e) { |
|
3407 |
||
3408 |
try { |
|
3409 |
// read in the new permission info from Dialog Box |
|
3410 |
PolicyParser.PermissionEntry pppe = |
|
3411 |
infoDialog.getPermFromDialog(); |
|
3412 |
||
3413 |
try { |
|
3414 |
tool.verifyPermission(pppe.permission, pppe.name, pppe.action); |
|
3415 |
} catch (ClassNotFoundException cnfe) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3416 |
MessageFormat form = new MessageFormat(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3417 |
("Warning.Class.not.found.class")); |
2 | 3418 |
Object[] source = {pppe.permission}; |
3419 |
tool.warnings.addElement(form.format(source)); |
|
3420 |
tw.displayStatusDialog(infoDialog, form.format(source)); |
|
3421 |
} |
|
3422 |
||
3423 |
// add the permission to the GUI permission list |
|
3424 |
TaggedList permList = |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3425 |
(TaggedList)listDialog.getComponent(ToolDialog.PE_PERM_LIST); |
2 | 3426 |
|
3427 |
String permString = ToolDialog.PermissionEntryToUserFriendlyString(pppe); |
|
3428 |
if (edit) { |
|
3429 |
// if editing, replace the original permission |
|
3430 |
int which = permList.getSelectedIndex(); |
|
3431 |
permList.replaceTaggedItem(permString, pppe, which); |
|
3432 |
} else { |
|
3433 |
// if adding, just add it to the end |
|
3434 |
permList.addTaggedItem(permString, pppe); |
|
3435 |
} |
|
3436 |
infoDialog.dispose(); |
|
3437 |
||
3438 |
} catch (InvocationTargetException ite) { |
|
3439 |
tw.displayErrorDialog(infoDialog, ite.getTargetException()); |
|
3440 |
} catch (Exception ee) { |
|
3441 |
tw.displayErrorDialog(infoDialog, ee); |
|
3442 |
} |
|
3443 |
} |
|
3444 |
} |
|
3445 |
||
3446 |
/** |
|
3447 |
* Event handler for RemovePrinButton button |
|
3448 |
*/ |
|
3449 |
class RemovePrinButtonListener implements ActionListener { |
|
3450 |
||
3451 |
private PolicyTool tool; |
|
3452 |
private ToolWindow tw; |
|
3453 |
private ToolDialog td; |
|
3454 |
private boolean edit; |
|
3455 |
||
3456 |
RemovePrinButtonListener(PolicyTool tool, ToolWindow tw, |
|
3457 |
ToolDialog td, boolean edit) { |
|
3458 |
this.tool = tool; |
|
3459 |
this.tw = tw; |
|
3460 |
this.td = td; |
|
3461 |
this.edit = edit; |
|
3462 |
} |
|
3463 |
||
3464 |
public void actionPerformed(ActionEvent e) { |
|
3465 |
||
3466 |
// get the Principal selected from the Principal List |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3467 |
TaggedList prinList = (TaggedList)td.getComponent( |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3468 |
ToolDialog.PE_PRIN_LIST); |
2 | 3469 |
int prinIndex = prinList.getSelectedIndex(); |
3470 |
||
3471 |
if (prinIndex < 0) { |
|
3472 |
tw.displayErrorDialog(td, new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3473 |
(PolicyTool.getMessage("No.principal.selected"))); |
2 | 3474 |
return; |
3475 |
} |
|
3476 |
// remove the principal from the display |
|
3477 |
prinList.removeTaggedItem(prinIndex); |
|
3478 |
} |
|
3479 |
} |
|
3480 |
||
3481 |
/** |
|
3482 |
* Event handler for RemovePermButton button |
|
3483 |
*/ |
|
3484 |
class RemovePermButtonListener implements ActionListener { |
|
3485 |
||
3486 |
private PolicyTool tool; |
|
3487 |
private ToolWindow tw; |
|
3488 |
private ToolDialog td; |
|
3489 |
private boolean edit; |
|
3490 |
||
3491 |
RemovePermButtonListener(PolicyTool tool, ToolWindow tw, |
|
3492 |
ToolDialog td, boolean edit) { |
|
3493 |
this.tool = tool; |
|
3494 |
this.tw = tw; |
|
3495 |
this.td = td; |
|
3496 |
this.edit = edit; |
|
3497 |
} |
|
3498 |
||
3499 |
public void actionPerformed(ActionEvent e) { |
|
3500 |
||
3501 |
// get the Permission selected from the Permission List |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3502 |
TaggedList permList = (TaggedList)td.getComponent( |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3503 |
ToolDialog.PE_PERM_LIST); |
2 | 3504 |
int permIndex = permList.getSelectedIndex(); |
3505 |
||
3506 |
if (permIndex < 0) { |
|
3507 |
tw.displayErrorDialog(td, new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3508 |
(PolicyTool.getMessage("No.permission.selected"))); |
2 | 3509 |
return; |
3510 |
} |
|
3511 |
// remove the permission from the display |
|
3512 |
permList.removeTaggedItem(permIndex); |
|
3513 |
||
3514 |
} |
|
3515 |
} |
|
3516 |
||
3517 |
/** |
|
3518 |
* Event handler for Edit Principal button |
|
3519 |
* |
|
3520 |
* We need the editPolicyEntry boolean to tell us if the user is |
|
3521 |
* adding a new PolicyEntry at this time, or editing an existing entry. |
|
3522 |
* If the user is adding a new PolicyEntry, we ONLY update the |
|
3523 |
* GUI listing. If the user is editing an existing PolicyEntry, we |
|
3524 |
* update both the GUI listing and the actual PolicyEntry. |
|
3525 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3526 |
class EditPrinButtonListener extends MouseAdapter implements ActionListener { |
2 | 3527 |
|
3528 |
private PolicyTool tool; |
|
3529 |
private ToolWindow tw; |
|
3530 |
private ToolDialog td; |
|
3531 |
private boolean editPolicyEntry; |
|
3532 |
||
3533 |
EditPrinButtonListener(PolicyTool tool, ToolWindow tw, |
|
3534 |
ToolDialog td, boolean editPolicyEntry) { |
|
3535 |
this.tool = tool; |
|
3536 |
this.tw = tw; |
|
3537 |
this.td = td; |
|
3538 |
this.editPolicyEntry = editPolicyEntry; |
|
3539 |
} |
|
3540 |
||
3541 |
public void actionPerformed(ActionEvent e) { |
|
3542 |
||
3543 |
// get the Principal selected from the Principal List |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3544 |
TaggedList list = (TaggedList)td.getComponent( |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3545 |
ToolDialog.PE_PRIN_LIST); |
2 | 3546 |
int prinIndex = list.getSelectedIndex(); |
3547 |
||
3548 |
if (prinIndex < 0) { |
|
3549 |
tw.displayErrorDialog(td, new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3550 |
(PolicyTool.getMessage("No.principal.selected"))); |
2 | 3551 |
return; |
3552 |
} |
|
3553 |
td.displayPrincipalDialog(editPolicyEntry, true); |
|
3554 |
} |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3555 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3556 |
public void mouseClicked(MouseEvent evt) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3557 |
if (evt.getClickCount() == 2) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3558 |
actionPerformed(null); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3559 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3560 |
} |
2 | 3561 |
} |
3562 |
||
3563 |
/** |
|
3564 |
* Event handler for Edit Permission button |
|
3565 |
* |
|
3566 |
* We need the editPolicyEntry boolean to tell us if the user is |
|
3567 |
* adding a new PolicyEntry at this time, or editing an existing entry. |
|
3568 |
* If the user is adding a new PolicyEntry, we ONLY update the |
|
3569 |
* GUI listing. If the user is editing an existing PolicyEntry, we |
|
3570 |
* update both the GUI listing and the actual PolicyEntry. |
|
3571 |
*/ |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3572 |
class EditPermButtonListener extends MouseAdapter implements ActionListener { |
2 | 3573 |
|
3574 |
private PolicyTool tool; |
|
3575 |
private ToolWindow tw; |
|
3576 |
private ToolDialog td; |
|
3577 |
private boolean editPolicyEntry; |
|
3578 |
||
3579 |
EditPermButtonListener(PolicyTool tool, ToolWindow tw, |
|
3580 |
ToolDialog td, boolean editPolicyEntry) { |
|
3581 |
this.tool = tool; |
|
3582 |
this.tw = tw; |
|
3583 |
this.td = td; |
|
3584 |
this.editPolicyEntry = editPolicyEntry; |
|
3585 |
} |
|
3586 |
||
3587 |
public void actionPerformed(ActionEvent e) { |
|
3588 |
||
3589 |
// get the Permission selected from the Permission List |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3590 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3591 |
JList<String> list = (JList<String>)td.getComponent(ToolDialog.PE_PERM_LIST); |
2 | 3592 |
int permIndex = list.getSelectedIndex(); |
3593 |
||
3594 |
if (permIndex < 0) { |
|
3595 |
tw.displayErrorDialog(td, new Exception |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3596 |
(PolicyTool.getMessage("No.permission.selected"))); |
2 | 3597 |
return; |
3598 |
} |
|
3599 |
td.displayPermissionDialog(editPolicyEntry, true); |
|
3600 |
} |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3601 |
|
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3602 |
public void mouseClicked(MouseEvent evt) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3603 |
if (evt.getClickCount() == 2) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3604 |
actionPerformed(null); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3605 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3606 |
} |
2 | 3607 |
} |
3608 |
||
3609 |
/** |
|
3610 |
* Event handler for Principal Popup Menu |
|
3611 |
*/ |
|
3612 |
class PrincipalTypeMenuListener implements ItemListener { |
|
3613 |
||
3614 |
private ToolDialog td; |
|
3615 |
||
3616 |
PrincipalTypeMenuListener(ToolDialog td) { |
|
3617 |
this.td = td; |
|
3618 |
} |
|
3619 |
||
3620 |
public void itemStateChanged(ItemEvent e) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3621 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3622 |
// We're only interested in SELECTED events |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3623 |
return; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3624 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3625 |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3626 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3627 |
JComboBox<String> prin = (JComboBox<String>)td.getComponent(ToolDialog.PRD_PRIN_CHOICE); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3628 |
JTextField prinField = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3629 |
ToolDialog.PRD_PRIN_TEXTFIELD); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3630 |
JTextField nameField = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3631 |
ToolDialog.PRD_NAME_TEXTFIELD); |
2 | 3632 |
|
3633 |
prin.getAccessibleContext().setAccessibleName( |
|
3634 |
PolicyTool.splitToWords((String)e.getItem())); |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3635 |
if (((String)e.getItem()).equals(ToolDialog.PRIN_TYPE)) { |
2 | 3636 |
// ignore if they choose "Principal Type:" item |
3637 |
if (prinField.getText() != null && |
|
3638 |
prinField.getText().length() > 0) { |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3639 |
Prin inputPrin = ToolDialog.getPrin(prinField.getText(), true); |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
3640 |
prin.setSelectedItem(inputPrin.getSimpleName()); |
2 | 3641 |
} |
3642 |
return; |
|
3643 |
} |
|
3644 |
||
3645 |
// if you change the principal, clear the name |
|
3646 |
if (prinField.getText().indexOf((String)e.getItem()) == -1) { |
|
3647 |
nameField.setText(""); |
|
3648 |
} |
|
3649 |
||
3650 |
// set the text in the textfield and also modify the |
|
3651 |
// pull-down choice menus to reflect the correct possible |
|
3652 |
// set of names and actions |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3653 |
Prin inputPrin = ToolDialog.getPrin((String)e.getItem(), false); |
2 | 3654 |
if (inputPrin != null) { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
3655 |
prinField.setText(inputPrin.getName()); |
2 | 3656 |
} |
3657 |
} |
|
3658 |
} |
|
3659 |
||
3660 |
/** |
|
3661 |
* Event handler for Permission Popup Menu |
|
3662 |
*/ |
|
3663 |
class PermissionMenuListener implements ItemListener { |
|
3664 |
||
3665 |
private ToolDialog td; |
|
3666 |
||
3667 |
PermissionMenuListener(ToolDialog td) { |
|
3668 |
this.td = td; |
|
3669 |
} |
|
3670 |
||
3671 |
public void itemStateChanged(ItemEvent e) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3672 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3673 |
// We're only interested in SELECTED events |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3674 |
return; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3675 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3676 |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3677 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3678 |
JComboBox<String> perms = (JComboBox<String>)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3679 |
ToolDialog.PD_PERM_CHOICE); |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3680 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3681 |
JComboBox<String> names = (JComboBox<String>)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3682 |
ToolDialog.PD_NAME_CHOICE); |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3683 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3684 |
JComboBox<String> actions = (JComboBox<String>)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3685 |
ToolDialog.PD_ACTIONS_CHOICE); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3686 |
JTextField nameField = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3687 |
ToolDialog.PD_NAME_TEXTFIELD); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3688 |
JTextField actionsField = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3689 |
ToolDialog.PD_ACTIONS_TEXTFIELD); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3690 |
JTextField permField = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3691 |
ToolDialog.PD_PERM_TEXTFIELD); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3692 |
JTextField signedbyField = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3693 |
ToolDialog.PD_SIGNEDBY_TEXTFIELD); |
2 | 3694 |
|
3695 |
perms.getAccessibleContext().setAccessibleName( |
|
3696 |
PolicyTool.splitToWords((String)e.getItem())); |
|
3697 |
||
3698 |
// ignore if they choose the 'Permission:' item |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3699 |
if (PolicyTool.collator.compare((String)e.getItem(), |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3700 |
ToolDialog.PERM) == 0) { |
2 | 3701 |
if (permField.getText() != null && |
3702 |
permField.getText().length() > 0) { |
|
3703 |
||
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3704 |
Perm inputPerm = ToolDialog.getPerm(permField.getText(), true); |
2 | 3705 |
if (inputPerm != null) { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
3706 |
perms.setSelectedItem(inputPerm.getSimpleName()); |
2 | 3707 |
} |
3708 |
} |
|
3709 |
return; |
|
3710 |
} |
|
3711 |
||
3712 |
// if you change the permission, clear the name, actions, and signedBy |
|
3713 |
if (permField.getText().indexOf((String)e.getItem()) == -1) { |
|
3714 |
nameField.setText(""); |
|
3715 |
actionsField.setText(""); |
|
3716 |
signedbyField.setText(""); |
|
3717 |
} |
|
3718 |
||
3719 |
// set the text in the textfield and also modify the |
|
3720 |
// pull-down choice menus to reflect the correct possible |
|
3721 |
// set of names and actions |
|
3722 |
||
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3723 |
Perm inputPerm = ToolDialog.getPerm((String)e.getItem(), false); |
2 | 3724 |
if (inputPerm == null) { |
3725 |
permField.setText(""); |
|
3726 |
} else { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
3727 |
permField.setText(inputPerm.getName()); |
2 | 3728 |
} |
3729 |
td.setPermissionNames(inputPerm, names, nameField); |
|
3730 |
td.setPermissionActions(inputPerm, actions, actionsField); |
|
3731 |
} |
|
3732 |
} |
|
3733 |
||
3734 |
/** |
|
3735 |
* Event handler for Permission Name Popup Menu |
|
3736 |
*/ |
|
3737 |
class PermissionNameMenuListener implements ItemListener { |
|
3738 |
||
3739 |
private ToolDialog td; |
|
3740 |
||
3741 |
PermissionNameMenuListener(ToolDialog td) { |
|
3742 |
this.td = td; |
|
3743 |
} |
|
3744 |
||
3745 |
public void itemStateChanged(ItemEvent e) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3746 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3747 |
// We're only interested in SELECTED events |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3748 |
return; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3749 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3750 |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3751 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3752 |
JComboBox<String> names = (JComboBox<String>)td.getComponent(ToolDialog.PD_NAME_CHOICE); |
2 | 3753 |
names.getAccessibleContext().setAccessibleName( |
3754 |
PolicyTool.splitToWords((String)e.getItem())); |
|
3755 |
||
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3756 |
if (((String)e.getItem()).indexOf(ToolDialog.PERM_NAME) != -1) |
2 | 3757 |
return; |
3758 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3759 |
JTextField tf = (JTextField)td.getComponent(ToolDialog.PD_NAME_TEXTFIELD); |
2 | 3760 |
tf.setText((String)e.getItem()); |
3761 |
} |
|
3762 |
} |
|
3763 |
||
3764 |
/** |
|
3765 |
* Event handler for Permission Actions Popup Menu |
|
3766 |
*/ |
|
3767 |
class PermissionActionsMenuListener implements ItemListener { |
|
3768 |
||
3769 |
private ToolDialog td; |
|
3770 |
||
3771 |
PermissionActionsMenuListener(ToolDialog td) { |
|
3772 |
this.td = td; |
|
3773 |
} |
|
3774 |
||
3775 |
public void itemStateChanged(ItemEvent e) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3776 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3777 |
// We're only interested in SELECTED events |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3778 |
return; |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3779 |
} |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3780 |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3781 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
3782 |
JComboBox<String> actions = (JComboBox<String>)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3783 |
ToolDialog.PD_ACTIONS_CHOICE); |
2 | 3784 |
actions.getAccessibleContext().setAccessibleName((String)e.getItem()); |
3785 |
||
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3786 |
if (((String)e.getItem()).indexOf(ToolDialog.PERM_ACTIONS) != -1) |
2 | 3787 |
return; |
3788 |
||
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3789 |
JTextField tf = (JTextField)td.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3790 |
ToolDialog.PD_ACTIONS_TEXTFIELD); |
2 | 3791 |
if (tf.getText() == null || tf.getText().equals("")) { |
3792 |
tf.setText((String)e.getItem()); |
|
3793 |
} else { |
|
3794 |
if (tf.getText().indexOf((String)e.getItem()) == -1) |
|
3795 |
tf.setText(tf.getText() + ", " + (String)e.getItem()); |
|
3796 |
} |
|
3797 |
} |
|
3798 |
} |
|
3799 |
||
3800 |
/** |
|
3801 |
* Event handler for all the children dialogs/windows |
|
3802 |
*/ |
|
3803 |
class ChildWindowListener implements WindowListener { |
|
3804 |
||
3805 |
private ToolDialog td; |
|
3806 |
||
3807 |
ChildWindowListener(ToolDialog td) { |
|
3808 |
this.td = td; |
|
3809 |
} |
|
3810 |
||
3811 |
public void windowOpened(WindowEvent we) { |
|
3812 |
} |
|
3813 |
||
3814 |
public void windowClosing(WindowEvent we) { |
|
3815 |
// same as pressing the "cancel" button |
|
3816 |
td.setVisible(false); |
|
3817 |
td.dispose(); |
|
3818 |
} |
|
3819 |
||
3820 |
public void windowClosed(WindowEvent we) { |
|
3821 |
} |
|
3822 |
||
3823 |
public void windowIconified(WindowEvent we) { |
|
3824 |
} |
|
3825 |
||
3826 |
public void windowDeiconified(WindowEvent we) { |
|
3827 |
} |
|
3828 |
||
3829 |
public void windowActivated(WindowEvent we) { |
|
3830 |
} |
|
3831 |
||
3832 |
public void windowDeactivated(WindowEvent we) { |
|
3833 |
} |
|
3834 |
} |
|
3835 |
||
3836 |
/** |
|
3837 |
* Event handler for CancelButton button |
|
3838 |
*/ |
|
3839 |
class CancelButtonListener implements ActionListener { |
|
3840 |
||
3841 |
private ToolDialog td; |
|
3842 |
||
3843 |
CancelButtonListener(ToolDialog td) { |
|
3844 |
this.td = td; |
|
3845 |
} |
|
3846 |
||
3847 |
public void actionPerformed(ActionEvent e) { |
|
3848 |
td.setVisible(false); |
|
3849 |
td.dispose(); |
|
3850 |
} |
|
3851 |
} |
|
3852 |
||
3853 |
/** |
|
3854 |
* Event handler for ErrorOKButton button |
|
3855 |
*/ |
|
3856 |
class ErrorOKButtonListener implements ActionListener { |
|
3857 |
||
3858 |
private ToolDialog ed; |
|
3859 |
||
3860 |
ErrorOKButtonListener(ToolDialog ed) { |
|
3861 |
this.ed = ed; |
|
3862 |
} |
|
3863 |
||
3864 |
public void actionPerformed(ActionEvent e) { |
|
3865 |
ed.setVisible(false); |
|
3866 |
ed.dispose(); |
|
3867 |
} |
|
3868 |
} |
|
3869 |
||
3870 |
/** |
|
3871 |
* Event handler for StatusOKButton button |
|
3872 |
*/ |
|
3873 |
class StatusOKButtonListener implements ActionListener { |
|
3874 |
||
3875 |
private ToolDialog sd; |
|
3876 |
||
3877 |
StatusOKButtonListener(ToolDialog sd) { |
|
3878 |
this.sd = sd; |
|
3879 |
} |
|
3880 |
||
3881 |
public void actionPerformed(ActionEvent e) { |
|
3882 |
sd.setVisible(false); |
|
3883 |
sd.dispose(); |
|
3884 |
} |
|
3885 |
} |
|
3886 |
||
3887 |
/** |
|
3888 |
* Event handler for UserSaveYes button |
|
3889 |
*/ |
|
3890 |
class UserSaveYesButtonListener implements ActionListener { |
|
3891 |
||
3892 |
private ToolDialog us; |
|
3893 |
private PolicyTool tool; |
|
3894 |
private ToolWindow tw; |
|
3895 |
private int select; |
|
3896 |
||
3897 |
UserSaveYesButtonListener(ToolDialog us, PolicyTool tool, |
|
3898 |
ToolWindow tw, int select) { |
|
3899 |
this.us = us; |
|
3900 |
this.tool = tool; |
|
3901 |
this.tw = tw; |
|
3902 |
this.select = select; |
|
3903 |
} |
|
3904 |
||
3905 |
public void actionPerformed(ActionEvent e) { |
|
3906 |
||
3907 |
// first get rid of the window |
|
3908 |
us.setVisible(false); |
|
3909 |
us.dispose(); |
|
3910 |
||
3911 |
try { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3912 |
String filename = ((JTextField)tw.getComponent( |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
3913 |
ToolWindow.MW_FILENAME_TEXTFIELD)).getText(); |
2 | 3914 |
if (filename == null || filename.equals("")) { |
3915 |
us.displaySaveAsDialog(select); |
|
3916 |
||
3917 |
// the above dialog will continue with the originally |
|
3918 |
// requested command if necessary |
|
3919 |
} else { |
|
3920 |
// save the policy entries to a file |
|
3921 |
tool.savePolicy(filename); |
|
3922 |
||
3923 |
// display status |
|
3924 |
MessageFormat form = new MessageFormat |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
3925 |
(PolicyTool.getMessage |
7179
4afb81e50183
6987827: security/util/Resources.java needs improvement
weijun
parents:
6542
diff
changeset
|
3926 |
("Policy.successfully.written.to.filename")); |
2 | 3927 |
Object[] source = {filename}; |
3928 |
tw.displayStatusDialog(null, form.format(source)); |
|
3929 |
||
3930 |
// now continue with the originally requested command |
|
3931 |
// (QUIT, NEW, or OPEN) |
|
3932 |
us.userSaveContinue(tool, tw, us, select); |
|
3933 |
} |
|
3934 |
} catch (Exception ee) { |
|
3935 |
// error -- just report it and bail |
|
3936 |
tw.displayErrorDialog(null, ee); |
|
3937 |
} |
|
3938 |
} |
|
3939 |
} |
|
3940 |
||
3941 |
/** |
|
3942 |
* Event handler for UserSaveNoButton |
|
3943 |
*/ |
|
3944 |
class UserSaveNoButtonListener implements ActionListener { |
|
3945 |
||
3946 |
private PolicyTool tool; |
|
3947 |
private ToolWindow tw; |
|
3948 |
private ToolDialog us; |
|
3949 |
private int select; |
|
3950 |
||
3951 |
UserSaveNoButtonListener(ToolDialog us, PolicyTool tool, |
|
3952 |
ToolWindow tw, int select) { |
|
3953 |
this.us = us; |
|
3954 |
this.tool = tool; |
|
3955 |
this.tw = tw; |
|
3956 |
this.select = select; |
|
3957 |
} |
|
3958 |
||
3959 |
public void actionPerformed(ActionEvent e) { |
|
3960 |
us.setVisible(false); |
|
3961 |
us.dispose(); |
|
3962 |
||
3963 |
// now continue with the originally requested command |
|
3964 |
// (QUIT, NEW, or OPEN) |
|
3965 |
us.userSaveContinue(tool, tw, us, select); |
|
3966 |
} |
|
3967 |
} |
|
3968 |
||
3969 |
/** |
|
3970 |
* Event handler for UserSaveCancelButton |
|
3971 |
*/ |
|
3972 |
class UserSaveCancelButtonListener implements ActionListener { |
|
3973 |
||
3974 |
private ToolDialog us; |
|
3975 |
||
3976 |
UserSaveCancelButtonListener(ToolDialog us) { |
|
3977 |
this.us = us; |
|
3978 |
} |
|
3979 |
||
3980 |
public void actionPerformed(ActionEvent e) { |
|
3981 |
us.setVisible(false); |
|
3982 |
us.dispose(); |
|
3983 |
||
3984 |
// do NOT continue with the originally requested command |
|
3985 |
// (QUIT, NEW, or OPEN) |
|
3986 |
} |
|
3987 |
} |
|
3988 |
||
3989 |
/** |
|
3990 |
* Event handler for ConfirmRemovePolicyEntryOKButtonListener |
|
3991 |
*/ |
|
3992 |
class ConfirmRemovePolicyEntryOKButtonListener implements ActionListener { |
|
3993 |
||
3994 |
private PolicyTool tool; |
|
3995 |
private ToolWindow tw; |
|
3996 |
private ToolDialog us; |
|
3997 |
||
3998 |
ConfirmRemovePolicyEntryOKButtonListener(PolicyTool tool, |
|
3999 |
ToolWindow tw, ToolDialog us) { |
|
4000 |
this.tool = tool; |
|
4001 |
this.tw = tw; |
|
4002 |
this.us = us; |
|
4003 |
} |
|
4004 |
||
4005 |
public void actionPerformed(ActionEvent e) { |
|
4006 |
// remove the entry |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4007 |
@SuppressWarnings("unchecked") |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4008 |
JList<String> list = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2 | 4009 |
int index = list.getSelectedIndex(); |
4010 |
PolicyEntry entries[] = tool.getEntry(); |
|
4011 |
tool.removeEntry(entries[index]); |
|
4012 |
||
4013 |
// redraw the window listing |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4014 |
DefaultListModel<String> listModel = new DefaultListModel<>(); |
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4015 |
list = new JList<>(listModel); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4016 |
list.setVisibleRowCount(15); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4017 |
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4018 |
list.addMouseListener(new PolicyListListener(tool, tw)); |
2 | 4019 |
entries = tool.getEntry(); |
4020 |
if (entries != null) { |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4021 |
for (int i = 0; i < entries.length; i++) { |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4022 |
listModel.addElement(entries[i].headerToString()); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4023 |
} |
2 | 4024 |
} |
4025 |
tw.replacePolicyList(list); |
|
4026 |
us.setVisible(false); |
|
4027 |
us.dispose(); |
|
4028 |
} |
|
4029 |
} |
|
4030 |
||
4031 |
/** |
|
4032 |
* Just a special name, so that the codes dealing with this exception knows |
|
4033 |
* it's special, and does not pop out a warning box. |
|
4034 |
*/ |
|
4035 |
class NoDisplayException extends RuntimeException { |
|
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
4036 |
private static final long serialVersionUID = -4611761427108719794L; |
2 | 4037 |
} |
4038 |
||
4039 |
/** |
|
4040 |
* This is a java.awt.List that bind an Object to each String it holds. |
|
4041 |
*/ |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4042 |
class TaggedList extends JList<String> { |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
4043 |
private static final long serialVersionUID = -5676238110427785853L; |
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
9035
diff
changeset
|
4044 |
|
7977
f47f211cd627
7008713: diamond conversion of kerberos5 and security tools
smarks
parents:
7532
diff
changeset
|
4045 |
private java.util.List<Object> data = new LinkedList<>(); |
2 | 4046 |
public TaggedList(int i, boolean b) { |
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4047 |
super(new DefaultListModel<>()); |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4048 |
setVisibleRowCount(i); |
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4049 |
setSelectionMode(b ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION); |
2 | 4050 |
} |
4051 |
||
4052 |
public Object getObject(int index) { |
|
4053 |
return data.get(index); |
|
4054 |
} |
|
4055 |
||
4056 |
public void addTaggedItem(String string, Object object) { |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4057 |
((DefaultListModel<String>)getModel()).addElement(string); |
2 | 4058 |
data.add(object); |
4059 |
} |
|
4060 |
||
4061 |
public void replaceTaggedItem(String string, Object object, int index) { |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4062 |
((DefaultListModel<String>)getModel()).set(index, string); |
2 | 4063 |
data.set(index, object); |
4064 |
} |
|
4065 |
||
4066 |
public void removeTaggedItem(int index) { |
|
22059
3ad91a1b7495
8030084: Fix lint warnings in sun.security.tools.policytool
darcy
parents:
21365
diff
changeset
|
4067 |
((DefaultListModel<String>)getModel()).remove(index); |
2 | 4068 |
data.remove(index); |
4069 |
} |
|
4070 |
} |
|
4071 |
||
4072 |
/** |
|
4073 |
* Convenience Principal Classes |
|
4074 |
*/ |
|
4075 |
||
4076 |
class Prin { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4077 |
final Class<? extends Principal> CLASS; |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4078 |
|
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4079 |
Prin(Class<? extends Principal> clazz) { |
2 | 4080 |
this.CLASS = clazz; |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4081 |
} |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4082 |
|
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4083 |
String getName() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4084 |
return CLASS.getName(); |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4085 |
} |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4086 |
|
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4087 |
String getSimpleName() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4088 |
return CLASS.getSimpleName(); |
2 | 4089 |
} |
4090 |
} |
|
4091 |
||
4092 |
class KrbPrin extends Prin { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4093 |
KrbPrin() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4094 |
super(javax.security.auth.kerberos.KerberosPrincipal.class); |
2 | 4095 |
} |
4096 |
} |
|
4097 |
||
4098 |
class X500Prin extends Prin { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4099 |
X500Prin() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4100 |
super(javax.security.auth.x500.X500Principal.class); |
2 | 4101 |
} |
4102 |
} |
|
4103 |
||
4104 |
/** |
|
4105 |
* Convenience Permission Classes |
|
4106 |
*/ |
|
4107 |
||
4108 |
class Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4109 |
final Class<? extends Permission> CLASS; |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4110 |
final String[] TARGETS; |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4111 |
final String[] ACTIONS; |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4112 |
|
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4113 |
Perm(Class<? extends Permission> clazz, |
2 | 4114 |
String[] targets, String[] actions) { |
4115 |
||
4116 |
this.CLASS = clazz; |
|
4117 |
this.TARGETS = targets; |
|
4118 |
this.ACTIONS = actions; |
|
4119 |
} |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4120 |
|
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4121 |
String getName() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4122 |
return CLASS.getName(); |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4123 |
} |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4124 |
|
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4125 |
String getSimpleName() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4126 |
return CLASS.getSimpleName(); |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4127 |
} |
2 | 4128 |
} |
4129 |
||
4130 |
class AllPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4131 |
AllPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4132 |
super(java.security.AllPermission.class, null, null); |
2 | 4133 |
} |
4134 |
} |
|
4135 |
||
4136 |
class AudioPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4137 |
AudioPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4138 |
super(javax.sound.sampled.AudioPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4139 |
new String[] { |
2 | 4140 |
"play", |
4141 |
"record" |
|
4142 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4143 |
null); |
2 | 4144 |
} |
4145 |
} |
|
4146 |
||
4147 |
class AuthPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4148 |
AuthPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4149 |
super(javax.security.auth.AuthPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4150 |
new String[] { |
2 | 4151 |
"doAs", |
4152 |
"doAsPrivileged", |
|
4153 |
"getSubject", |
|
4154 |
"getSubjectFromDomainCombiner", |
|
4155 |
"setReadOnly", |
|
4156 |
"modifyPrincipals", |
|
4157 |
"modifyPublicCredentials", |
|
4158 |
"modifyPrivateCredentials", |
|
4159 |
"refreshCredential", |
|
4160 |
"destroyCredential", |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4161 |
"createLoginContext.<" + PolicyTool.getMessage("name") + ">", |
2 | 4162 |
"getLoginConfiguration", |
4163 |
"setLoginConfiguration", |
|
4164 |
"createLoginConfiguration.<" + |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4165 |
PolicyTool.getMessage("configuration.type") + ">", |
2 | 4166 |
"refreshLoginConfiguration" |
4167 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4168 |
null); |
2 | 4169 |
} |
4170 |
} |
|
4171 |
||
4172 |
class AWTPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4173 |
AWTPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4174 |
super(java.awt.AWTPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4175 |
new String[] { |
2 | 4176 |
"accessClipboard", |
4177 |
"accessEventQueue", |
|
4178 |
"accessSystemTray", |
|
4179 |
"createRobot", |
|
4180 |
"fullScreenExclusive", |
|
4181 |
"listenToAllAWTEvents", |
|
4182 |
"readDisplayPixels", |
|
4183 |
"replaceKeyboardFocusManager", |
|
4184 |
"setAppletStub", |
|
4185 |
"setWindowAlwaysOnTop", |
|
4186 |
"showWindowWithoutWarningBanner", |
|
4187 |
"toolkitModality", |
|
4188 |
"watchMousePointer" |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4189 |
}, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4190 |
null); |
2 | 4191 |
} |
4192 |
} |
|
4193 |
||
4194 |
class DelegationPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4195 |
DelegationPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4196 |
super(javax.security.auth.kerberos.DelegationPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4197 |
new String[] { |
2 | 4198 |
// allow user input |
4199 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4200 |
null); |
2 | 4201 |
} |
4202 |
} |
|
4203 |
||
4204 |
class FilePerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4205 |
FilePerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4206 |
super(java.io.FilePermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4207 |
new String[] { |
2 | 4208 |
"<<ALL FILES>>" |
4209 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4210 |
new String[] { |
2 | 4211 |
"read", |
4212 |
"write", |
|
4213 |
"delete", |
|
4214 |
"execute" |
|
4215 |
}); |
|
4216 |
} |
|
4217 |
} |
|
4218 |
||
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
20754
diff
changeset
|
4219 |
class URLPerm extends Perm { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4220 |
URLPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4221 |
super(java.net.URLPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4222 |
new String[] { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4223 |
"<"+ PolicyTool.getMessage("url") + ">", |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4224 |
}, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4225 |
new String[] { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4226 |
"<" + PolicyTool.getMessage("method.list") + ">:<" |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4227 |
+ PolicyTool.getMessage("request.headers.list") + ">", |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4228 |
}); |
17692
685c0741cfbb
8012261: update policytool to support java.net.HttpURLPermission
weijun
parents:
15013
diff
changeset
|
4229 |
} |
685c0741cfbb
8012261: update policytool to support java.net.HttpURLPermission
weijun
parents:
15013
diff
changeset
|
4230 |
} |
685c0741cfbb
8012261: update policytool to support java.net.HttpURLPermission
weijun
parents:
15013
diff
changeset
|
4231 |
|
3482
4aaa66ce712d
6710360: export Kerberos session key to applications
weijun
parents:
715
diff
changeset
|
4232 |
class InqSecContextPerm extends Perm { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4233 |
InqSecContextPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4234 |
super(com.sun.security.jgss.InquireSecContextPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4235 |
new String[] { |
3483
a16fce1820ef
6821190: more InquireType values for ExtendedGSSContext
weijun
parents:
3482
diff
changeset
|
4236 |
"KRB5_GET_SESSION_KEY", |
a16fce1820ef
6821190: more InquireType values for ExtendedGSSContext
weijun
parents:
3482
diff
changeset
|
4237 |
"KRB5_GET_TKT_FLAGS", |
a16fce1820ef
6821190: more InquireType values for ExtendedGSSContext
weijun
parents:
3482
diff
changeset
|
4238 |
"KRB5_GET_AUTHZ_DATA", |
a16fce1820ef
6821190: more InquireType values for ExtendedGSSContext
weijun
parents:
3482
diff
changeset
|
4239 |
"KRB5_GET_AUTHTIME" |
3482
4aaa66ce712d
6710360: export Kerberos session key to applications
weijun
parents:
715
diff
changeset
|
4240 |
}, |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4241 |
null); |
3482
4aaa66ce712d
6710360: export Kerberos session key to applications
weijun
parents:
715
diff
changeset
|
4242 |
} |
4aaa66ce712d
6710360: export Kerberos session key to applications
weijun
parents:
715
diff
changeset
|
4243 |
} |
4aaa66ce712d
6710360: export Kerberos session key to applications
weijun
parents:
715
diff
changeset
|
4244 |
|
2 | 4245 |
class LogPerm extends Perm { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4246 |
LogPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4247 |
super(java.util.logging.LoggingPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4248 |
new String[] { |
2 | 4249 |
"control" |
4250 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4251 |
null); |
2 | 4252 |
} |
4253 |
} |
|
4254 |
||
4255 |
class MgmtPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4256 |
MgmtPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4257 |
super(java.lang.management.ManagementPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4258 |
new String[] { |
2 | 4259 |
"control", |
4260 |
"monitor" |
|
4261 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4262 |
null); |
2 | 4263 |
} |
4264 |
} |
|
4265 |
||
4266 |
class MBeanPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4267 |
MBeanPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4268 |
super(javax.management.MBeanPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4269 |
new String[] { |
2 | 4270 |
// allow user input |
4271 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4272 |
new String[] { |
2 | 4273 |
"addNotificationListener", |
4274 |
"getAttribute", |
|
4275 |
"getClassLoader", |
|
4276 |
"getClassLoaderFor", |
|
4277 |
"getClassLoaderRepository", |
|
4278 |
"getDomains", |
|
4279 |
"getMBeanInfo", |
|
4280 |
"getObjectInstance", |
|
4281 |
"instantiate", |
|
4282 |
"invoke", |
|
4283 |
"isInstanceOf", |
|
4284 |
"queryMBeans", |
|
4285 |
"queryNames", |
|
4286 |
"registerMBean", |
|
4287 |
"removeNotificationListener", |
|
4288 |
"setAttribute", |
|
4289 |
"unregisterMBean" |
|
4290 |
}); |
|
4291 |
} |
|
4292 |
} |
|
4293 |
||
4294 |
class MBeanSvrPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4295 |
MBeanSvrPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4296 |
super(javax.management.MBeanServerPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4297 |
new String[] { |
2 | 4298 |
"createMBeanServer", |
4299 |
"findMBeanServer", |
|
4300 |
"newMBeanServer", |
|
4301 |
"releaseMBeanServer" |
|
4302 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4303 |
null); |
2 | 4304 |
} |
4305 |
} |
|
4306 |
||
4307 |
class MBeanTrustPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4308 |
MBeanTrustPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4309 |
super(javax.management.MBeanTrustPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4310 |
new String[] { |
2 | 4311 |
"register" |
4312 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4313 |
null); |
2 | 4314 |
} |
4315 |
} |
|
4316 |
||
4317 |
class NetPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4318 |
NetPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4319 |
super(java.net.NetPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4320 |
new String[] { |
26204
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4321 |
"allowHttpTrace", |
2 | 4322 |
"setDefaultAuthenticator", |
4323 |
"requestPasswordAuthentication", |
|
4324 |
"specifyStreamHandler", |
|
26204
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4325 |
"getNetworkInformation", |
2 | 4326 |
"setProxySelector", |
4327 |
"getProxySelector", |
|
4328 |
"setCookieHandler", |
|
4329 |
"getCookieHandler", |
|
4330 |
"setResponseCache", |
|
4331 |
"getResponseCache" |
|
4332 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4333 |
null); |
2 | 4334 |
} |
4335 |
} |
|
4336 |
||
26204
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4337 |
class NetworkPerm extends Perm { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4338 |
NetworkPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4339 |
super(jdk.net.NetworkPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4340 |
new String[] { |
26204
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4341 |
"setOption.SO_FLOW_SLA", |
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4342 |
"getOption.SO_FLOW_SLA" |
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4343 |
}, |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4344 |
null); |
26204
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4345 |
} |
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4346 |
} |
77df35747ce7
8055901: Update policytool for jdk.net.NetworkPermission
weijun
parents:
25859
diff
changeset
|
4347 |
|
2 | 4348 |
class PrivCredPerm extends Perm { |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4349 |
PrivCredPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4350 |
super(javax.security.auth.PrivateCredentialPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4351 |
new String[] { |
2 | 4352 |
// allow user input |
4353 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4354 |
new String[] { |
2 | 4355 |
"read" |
4356 |
}); |
|
4357 |
} |
|
4358 |
} |
|
4359 |
||
4360 |
class PropPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4361 |
PropPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4362 |
super(java.util.PropertyPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4363 |
new String[] { |
2 | 4364 |
// allow user input |
4365 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4366 |
new String[] { |
2 | 4367 |
"read", |
4368 |
"write" |
|
4369 |
}); |
|
4370 |
} |
|
4371 |
} |
|
4372 |
||
4373 |
class ReflectPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4374 |
ReflectPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4375 |
super(java.lang.reflect.ReflectPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4376 |
new String[] { |
2 | 4377 |
"suppressAccessChecks" |
4378 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4379 |
null); |
2 | 4380 |
} |
4381 |
} |
|
4382 |
||
4383 |
class RuntimePerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4384 |
RuntimePerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4385 |
super(java.lang.RuntimePermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4386 |
new String[] { |
2 | 4387 |
"createClassLoader", |
4388 |
"getClassLoader", |
|
4389 |
"setContextClassLoader", |
|
4390 |
"enableContextClassLoaderOverride", |
|
705
1db8adb3ea95
6711509: PolicyTool is misspelling Runtime permission - 'setSecurityManager' entry in the policy file
weijun
parents:
2
diff
changeset
|
4391 |
"setSecurityManager", |
2 | 4392 |
"createSecurityManager", |
4393 |
"getenv.<" + |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4394 |
PolicyTool.getMessage("environment.variable.name") + ">", |
2 | 4395 |
"exitVM", |
4396 |
"shutdownHooks", |
|
4397 |
"setFactory", |
|
4398 |
"setIO", |
|
4399 |
"modifyThread", |
|
4400 |
"stopThread", |
|
4401 |
"modifyThreadGroup", |
|
4402 |
"getProtectionDomain", |
|
4403 |
"readFileDescriptor", |
|
4404 |
"writeFileDescriptor", |
|
4405 |
"loadLibrary.<" + |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4406 |
PolicyTool.getMessage("library.name") + ">", |
2 | 4407 |
"accessClassInPackage.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4408 |
PolicyTool.getMessage("package.name")+">", |
2 | 4409 |
"defineClassInPackage.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4410 |
PolicyTool.getMessage("package.name")+">", |
2 | 4411 |
"accessDeclaredMembers", |
4412 |
"queuePrintJob", |
|
4413 |
"getStackTrace", |
|
4414 |
"setDefaultUncaughtExceptionHandler", |
|
4415 |
"preferences", |
|
4416 |
"usePolicy", |
|
4417 |
// "inheritedChannel" |
|
4418 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4419 |
null); |
2 | 4420 |
} |
4421 |
} |
|
4422 |
||
4423 |
class SecurityPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4424 |
SecurityPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4425 |
super(java.security.SecurityPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4426 |
new String[] { |
2 | 4427 |
"createAccessControlContext", |
4428 |
"getDomainCombiner", |
|
4429 |
"getPolicy", |
|
4430 |
"setPolicy", |
|
4431 |
"createPolicy.<" + |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4432 |
PolicyTool.getMessage("policy.type") + ">", |
2 | 4433 |
"getProperty.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4434 |
PolicyTool.getMessage("property.name") + ">", |
2 | 4435 |
"setProperty.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4436 |
PolicyTool.getMessage("property.name") + ">", |
2 | 4437 |
"insertProvider.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4438 |
PolicyTool.getMessage("provider.name") + ">", |
2 | 4439 |
"removeProvider.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4440 |
PolicyTool.getMessage("provider.name") + ">", |
2 | 4441 |
//"setSystemScope", |
4442 |
//"setIdentityPublicKey", |
|
4443 |
//"setIdentityInfo", |
|
4444 |
//"addIdentityCertificate", |
|
4445 |
//"removeIdentityCertificate", |
|
4446 |
//"printIdentity", |
|
4447 |
"clearProviderProperties.<" + |
|
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4448 |
PolicyTool.getMessage("provider.name") + ">", |
2 | 4449 |
"putProviderProperty.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4450 |
PolicyTool.getMessage("provider.name") + ">", |
2 | 4451 |
"removeProviderProperty.<" + |
20886
9630bb813a6c
7025699: Policy Tool is not accessible by keyboard
weijun
parents:
20787
diff
changeset
|
4452 |
PolicyTool.getMessage("provider.name") + ">", |
2 | 4453 |
//"getSignerPrivateKey", |
4454 |
//"setSignerKeyPair" |
|
4455 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4456 |
null); |
2 | 4457 |
} |
4458 |
} |
|
4459 |
||
4460 |
class SerialPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4461 |
SerialPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4462 |
super(java.io.SerializablePermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4463 |
new String[] { |
2 | 4464 |
"enableSubclassImplementation", |
4465 |
"enableSubstitution" |
|
4466 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4467 |
null); |
2 | 4468 |
} |
4469 |
} |
|
4470 |
||
4471 |
class ServicePerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4472 |
ServicePerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4473 |
super(javax.security.auth.kerberos.ServicePermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4474 |
new String[] { |
2 | 4475 |
// allow user input |
4476 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4477 |
new String[] { |
2 | 4478 |
"initiate", |
4479 |
"accept" |
|
4480 |
}); |
|
4481 |
} |
|
4482 |
} |
|
4483 |
||
4484 |
class SocketPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4485 |
SocketPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4486 |
super(java.net.SocketPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4487 |
new String[] { |
2 | 4488 |
// allow user input |
4489 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4490 |
new String[] { |
2 | 4491 |
"accept", |
4492 |
"connect", |
|
4493 |
"listen", |
|
4494 |
"resolve" |
|
4495 |
}); |
|
4496 |
} |
|
4497 |
} |
|
4498 |
||
4499 |
class SQLPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4500 |
SQLPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4501 |
super(java.sql.SQLPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4502 |
new String[] { |
6542
155856185c1b
6845220: Need to update Policytool for Rowset 1.1 and JDBC 4.1 MR added permissions
weijun
parents:
5627
diff
changeset
|
4503 |
"setLog", |
155856185c1b
6845220: Need to update Policytool for Rowset 1.1 and JDBC 4.1 MR added permissions
weijun
parents:
5627
diff
changeset
|
4504 |
"callAbort", |
155856185c1b
6845220: Need to update Policytool for Rowset 1.1 and JDBC 4.1 MR added permissions
weijun
parents:
5627
diff
changeset
|
4505 |
"setSyncFactory", |
155856185c1b
6845220: Need to update Policytool for Rowset 1.1 and JDBC 4.1 MR added permissions
weijun
parents:
5627
diff
changeset
|
4506 |
"setNetworkTimeout", |
2 | 4507 |
}, |
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4508 |
null); |
2 | 4509 |
} |
4510 |
} |
|
4511 |
||
4512 |
class SSLPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4513 |
SSLPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4514 |
super(javax.net.ssl.SSLPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4515 |
new String[] { |
2 | 4516 |
"setHostnameVerifier", |
4517 |
"getSSLSessionContext" |
|
4518 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4519 |
null); |
2 | 4520 |
} |
4521 |
} |
|
4522 |
||
4523 |
class SubjDelegPerm extends Perm { |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4524 |
SubjDelegPerm() { |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4525 |
super(javax.management.remote.SubjectDelegationPermission.class, |
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4526 |
new String[] { |
2 | 4527 |
// allow user input |
4528 |
}, |
|
31803
a359181776b2
8131350: policytool can directly reference permission classes
weijun
parents:
29370
diff
changeset
|
4529 |
null); |
2 | 4530 |
} |
4531 |
} |