• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Unsigned Applet PrivilegedActionException

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I've created an Applet for my JSF Webapplication. I want to use the Applet to get the Client side Printers and print on them.

I Need this function for my School Project, which means that my Applet is unsigned.

If I start my Web application I always get a Dialog box which asks me if I'm sure to run the Applet. That all fine. After I execute the Applet with Javascript I get this error message:



I've been searching for a couple of hours but I didn't found any hint for unsigned applets.

JSF



Javascript

 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF doesn't have any special effect on applets. So you could have asked in our Applets forum.

Based on your sample code, I suspect that you're attempting to access the printer and the Java sandbox will not permit that. You would have to sign the applet to be able to talk to the printer.

Your browser or OS Control panel should have an option to open a debugging window that can display the stack trace from where your applet failed. It also is where any System.out.print and System.err.print messages would display.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Arman Döner wrote:I Need this function for my School Project, which means that my Applet is unsigned.



Really? Applets are dead now -- browsers are dropping support for applets right now because of their security issues -- so there's no reason for schools to teach people how to write applets. So if there's an alternate project you could choose which doesn't involve applets I would strongly suggest you switch to that project instead.

 
Arman Döner
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for answering. Yes I Need to do this Project. I have no alternative. The main Point of the Project is to print a file on button click by Client side without a print Dialog.
For this I Need to use Java & JSF. So I didn't found any other way to to print like that.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you are doomed.

The security reputation of applets has been probably irrevocably tarnished by the recent (and not-so-recent) string of exploits found in the client-side JVM. But nevertheless, unsigned applets are expressly forbidden to access files or devices (including the printer).

Here's some examples of why untrusted applets must not print:

1. I could write an applet out of petty spite that would do nothing but print random garbage on pages forever. If you weren't paying attention, I could thus ruin your printer's paper supply.

2. If I knew of an exploit in the printer driver - or the printer, I could use that to make the printer explode Mission Impossible style or even take over the client's computer. These things happen. Consider the recent incident where the "harmless" activity of setting the date would brick certain Apple devices.
 
Arman Döner
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm sounds clear.

As You said.. I'm doomed!

What about getting the Computer Name of the Client who started the request?

The Printers are on the Server and shared to the other Workstations..
Every Workstation is related to a Printer and every Workstation has an unique name.
So I could start the print by Server side if I know the Computer Name.

Can I do that with Applet or JSF? Maybe Cookies?
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You wouldn't need an applet if the server was running the print job.

I don't think there's a way to get the client's hostname (for one thing, computers can have more than one name), although you could get its IP address. IP addresses can be misleading, though. All of the machines on my domain look like they are at the same IP address to outside websites, thanks to NAT.

Probably your best bet is to create a list of available printers and let the web application present them for the user to select from. You can then remember that selection either with a cookie or server-side persistent data.

Some extra considerations:

1. If the webserver is doing the printing, then you should schedule print jobs in separate threads to avoid bogging down the webserver. However that does NOT mean that a servlet is allowed to spawn threads. Getting independent threads to run in a webapp is a semi-complicated affair that I won't cover just now.

2. Just because the webserver is doing the printing doesn't mean that the webserver can open files on the client machine to print from. That would be a MAJOR security issue and in any event, HTTP doesn't support it. You'd have to be printing data from the server. You could upload a copy of the file and print that, however.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Arman Döner wrote:What about getting the Computer Name of the Client who started the request?

The Printers are on the Server and shared to the other Workstations..
Every Workstation is related to a Printer and every Workstation has an unique name.
So I could start the print by Server side if I know the Computer Name.

Can I do that with Applet or JSF? Maybe Cookies?



Wait a minute. I interpreted all your posts so far as "I have to use an applet for my project". But now I'm not so sure. Do you have to use an applet, or was that only your first idea for implementing the actual requirement which you haven't told us?
 
Arman Döner
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:
Wait a minute. I interpreted all your posts so far as "I have to use an applet for my project". But now I'm not so sure. Do you have to use an applet, or was that only your first idea for implementing the actual requirement which you haven't told us?



Sorry If you understood me wrong.
The Project sais.. Search the best way to print from a Web application using a Printer which is installed on Client side.

I was pretty sure that to call by Applet would be the best way.
Looks like it's not.

So I'm searcihng for an alternative solution.

The Project description don't say, that I Need to use applets or the Printer can't be shared from Server.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the answer to that if you can't sign an applet is as follows:

1. Serve a malware exploit up the client and have it take over the client's machine.

2. Have the malware print something using its illegally-obtained elevated privileges.

The HTTP protocol, as I have said before, doesn't permit direct access of files, devices or services by server-side code. Doesn't matter if it's JSF, plain Java or even .Net. About as close as you can get is to have the server send back something for client-side execution (for example, javascript), but JavaScript is supposed to obey certain sandbox rules too.

Now on the other hand, you can use CSS tags to make web pages printer-friendly, and I often do. But the actual print command itself has to be issued by the user.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic