• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

runtime permission

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I need to permit shutdownhooks in my applet. It is not malicious, honest, promise, no I am not from the govt, grin. I cant edit the individual users' policy file. Is there a way of just having a policy file for the applet or make a modification and restore the original on close? All I want to do is make sure my code fully shuts down before the jvm quits. Any insight, thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If altering the policy file is not an option, then you'd need to sign the applet.

But shutdown hooks are only executed when the JVM actually quits, which will most likely be when the browser is closed. That could be a hours or days after the applet is unloaded.

As an alternative, consider doing a proper termination in the applet's "stop" method.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
If altering the policy file is not an option, then you'd need to sign the applet.

But shutdown hooks are only executed when the JVM actually quits, which will most likely be when the browser is closed. That could be a hours or days after the applet is unloaded.

As an alternative, consider doing a proper termination in the applet's "stop" method.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf
Sorry for that blank post.

How does the plugin handle it if it is signed? Is it interpreting it, finding the ShutDownHook and then seeing signed permit the grant?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the plugin handle it if it is signed? Is it interpreting it, finding the ShutDownHook and then seeing signed permit the grant?


If you look at the javadocs for adShutdownHook, you'll see that it throws a SecurityException if a security manager is present (which is the case for an applet), and the code does not have the shutdownHooks RuntimePermission (which is also the case for applets, see here).

Signing the applet in effect grants the applet the that RuntimePermission, thus making it possible to register shutdown hooks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic