Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / March 2004

Tip: Looking for answers? Try searching our database.

AccessControlException with Appletviewer and policyfile...

Thread view: 
Klaas van Gelder - 24 Feb 2004 10:51 GMT
Hi,

Evaluating a (pretty old) security tutorial from Sun, I encounter a
very strange problem.
In the example, an applet trying to write a file on local disk is
loaded from the website of Sun, at first without any security policy:

appletviewer http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/WriteFil
e.html


As expected, an AccessControlException is thrown

Second, a policyfile called "mypolicy" is created to grant the code
from the Sun-url file-write permission:

grant codeBase "http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/"
{
 permission java.io.FilePermission "writetest", "write";
};

Now I run the applet specifying this policyfile on the commandline:

appletviewer -J-Djava.security.policy=mypolicy
http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/WriteFil
e.html


This works OK, the the applet writes a file to the disk.

But now, I insert the following line in the java.security file:
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy
#new line added by me...
policy.url.3=file:c:/temp/mypolicy  

The policyfile is located in c:/temp. The tutorial suggests that I
should now be able to run the applet WITHOUT specifying the policyfile
on the commandline. But when I try this, an AccessControlException is
thrown again, as if the AppletViewer were not able to locate the the
java.security file.

I use JSK version 1.4.1_03, the java.security file is located at
c:/j2sdk1.4.1_03/jre/lib/security.
So does the appletviewer look in that location for the java./security
file ? Or do i miss someting else ???

Greetz, Klaas
KC Wong - 05 Mar 2004 08:57 GMT
> I use JSK version 1.4.1_03, the java.security file is located at
> c:/j2sdk1.4.1_03/jre/lib/security.
> So does the appletviewer look in that location for the java./security
> file ? Or do i miss someting else ???

When installing JDK, a JRE is always installed under JAVA_HOME/jre. It will
also ask if you'd like to install a "public" JRE. This "public" JRE will be
by default in C:/Program Files/...

It's most likely you were using the "public" JRE.

HTH,

KC


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.