# JAVA security warning - printing



## BrianJohnson (Feb 6, 2008)

I have an application that pops up with the message:
=================================
Security warning
The applet has requested access to the printer
Do you want to allow this action?
=================================
The applet is one developed in house called FeAppletPrint.

There is a tickbox to always allow this applet to run. If I check this box and allow the applet to execute all works fine, however the next time the applet is called then the same security popup appears. 

I've tried several setting in both IE and Java, all without sucess...

Is there any way that I can stop this security warning appearing?

help....


----------



## jjobin (Feb 11, 2008)

I would like an answer to the same question.


----------



## BrianJohnson (Feb 6, 2008)

One of our technical guys came-up with the following:
I only have one version of java installed – jre.1.5.0 – so go into the folder of whichever version of java you’re running then into the lib\security folder:

C:\program files\Java\jre.1.5.0\lib\security

There should be a file called java.policy. Open this in notepad and add the line:

permission java.lang.RuntimePermission "queuePrintJob";

to the

grant {

};

section. Mine went from looking like:

// Standard extensions get all permissions by default

grant codeBase "file:${{java.ext.dirs}}/*" {

permission java.security.AllPermission;

};

// default permissions granted to all domains

grant { 

// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See "http://java.sun.com/notes" for more information.
permission java.lang.RuntimePermission "stopThread";

// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "localhost:1024-", "listen";

// "standard" properies that can be read by anyone

permission java.util.PropertyPermission "java.version", "read";

permission java.util.PropertyPermission "java.vendor", "read";

permission java.util.PropertyPermission "java.vendor.url", "read";

permission java.util.PropertyPermission "java.class.version", "read";

permission java.util.PropertyPermission "os.name", "read";

permission java.util.PropertyPermission "os.version", "read";

permission java.util.PropertyPermission "os.arch", "read";

permission java.util.PropertyPermission "file.separator", "read";

permission java.util.PropertyPermission "path.separator", "read";

permission java.util.PropertyPermission "line.separator", "read";



permission java.util.PropertyPermission "java.specification.version", "read";

permission java.util.PropertyPermission "java.specification.vendor", "read";

permission java.util.PropertyPermission "java.specification.name", "read";



permission java.util.PropertyPermission "java.vm.specification.version", "read";

permission java.util.PropertyPermission "java.vm.specification.vendor", "read";

permission java.util.PropertyPermission "java.vm.specification.name", "read";

permission java.util.PropertyPermission "java.vm.version", "read";

permission java.util.PropertyPermission "java.vm.vendor", "read";

permission java.util.PropertyPermission "java.vm.name", "read";

};



to:



// Standard extensions get all permissions by default



grant codeBase "file:${{java.ext.dirs}}/*" {

permission java.security.AllPermission;

};



// default permissions granted to all domains



grant { 

// Allows any thread to stop itself using the java.lang.Thread.stop()

// method that takes no argument.

// Note that this permission is granted by default only to remain

// backwards compatible.

// It is strongly recommended that you either remove this permission

// from this policy file or further restrict it to code sources

// that you specify, because Thread.stop() is potentially unsafe.

// See "http://java.sun.com/notes" for more information.

permission java.lang.RuntimePermission "stopThread";



// allows anyone to listen on un-privileged ports

permission java.net.SocketPermission "localhost:1024-", "listen";



// "standard" properies that can be read by anyone



permission java.util.PropertyPermission "java.version", "read";

permission java.util.PropertyPermission "java.vendor", "read";

permission java.util.PropertyPermission "java.vendor.url", "read";

permission java.util.PropertyPermission "java.class.version", "read";

permission java.util.PropertyPermission "os.name", "read";

permission java.util.PropertyPermission "os.version", "read";

permission java.util.PropertyPermission "os.arch", "read";

permission java.util.PropertyPermission "file.separator", "read";

permission java.util.PropertyPermission "path.separator", "read";

permission java.util.PropertyPermission "line.separator", "read";



permission java.util.PropertyPermission "java.specification.version", "read";

permission java.util.PropertyPermission "java.specification.vendor", "read";

permission java.util.PropertyPermission "java.specification.name", "read";



permission java.util.PropertyPermission "java.vm.specification.version", "read";

permission java.util.PropertyPermission "java.vm.specification.vendor", "read";

permission java.util.PropertyPermission "java.vm.specification.name", "read";

permission java.util.PropertyPermission "java.vm.version", "read";

permission java.util.PropertyPermission "java.vm.vendor", "read";

permission java.util.PropertyPermission "java.vm.name", "read";

permission java.lang.RuntimePermission "queuePrintJob";

};





Save this file then reload web rio and it should be ok.[/SIZE]


----------



## tokn (Jul 9, 2008)

Confirm that this fixed the problem.

Thanks!


----------



## arturoterron (Dec 9, 2009)

Hello! I had the same problem, resolved with the change in the java.policy file that BrianJohnson wrote, but... I have always an exception after try:

docPrintJob.print(doc, null);

The exception:
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at sun.print.Win32PrintJob.initializeAttributeSets(Unknown Source)
at sun.print.Win32PrintJob.print(Unknown Source)
at ImprimirPruebas.paint(ImprimirPruebas.java:95)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

I suposse that it's about a permissions problem, but I'm not be able to find the solution. Any help? Thanks in advance.


----------

