-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b47
-
x86, sparc
-
solaris_9, windows_xp
-
Verified
I am getting the PrintJob from Toolkit and printing a frame to a file. I have given the following permissions in the policytool:
RuntimePermission - QueuePrintJob
FilePermission - ALL FILES - read, write, execute
Only these 2 permissions are specified in the API doc for printing using PrintJob. I have set the destination type to FILE but I have not set a FileName explicitly. When executing this application with SecurityManager installed, I am getting a security exception asking the user to give user.dir permission. This exception does not occur when file name is set explicitly. I assume this exception is thrown when trying to create the default file 'out.prn' / 'out.ps' in the current directory of the user.
This is reproducible on all platforms since 1.4. For Win32 with Native Dialog, I am able to reproduce this only since b04 and not on earlier builds. On Tiger, no exception is thrown and printing works just fine. Hence this is a regression introduced in Mustang-b04 for Win32.
I have attached a sample test. Execute the sample test. You would see a frame with 4 buttons. Click on the buttons. If dialog comes up, click 'PrintToFile' followed by 'OK'. If you get the following exception the bug is reproduced. Sometimes, exception will be thrown upfront even before the dialog is shown.
Here is the exception:
Exception in thread "AWT-EventQueue-0" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
at java.lang.System.getProperty(System.java:627)
at java.io.Win32FileSystem.getUserPath(Win32FileSystem.java:295)
at java.io.Win32FileSystem.resolve(Win32FileSystem.java:311)
at java.io.File.getAbsolutePath(File.java:473)
at java.io.File.getAbsoluteFile(File.java:489)
at java.io.File.toURI(File.java:629)
at sun.print.PrintJob2D.copyAttributes(PrintJob2D.java:620)
at sun.print.PrintJob2D.printDialog(PrintJob2D.java:364)
at sun.awt.windows.WToolkit.getPrintJob(WToolkit.java:579)
at DestinationTest.actionPerformed(DestinationTest.java:74)
at java.awt.Button.processActionEvent(Button.java:388)
at java.awt.Button.processEvent(Button.java:356)
at java.awt.Component.dispatchEventImpl(Component.java:3958)
at java.awt.Component.dispatchEvent(Component.java:3806)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:591)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
###@###.### 2004-11-16 14:14:09 GMT
RuntimePermission - QueuePrintJob
FilePermission - ALL FILES - read, write, execute
Only these 2 permissions are specified in the API doc for printing using PrintJob. I have set the destination type to FILE but I have not set a FileName explicitly. When executing this application with SecurityManager installed, I am getting a security exception asking the user to give user.dir permission. This exception does not occur when file name is set explicitly. I assume this exception is thrown when trying to create the default file 'out.prn' / 'out.ps' in the current directory of the user.
This is reproducible on all platforms since 1.4. For Win32 with Native Dialog, I am able to reproduce this only since b04 and not on earlier builds. On Tiger, no exception is thrown and printing works just fine. Hence this is a regression introduced in Mustang-b04 for Win32.
I have attached a sample test. Execute the sample test. You would see a frame with 4 buttons. Click on the buttons. If dialog comes up, click 'PrintToFile' followed by 'OK'. If you get the following exception the bug is reproduced. Sometimes, exception will be thrown upfront even before the dialog is shown.
Here is the exception:
Exception in thread "AWT-EventQueue-0" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
at java.lang.System.getProperty(System.java:627)
at java.io.Win32FileSystem.getUserPath(Win32FileSystem.java:295)
at java.io.Win32FileSystem.resolve(Win32FileSystem.java:311)
at java.io.File.getAbsolutePath(File.java:473)
at java.io.File.getAbsoluteFile(File.java:489)
at java.io.File.toURI(File.java:629)
at sun.print.PrintJob2D.copyAttributes(PrintJob2D.java:620)
at sun.print.PrintJob2D.printDialog(PrintJob2D.java:364)
at sun.awt.windows.WToolkit.getPrintJob(WToolkit.java:579)
at DestinationTest.actionPerformed(DestinationTest.java:74)
at java.awt.Button.processActionEvent(Button.java:388)
at java.awt.Button.processEvent(Button.java:356)
at java.awt.Component.dispatchEventImpl(Component.java:3958)
at java.awt.Component.dispatchEvent(Component.java:3806)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:591)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
###@###.### 2004-11-16 14:14:09 GMT
- duplicates
-
JDK-6195933 REG: PrintToFile is not selected automatically in the print dlg when sec mgr is installed, win32
-
- Closed
-
-
JDK-6196546 Printing to File throws exception when user.home permission is not given, on unix
-
- Closed
-