.Java.policy file and local applet

I am working on an HTML page using Javascript to interact with a Java applet. The HTML page, javascript and .jar file for the applet will be deployed locally to a folder in the user file system.

(It’s not an option to use this as a stand-alone Java application, for various reasons I won’t explain here).

The applet must execute the local I / O file. Thus, I am trying to tweek the settings in the user's .java.policy file to allow this.

I found that the following setting only works:

grant 
{
  permission java.io.FilePermission "<<ALL FILES>>", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "write";
};

This is not ideal, as it provides all applet permissions for reading all files. Naturally, I would rather isolate a specific code base. However, I could not find the "grant codeBase" syntax that works.

I tried:

grant codeBase "file:/C:/Files/FileIOApplet/-" {
  permission java.io.FilePermission "<<ALL FILES>>", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "write";
};

grant codeBase "file:///-" {
  permission java.io.FilePermission "<<ALL FILES>>", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "write";
};

grant codeBase  "file:${user.home}/-"
{
  permission java.io.FilePermission "<<ALL FILES>>", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "write";
};

:

  • Firefox 3.6.10
  • Java 1.6 25
  • Windows 7 64

.java.policy?

Java-, , !

+3
2

:

policyTool, :

java->jdk1.3->bin->policyTool Application

.
" " " ".

CodeBase ":/path java bin".

CodeBase   file:/c:/java/jdk1.3/bin/

" " " " .
""

" " "".
"".

" " " " .

"" RunTimepermission " " ". " " "accessClassInpackage", accessClassInpackage.sun.jdbc.odbc

"".

"done" " " .

- > "bin" Java. ... , .. appletpermission ''

java

javac programname.java

, :

appletviewer -J-Djava.security.policy=appletpermission programname.java

.

+4

, :

:

0

All Articles