6738668: JFileChooser cannot be created under SecurityManager
Reviewed-by: peterz
This commit is contained in:
parent
e6ea9147f9
commit
30beae5a8c
@ -39,6 +39,8 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.awt.shell.ShellFolder;
|
||||
import sun.awt.OSInfo;
|
||||
@ -1143,7 +1145,11 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
File[] baseFolders;
|
||||
if (useShellFolder) {
|
||||
baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
|
||||
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
|
||||
public File[] run() {
|
||||
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
baseFolders = fsv.getRoots();
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import javax.accessibility.*;
|
||||
|
||||
import sun.awt.shell.ShellFolder;
|
||||
@ -937,7 +939,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
File[] baseFolders;
|
||||
if (useShellFolder) {
|
||||
baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
|
||||
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
|
||||
public File[] run() {
|
||||
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
baseFolders = fsv.getRoots();
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
@ -749,7 +751,11 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
|
||||
File[] baseFolders;
|
||||
if (useShellFolder) {
|
||||
baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
|
||||
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
|
||||
public File[] run() {
|
||||
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
baseFolders = fsv.getRoots();
|
||||
}
|
||||
|
44
jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java
Normal file
44
jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 6738668
|
||||
@summary JFileChooser cannot be created under SecurityManager
|
||||
@author Pavel Porvatov
|
||||
@run main/othervm/policy=security.policy bug6738668
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
public class bug6738668 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
|
||||
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
|
||||
|
||||
new JFileChooser(new File("c:/temp"));
|
||||
|
||||
System.out.println("Test passed for LookAndFeel " + lookAndFeelInfo.getClassName());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
grant {
|
||||
permission java.io.FilePermission "C:\\temp\\*", "read";
|
||||
permission java.io.FilePermission "C:\\temp", "read";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user