I developed an applet to take a screenshot and save it to the user's computer using the java.awt.Robot class. I need to insert this applet into an html page (using an object tag) so that when a user clicks a button on a web page, a screenshot is taken.
The applet itself works fine, I tested it by adding a temporary main method to it and running it on my local computer as a regular Java application.
In cases where I am having difficulty, you set permissions to allow it to run from its built-in location. Obviously, the class of robots is somewhat dangerous, so you need to install AWTPermission, and the applet itself must be signed.
I went through the tutorial at http://download.oracle.com/javase/tutorial/security/toolsign/index.html and was able to create a signed .jar file and then the policy file that allowed the demo application in this tutorial to run. Where I am now facing problems is how to reconcile what I learned with the situation in which my applet will be used.
My target audience is about 100 machines, and I need it to run on all of them. I packed my java.class file in .jar and signed it with keytool and jarsigner. Then I uploaded the .jar and .cer files to the server directory where the pages are located.
However: when I used policytool to create a new policy file on one of the computers to verify the installation, I still cannot run the applet from HTML. I get Java.Security.AccessControlException Acess Denied java.awt.AWTPermission createRobot.
I rather suspect that this political step is contrary, so I will describe the steps I took: I upload the certificate to the local computer and generate a keystore from it, I run "policytool" from this directory via the command line I add the directory on the local computer where the keystore is stored, and my certificate. Then I click the Add Policy button and enter the alias SignedBy. Then add permissions and select AWTPermission. Target name. I select createRobot. The function field I leave empty, because I canβt think what will be applied here. The signature in this window is also left empty Then I click βOKβ and βFinishβ and I get a warning that there is no public key for the alias that I entered in the first step. I do "save as" and save the policy file in the same directory where I put the certificate and the keystore from it.
This does not allow me to run the applet from a web page, but my limited understanding of this aspect of programming does not provide any indication as to what went wrong.
Ideas, thoughts, observations? If I did not mention something, then I did not. My biggest suspect is the warning I get, but I can't find why his appearance
EDIT: Forgot to mention the step. I manually added the line "policy.url.3 = file: / C: / Testing / debugpolicy" to my jre \ lib \ security \ java.security file, since this is the path and policy file name that I created during the above steps . I also just deleted the warning that I mentioned earlier, I mixed my alias "and gave an alias for a private keystore, not a public one, during the creation of the policy file, however I still encounter the same problems.