Skip to main content

applet problem

7 replies [Last post]
manojtyagi
Offline
Joined: 2006-02-17

hye
i added toolbar in applet.
but on the tool bar ,image icon does not display image icon on toolbar's buttons.
following run time Exception is thrown.
java.security.AccessControlException: access denied (java.io.FilePermission e://guieditor/image/undo.gif read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkRead(SecurityManager.java:863)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:472)
at sun.awt.SunToolkit.getImage(SunToolkit.java:486)
at javax.swing.ImageIcon.(ImageIcon.java:81)
at javax.swing.ImageIcon.(ImageIcon.java:107)
at htmledit$UndoAction.(htmledit.java:434)
at htmledit.(htmledit.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.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)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Andrei V. Dmitriev

hi manoj,

possibly you should use policytool from JDK to permit reading files. Run it.
Then select Add policy entry-> Add permission -> Choose in Permissions
list "FilePermission".
Press OK.
Press Done.
This is because of applet security policy.

-Andrei

swing-feedback@javadesktop.org wrote:
> hye
> i added toolbar in applet.
> but on the tool bar ,image icon does not display image icon on toolbar's buttons.
> following run time Exception is thrown.
> java.security.AccessControlException: access denied (java.io.FilePermission e://guieditor/image/undo.gif read)
> at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
> at java.security.AccessController.checkPermission(AccessController.java:401)
> at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
> at java.lang.SecurityManager.checkRead(SecurityManager.java:863)
> at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:472)
> at sun.awt.SunToolkit.getImage(SunToolkit.java:486)
> at javax.swing.ImageIcon.(ImageIcon.java:81)
> at javax.swing.ImageIcon.(ImageIcon.java:107)
> at htmledit$UndoAction.(htmledit.java:434)
> at htmledit.(htmledit.java:30)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.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)
> ---
> [Message sent by forum member 'manojtyagi' (manoj)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=41324&#41324

manojtyagi
Offline
Joined: 2006-02-17

but if i run policy tool it does not find the java.policy file
i gives the error "could not find policy file in c:\Documents and setting\administrator\java.policy"
if i put the java.policy file in this path it still gives
the same error.
what should i do now?

Andrei V. Dmitriev

You should
1) run policytool (you'll see "could not find policy file..." message)
2) click "OK"
3) click "add policy entry", than "add permission"
4) select "All permissions"
5) click OK, than DONE
6) In the menu choose File-> Save As -> c:\Documents and
setting\administrator\.java.policy
Note that the name of policy file must be ".java.policy", not
"java.policy" :)
7) close policytool

Thats all.

.java.policy

swing-feedback@javadesktop.org wrote:
> but if i run policy tool it does not find the java.policy file
> i gives the error "could not find policy file in c:\Documents and setting\administrator\java.policy"
> if i put the java.policy file in this path it still gives
> the same error.
> what should i do now?
> ---
> [Message sent by forum member 'manojtyagi' (manoj)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=44196&#44196

manojtyagi
Offline
Joined: 2006-02-17

hye,
thank a lot. it's working.
actually this applet would reside on the server and be called by the client.
if the client calls it and click on the menu "open" on the applet , JFileChooser displays. JFIleChooser should display the files of the client.
my applet is showing the file of local system.
if the applet is reside on the server
what are the steps to change the security?

Andrei V. Dmitriev

Actually this is not correct, applets are always works in browsers and
they don't have access to server's file system. Changing security
probably will not help in this case.

swing-feedback@javadesktop.org wrote:
> hye,
> thank a lot. it's working.
> actually this applet would reside on the server and be called by the client.
> if the client calls it and click on the menu "open" on the applet , JFileChooser displays. JFIleChooser should display the files of the client.
> my applet is showing the file of local system.
> if the applet is reside on the server
> what are the steps to change the security?
> ---
> [Message sent by forum member 'manojtyagi' (manoj)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=44201&#44201

manojtyagi
Offline
Joined: 2006-02-17

when the user would acces the applet through browser,
obviously, user would be able to open the client files only.
at that time if user click on the menu "open"
JFileChooser would display client files or security exception will be thrown.
is there required security change ?
if yes , what the steps?

idk
Offline
Joined: 2005-01-12

Hi,

There is 'Applet Security FAQ':

http://java.sun.com/sfaq/#read

Thanks,
Igor