This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Queries on Builiging a trusted Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Queries on Builiging a trusted Applet" Watch "Queries on Builiging a trusted Applet" New topic
Author

Queries on Builiging a trusted Applet

dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Hi All,

While going through the FAQ section of sun i found this point.

Can applets read or write files?
In Java-enabled browsers, untrusted applets cannot read or write files at all. By default, downloaded applets are considered untrusted. There are two ways for an applet to be considered trusted:

1The applet is installed on the local hard disk, in a directory on the CLASSPATH used by the program that you are using to run the applet. Usually, this is a Java-enabled browser, but it could be the appletviewer, or other Java programs that know how to load applets

Can anybody give me some more input on this. I tried saving my Applet that tries to write a File in the directory that is specified in the ClassPath but it does not work.

Thanks in Advance!!!
dinesh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41178
    
  45
I tried saving my Applet that tries to write a File in the directory that is specified in the ClassPath but it does not work.


First of all, what does "it does not work" mean? Are there any exceptions in the Java Console? If so, which ones?

Is the applet properly initialized, i.e. does the init method finish without problems?

How are you running this applet - with appletviewer, with a file:/// URL in a browser or from a web server?

What does "saving the applet" mean?

Answering these questions will let us help you track down the problem.
[ January 10, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Answer for Question What do i mean by "it does not work"?
Yes, I am getting some exceptions.
java.security.AccessControlException: access denied (java.io.FilePermission Secu
rity.sec write)

Answer for the Question "Is the Applet properly Initialized?"

Yes, the Applet is properly initialized and started since I have placed the code to access File in the paint method.

Regarding Executing the applet.

I have used the appletviewer to run the Applet.

I meant I have made a copy of the Applet class and source in a directory that is present in the ClassPath by the statement saving the applet.

Thanks,
dinesh.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41178
    
  45
Your Java installation may have a security policy that enforces the applet restrictions even for local applets. A starting point for learning about policies can be found here. Make sure that the policy in force allows applet file access.

I have placed the code to access File in the paint method.

That's not such a good idea. The paint method can be called many times, which would lead to the file being read over and over - is that what you want?
dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Thank you!!!
dinesh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Queries on Builiging a trusted Applet
 
Similar Threads
applet security:
some unsure questions on phase 1
reading client-side file from applet
applet security,still confused
Applet Security Clarification