Due to its remote origin (applets are usually downloaded from a server on the Internet) an applet is a potentially dangerous piece of code. By writing malicious applets, programmers might take control of other peopleīs machines, copying or deleting data, formatting disks and so on. To minimize these risks, heavy safety restrictions are applicable to java applets executed within a WWW browser. One of these safety restrictions prevents java applets from accessing the userīs local disks (neither in reading nor writing mode) something that, in principle, means that our PV applet cannot save or load local simulation files.
Fortunately, after the Java 1.2 API release users are allowed to grant special permissions to the browser-applet runtime environment. Basically, the new safety plan implemented by Sun Microsystems consists on the following: applets cannot do anything potentially dangerous unless you explicitly allow them to do it.
Very early in the software design process it was clear that the PV simulator applet should allow users to save and load simulation files. This target, however, was difficult to achieve because of the safety restrictions commented above. Three different solutions were found and tested:
Of these three options only the third has been implemented in the final version of the program. It has proved the best solution from the serverīs organization and security point of view. As regards the user own safety it is also the best solution because the applet will only have permission to access a particular folder in the local machine, while signed applets can read or write anything anywhere.
To summarize, if you want to save or load simulation files on your local machine you must do the following:
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy
After these two lines you must include the following:
policy.url.3=file:${user.home}/fotorred.java.policy
so that your new java.security file looks like this one: new_java.security
grant {
permission java.util.PropertyPermission "user.home","read";
permission java.io.FilePermission "${user.home}${/}PVSIM${/}*", "read,
write";
};
This file grants read permission to find your user.home folder and read-write permissions to access files in a folder called PVSIM (in capitals) located in your user.home path. Access to any other file in your computer will not be allowed. Later on, the applet sets even higher safety restrictions checking that any file written to or read from that path has ".pvs" extension (containing PV simulation data only).
If you are having trouble to find your java.home and user.home folders, download and execute this small Java application: user_paths. This program tries to find these folders in your machine and displays their paths. It is not an applet (security restrictions prevent applets from reading this information) so it is not executed in a browser. You should download the program, save it on your disk, unzip it and execute it by double clicking on the file called launch.bat. If your computer is capable of executing Java applications (it will be if you have ever installed a JDK or a JRE) a window will be displayed showing the path of the two wanted folders.
If your machine cannot execute the application described above and you cannot find your user.home and java.home folders yourself, it looks like your computer is not prepared to execute Java programs and cannot grant security permissions. To learn more about how to configure your machine to work with Java please visit http://www.javasoft.com.