Please help, **** policy files

Hi,

I need to load a signed applet with applet viewer. I have done the following

linked my policy file(which grants all permissions) to the .java.security file.

Following are excerpts from files pasted:

java.security

policy.url.1=file:${java.home}/lib/security/java.policy

policy.url.2="file:/C:/Documents and Settings/Administrator/Desktop/Spring 2004/CS 441/Project Part A/web/abhi.policy"

abhi.policy

/* AUTOMATICALLY GENERATED ON Thu Mar 11 08:06:09 CST 2004*/

/* DO NOT EDIT */

keystore "tiredstore.ks", "ks";

grant codeBase "file:/C:/Documents and Settings/Administrator/Desktop/Spring 2004/CS 441/Project Part A/web/graph.html" {

permission java.security.AllPermission;

};

graph.html

<HTML>

<BODY>

<APPLET CODE=abhi/MyView.class ARCHIVE="spooplet.jar" WIDTH=800 HEIGHT=800>

</APPLET>

</BODY>

</HTML>

I have been trying to figure this out, but to no avail, How do I even kow if the policy files are being used? apprently they are not because following is the error I get

Command run to invoke appletviewer

"C:\j2sdk1.4.2_03\bin\appletviewer" "file:/C:/Documents and Settings/Administrator/Desktop/Spring 2004/CS 441/Project Part A/web/graph.html"

Error from applet

java.security.AccessControlException: access denied (java.util.PropertyPermissio

n user.dir read)

at java.security.AccessControlContext.checkPermission(AccessControlConte

xt.java:269)

at java.security.AccessController.checkPermission(AccessController.java:

401)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)

at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12

76)

at java.lang.System.getProperty(System.java:573)

at java.io.Win32FileSystem.getUserPath(Win32FileSystem.java:272)

at java.io.Win32FileSystem.resolve(Win32FileSystem.java:288)

at java.io.File.getAbsolutePath(File.java:459)

at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:191)

at sun.awt.shell.Win32ShellFolder2.listFiles(Win32ShellFolder2.java:504)

at sun.awt.shell.ShellFolder.listFiles(ShellFolder.java:115)

at sun.awt.shell.Win32ShellFolderManager2.get(Win32ShellFolderManager2.j

ava:189)

at sun.awt.shell.ShellFolder.get(ShellFolder.java:245)

at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFile

ChooserUI.java:311)

at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserU

I.java:130)

at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserU

I.java:152)

at javax.swing.JComponent.setUI(JComponent.java:449)

at javax.swing.JFileChooser.updateUI(JFileChooser.java:1701)

at javax.swing.JFileChooser.setup(JFileChooser.java:345)

at javax.swing.JFileChooser.<init>(JFileChooser.java:320)

at javax.swing.JFileChooser.<init>(JFileChooser.java:273)

at abhi.MyView.<init>(MyView.java:56)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct

orAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC

onstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:274)

at java.lang.Class.newInstance0(Class.java:308)

at java.lang.Class.newInstance(Class.java:261)

at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)

at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)

at sun.applet.AppletPanel.run(AppletPanel.java:298)

at java.lang.Thread.run(Thread.java:534)

[3921 byte] By [atlantisLoveAngel] at [2007-9-30 2:54:58]
# 1

hi,

those security errors and policy files are annoying,

try this:

regenerate your policy file and save it in your directory that you are running the applet from,

in your case it's

--> C:/Documents and Settings/Administrator/Desktop/Spring 2004/CS 441/Project Part A/web/

save it as mypolicy.txt or whatever.

then in the command where you are running appletviewer type:

(make sure you are in the directory where your graph.html file and policy.txt files are),

-J-Djava.security.policy=mypolicy.txt graph.html

this should work,

good luck.

b737-800 at 2007-6-29 10:52:47 > top of Java-index,Security,Signed Applets...
# 2

Those policy file was in the same directory. It works when I give it all permissions like in the following

keystore "tiredstore.ks", "ks";

grant {

permission java.security.AllPermission;

};

but DOES NOT work when I specify a codebase in there. Hence:

1. DOes the html file need to have the CODEBASE tag in the applet

2. Also, let says this jar file is running of a remote server and this jar reads and writes to text files and loads images, then we would need to configure this on the server right?

atlantisLoveAngel at 2007-6-29 10:52:47 > top of Java-index,Security,Signed Applets...