0

I made an applet which can be run if add the permission to java.policy(See below).

permission java.awt.AWTPermission "createRobot";
permission java.awt.AWTPermission "readDisplayPixels";
permission java.awt.AWTPermission "accessClipboard"; 
permission java.awt.AWTPermission "accessEventQueue"; 
permission java.awt.AWTPermission "showWindowWithoutWarningBanner";

Otherwise java console will show:

java.security.AccessControlException: access denied("java.awt.AWTPermission" "createRobot")

How to do it with a product way since users dont want to modify the policy file?

In addition, the applet has already been signed and the files below are put in the server.

ScreenShot.cer
ScreenShot.store
ScreenShot.jar
ScreenShot.policy

HTML tag:

<applet name="SnapShot" archive="ScreenShot.jar" codebase="." code="ScreenShot.class" width="1" height="1" mayscript="true">
    <param name="cache_archive" value="ScreenShot.jar">
    <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
    <param name="permissions" value="all-permissions">
</applet>
Jianyuan Ma
  • 305
  • 2
  • 4
  • 13
  • *"I have already done the applet signature"* Does that mean you digitally signed the applet? *"..and put the files below in the server."* The only file of those 4 that needs to be on the server is the `myApplet.jar`. The rest are redundant. But just noticed the difference between `myApplet.jar` & `ScreenShot.jar`. Don't paraphrase when describing these things. Is it the first name, or the 2nd? – Andrew Thompson Sep 04 '13 at 08:23
  • It is a mistake; actually, it should be ScreenShot.jar. I just corrected. Thanks for reminding – Jianyuan Ma Sep 04 '13 at 08:27
  • OK.. again, *Does that mean you digitally signed the applet?* – Andrew Thompson Sep 04 '13 at 08:29
  • Yes, it does. But still suck with the AWTPermission – Jianyuan Ma Sep 04 '13 at 08:37
  • How big is the Jar? Can you upload it somewhere that I can download from (to check the digital signature)? – Andrew Thompson Sep 04 '13 at 09:06
  • I create an repository in github: https://github.com/max90727/ScreenShot – Jianyuan Ma Sep 05 '13 at 08:00
  • 1.7 Meg?!? When I asked 'how big is the Jar?' I was hoping you'd take the hint to make a Jar of less that 5KB! It would take less that 200 lines of code to test those 4 permissions.. – Andrew Thompson Sep 05 '13 at 08:45
  • alright, I though it could be clear. but the JAR file is around 23KB. You can download at http://temp-share.com/show/YgFbcdy0y – Jianyuan Ma Sep 05 '13 at 14:05
  • It shows a warning that might be meaningful. Further details in [this Q&A](http://stackoverflow.com/q/8387983/418556).. – Andrew Thompson Sep 05 '13 at 14:33
  • @AndrewThompson: I want to enable copy/paste on my applet. I added grant all permissions to my.policy. And self-signed my applet. I still got Access denied. Can you help me show which step I do wrong? There is only granting more pivileged outside sandbox to trusted-sign applets, isn't there? – Ken Block Jun 23 '14 at 04:12
  • @KenBlock Copy/paste is a whole different (more complicated) situation. You'd be best off asking a separate question. – Andrew Thompson Jun 23 '14 at 05:12

1 Answers1

0

this question dulicates one from here where i've posted an answer:

java.security.AccessControlException when using java.awt.Robot class for screen capture in applet

Community
  • 1
  • 1
Misiakw
  • 902
  • 8
  • 28