aspose file tools*
The moose likes Applets and the fly likes java .security .AccessControlException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "java .security .AccessControlException" Watch "java .security .AccessControlException" New topic
Author

java .security .AccessControlException

Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi all the ranchers
When I run the JApplet in the browser,the status bar in the browser give me java.security.AccessControlException: access denied (java.io.FilePermission i.gif read)
The first question is
Could the JApplet run on browser without putting it in server?
And
How can I cope with the problem?
thanks for your time to answer


Francis Siu
SCJP, MCDBA
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi sui,
Could the JApplet run on browser without putting it in server?
yes. u write the applet on ur machine.
prepare the HTML file.
view it on local browser.
also, the image that the JApplet is trying to get "i.gif" is where? do u have a jar file for the applet? if u have the jar file then u can put ur image in that jar file and get the iamge via getResourceAsStream() or something from the applet instead referring to the file directly via,
Image img = new Image("i.gif") u know...
regards
maulin
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Maulin
thanks you for reply
the image that the JApplet is trying to get "i.gif" is where?
In the same folder of that html and the required class.
I do not know why I can not read the .gif file

Actually,I can run on the JBuilder but I can not run on local browser.
do u have a jar file for the applet?
No.
Do I need to make a jar file for the JApplet?
thanks for your attention
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
A little bit confuse of the following


checkPermission
public void checkPermission(Permission perm)
throws AccessControlExceptionDetermines
whether the access request indicated by the specified permission should be allowed or denied, based on the security policy currently in effect, and the context in this object.
This method quietly returns if the access request is permitted, or throws a suitable AccessControlException otherwise.

Parameters:
perm - the requested permission.
Throws:
AccessControlException - if the specified permission is not permitted, based on the current security policy and the context encapsulated by this object.

Can I override the above method so that I can set the permission of the action
But I do not know the object reference of the Permission object,Can I use Permission object point to the pathname of a file?
Most Permission objects also include an "actions" list that tells the actions that are permitted for the object. For example, for a java.io.FilePermission object, the permission name is the pathname of a file (or directory), and the actions list (such as "read, write") specifies which actions are granted for the specified file (or for files in the specified directory). The actions list is optional for Permission objects, such as java.lang.RuntimePermission, that don't need such a list; you either have the named permission (such as "system.exit") or you don't.

please help me how do I need to do.
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java .security .AccessControlException