AppletLoadsFile

MINERVA applets can access the local file system and other restricted resources according to the Java security model, either with a policy file on the client machine or with signed applets.

Applet handles files on local file system

This example applet shows how to read a text file, and how to load and execute a MINERVA program from the local machine.
Applet output goes to Java console
(This applet has no graphics or anything visible.)

Server side files

wrap.html (as this file, look at the source to see the applet tag)
Compile.sh compile command
localfile.min applet source
localfile.mbc applet object
localfile.mpk

Local machine side files (to be extracted to C:\minlocal\)

minlocal.zip archive

To install, download the zip file to C:, then unzip, so that the files end up as

C:\minlocal\hi_world.min 
and read README.txt . Since the applet program uses this location, you will also need to adapt the server side program if you want to use another location.

Sample HTTP client C:\minlocal\Go.bat

appletviewer -J-Djava.security.policy=mypolicy   http://www.ifcomputer.co.jp/MINERVA/ExamplePrograms/MinervaFeatures/AppletLoadsFile/wrap.html
(this must all be in one line)

Sample policy file C:\minlocal\mypolicy

grant codeBase "http://www.ifcomputer.co.jp/-" {
  permission java.security.AllPermission;
};
This policy file is used explicitly in the invocation of appletviewer (see Go.bat).

Reference

http://java.sun.com/docs/books/tutorial/security1.2/tour1/step3.html

Remarks

This code was tested with Sun JDK1.3 appletviewer, with Opera 6.05, and with Mozilla 1.1 all on Microsoft Windows98SE.

This example requires use of Sun Java, it will not work with Microsoft Java virtual machines.

The installation of the policy file is browser dependent.

For JDK, instead of passing the policy file to appletviewer, you could edit

C:\jdk1.3.1\jre\lib\security\java.policy

For Opera, you could edit

C:\Program Files\Opera\Classes\Opera.policy

For Mozilla, you could edit

C:\Windows\.java.policy

For Internet Explorer, use the Sun Java plugin.

Signed Applets

MINERVA deployment as signed applet is same as Java signed applets. There are 5 steps:
  1. make a program that works with a policy file
    a good example is the program presented here. It does not need any modification.
  2. read the friendly manual about Java signed applets
    You find this in the documentation of your Java processor. If you plan to skip this, please skip signed applets.
  3. buy a certificate or make a self-signed certificate
    e.g.
    keytool -genkey -alias test -keypass testpassword -keystore $HOME/keystore
    all in one line
  4. sign the jar holding the MINERVA classes and your own classes if any. e.g.
    jarsigner -keystore $HOME/keystore -storepass mykeystore -keypass testpassword -signedjar $MINERVA_HOME/signed_minrt.jar $MINERVA_HOME/minrt.jar test
    all in one line
  5. change your applet tag to use the signed jar

Notes:

Some browsers including appletviewer do not accept self-signed certificates, and they will not tell you. This code was tested with server side Sun JDK1.4 tools on Linux, client side Sun JDK1.4 appletviewer, with Opera 7.23, and with Mozilla 1.1 all on Microsoft Windows98SE.


–ß‚é ‘±‚­..