Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6196546

Printing to File throws exception when user.home permission is not given, on unix

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 6
    • 6
    • client-libs
    • 2d
    • sparc
    • solaris_9

      Printing to a file throws a security exception when a security manager is installed and user.home property is not given. This is not documented anywhere. I am printing some data through AWT PrintJob and I have installed a sec manager. I have given the following permissions through policy file:

      RuntimePermission - queuePrintJob
      FilePermission - ALL FILES - read, write, execute
      PropertyPermission - user.dir - read (This is also not documented. A separate bug has been filed against this)

      When I run the application on Solaris/Linux, a security exception is thrown asking the user to give user.home permission. This exception is not documented anywhere but it is typically thrown when popping up a file dialog for entering the file name. This exception must be documented in one of the printing classes in order to let the user know the list of permissions required to print to a file. Otherwise, PrintToFile option should be disabled upfront in the print dialog when such a permission is not available.

      This is not reproducible on Win32 but reproducible only on Solaris / Linux. Exception is thrown only on the PIT build given below:

      java version "2d.pit-awt-blade-2004-11-15.mustang"
      Java(TM) 2 Runtime Environment, Standard Edition (build 2d.pit-awt-blade-2004-11-15.mustang)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b12, mixed mode)

      On 1.4.2, it works fine. On Tiger and mustang builds (till b11), PJOB is returned as null and no exception is thrown.

      I have attached a sample test. Execute the sample test. Sec manager will be installed by default. A cross platform dialog will appear. Select PrintToFile option if it is not already selected. Click OK. If you notice the following exception on the console, the bug is reproduced.

      Here is the exception:
      java.security.AccessControlException: access denied (java.util.PropertyPermission user.home 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 javax.swing.filechooser.FileSystemView.getHomeDirectory(FileSystemView.java:369)
      at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFileChooserUI.java:244)
      at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:136)
      at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserUI.java:123)
      at javax.swing.JComponent.setUI(JComponent.java:665)
      at javax.swing.JFileChooser.updateUI(JFileChooser.java:1755)
      at javax.swing.JFileChooser.setup(JFileChooser.java:366)
      at javax.swing.JFileChooser.<init>(JFileChooser.java:332)
      at javax.swing.JFileChooser.<init>(JFileChooser.java:285)
      at sun.print.ServiceDialog$ValidatingFileChooser.<init>(ServiceDialog.java:2727)
      at sun.print.ServiceDialog$ValidatingFileChooser.<init>(ServiceDialog.java:2727)
      at sun.print.ServiceDialog.showFileChooser(ServiceDialog.java:406)
      at sun.print.ServiceDialog.actionPerformed(ServiceDialog.java:362)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1863)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2183)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
      at java.awt.Component.processMouseEvent(Component.java:5506)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3153)
      at java.awt.Component.processEvent(Component.java:5271)
      at java.awt.Container.processEvent(Container.java:1966)
      at java.awt.Component.dispatchEventImpl(Component.java:3958)
      at java.awt.Container.dispatchEventImpl(Container.java:2024)
      at java.awt.Component.dispatchEvent(Component.java:3806)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
      at java.awt.Container.dispatchEventImpl(Container.java:2010)
      at java.awt.Window.dispatchEventImpl(Window.java:1768)
      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.pumpEventsForHierarchy(EventDispatchThread.java:153)
      at java.awt.Dialog$1.run(Dialog.java:515)
      at java.awt.Dialog.show(Dialog.java:536)
      at javax.print.ServiceUI.printDialog(ServiceUI.java:219)
      at sun.print.RasterPrinterJob.printDialog(RasterPrinterJob.java:853)
      at sun.print.PSPrinterJob.printDialog(PSPrinterJob.java:414)
      at sun.print.RasterPrinterJob.printDialog(RasterPrinterJob.java:783)
      at sun.print.PrintJob2D.printDialog(PrintJob2D.java:385)
      at sun.awt.motif.MToolkit.getPrintJob(MToolkit.java:396)
      at NativeDialogTest.actionPerformed(NativeDialogTest.java:54)
      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-17 12:26:40 GMT

            jgodinez Jennifer Godinez (Inactive)
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: