| |||||||||||
| 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 systemThis 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 fileswrap.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 archiveTo install, download the zip file to C:, then unzip, so that the files end up as C:\minlocal\hi_world.minand 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.batappletviewer -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).
Referencehttp://java.sun.com/docs/books/tutorial/security1.2/tour1/step3.html
RemarksThis 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 AppletsMINERVA deployment as signed applet is same as Java signed applets. There are 5 steps:
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.
| |||||||||||
| |||||||||||
| Back> |
|