Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AccessControlException : Access Denied

0 views
Skip to first unread message

Daniel J. Woods

unread,
Aug 10, 2000, 3:00:00 AM8/10/00
to
Applets can't use file I/O on the host machine unless they've been
expressly given permission to do so using digital signatures (a lengthy
process I'm none too keen on). The rationale behind this comes from the
fact that applets are essentially untrusted code which is downloaded
from some remote source and run on your browser--not something you want
to be snooping around your hard-drive (potentially deleting whatever it
wants).

Aside from the digital signatures thingy, applets can only load files
from the server from which it was downloaded. This involves establishing
a connection to the server a la:
...
URL myFile;
InputStream fileStream;

try {
myFile = new URL(getCodeBase(),"somefile.whatever");
} catch(MalformedURLException murle) {
// exception handling stuff
}

try {
fileStream = myFile.openStream();
// other stuff like reading
} catch(IOException ioe) {
// more exception handling stuff
}

etc.

The important thing to remember is that the applet was (presumably)
downloaded from some Web-server somewhere, and that it doesn't have
access to the user's PC at all--only resources on the server are
available.

Hope that's useful,

Danny.

P.Goo...@Clipper.Be wrote:

>
> We are new in the Java world and agree that this is a very powerfull
> language but ... how the ... do you learn it ? We are stuck under
> lots of books, url's, newsgroups,... where is the time you bought an
> RPG / COBOL book and started to program ...
>
> OK, after a couple of weeks we are able to create little 'stand alone'
> Java programs wich runs fine on our PC. The application(s) retrieves
> records from the AS400 using DPC and displays them on screen. Then we
> changed them into an applet by adding (extends JAPPLET) and replacing
> the main() method by init() method. All neccessary classes and images
> are stored on AS400Webfolder. (We didn't pack them in a Jar file).
>
> Compile give no error but when calling URL in browser, following
> happens :
> - jt400.jar file loads (archive=jt400.jar in htmldoc)
> - message is shown that Class xxxx is not found.
>
> Then I call same applet with appletviewer and following occurs :
>
> - AccessControlException occurs with following details:
>
> C:\WINDOWS>appletviewer http://s44a5189:2021/BH_HTTP/Conti.html
> java.security.AccessControlException: access denied
> (java.io.FilePermission butt
> o61c.gif read)
> at
> java.security.AccessControlContext.checkPermission(AccessControlConte
> xt.java:195)
> at
> java.security.AccessController.checkPermission(AccessController.java,
> Compiled Code)
> at
> java.lang.SecurityManager.checkPermission(SecurityManager.java, Compi
> led Code)
> at
> java.lang.SecurityManager.checkRead(SecurityManager.java:873)
> at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:242)
> at sun.awt.SunToolkit.getImage(SunToolkit.java:256)
> at javax.swing.ImageIcon.<init>(ImageIcon.java:64)
> at javax.swing.ImageIcon.<init>(ImageIcon.java:83)
> at Conti.<init>(Conti.java:54)
> at java.lang.Class.newInstance0(Native Method)
> at java.lang.Class.newInstance(Class.java:241)
> at sun.applet.AppletPanel.createApplet(AppletPanel.java:517)
> at sun.applet.AppletPanel.runLoader(AppletPanel.java:453)
> at sun.applet.AppletPanel.run(AppletPanel.java:291)
> at java.lang.Thread.run(Thread.java:479)

--
Danny Woods
Software Engineer
BT CDMC Data Quality
-- Unless otherwise stated, what's in this mail is purely my opinion,
-- not that of BT.

Bill Hamlin

unread,
Aug 10, 2000, 3:00:00 AM8/10/00
to
I have a related question. I have an applet that uses the java.net.Socket
class. It runs OK in Netscape but for it to run in IE I need to set the
security level to "Low". I'm opening a socket to a port on the same machine
from which I load the web page/applet.

Is there a way for me to get this to run in the "Medium" level (I'm running
IE 5.0 by the way).


Daniel J. Woods <dwo...@gssec.bt.co.uk> wrote in message
news:39928C32...@gssec.bt.co.uk...

0 new messages