🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #365

Re: AccessControlException : Access Denied

#365
From: Daniel J. Woods
Date: Thu, 10 Aug 2000 00:00
96 lines
5143 bytes
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.Goovaerts@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.
Technical Details
Message-ID: <39928C32.EDAD2338@gssec.bt.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <f_sk5.13$gG5.927@nreader1.kpnqwest.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6e60,b304918546c7951d,start
X-Google-Attributes: gidf6e60,public
X-Google-Thread: f5d71,b304918546c7951d,start
X-Google-Attributes: gidf5d71,public
X-Google-Thread: 10d861,b304918546c7951d,start
X-Google-Attributes: gid10d861,public
X-Google-Thread: fecd1,b304918546c7951d,start
X-Google-Attributes: gidfecd1,public
X-Google-Thread: 10d6db,b304918546c7951d,start
X-Google-Attributes: gid10d6db,public
X-Google-Thread: 10fd6d,b304918546c7951d,start
X-Google-Attributes: gid10fd6d,public
X-Google-Thread: 113ae9,b304918546c7951d,start
X-Google-Attributes: gid113ae9,public
X-Google-Thread: 107d55,b304918546c7951d,start
X-Google-Attributes: gid107d55,public
From: "Daniel J. Woods" <dwoods@gssec.bt.co.uk>
Subject: Re: AccessControlException : Access Denied
Date: 2000/08/10
Message-ID: <39928C32.EDAD2338@gssec.bt.co.uk>
X-Deja-AN: 656711211
Content-Transfer-Encoding: 7bit
References: <f_sk5.13$gG5.927@nreader1.kpnqwest.net>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: postmaster@axion.bt.co.uk
X-Trace: pheidippides.axion.bt.co.uk 965905856 16832 132.146.14.55 (10 Aug 2000 11:10:56 GMT)
Organization: BT Adastral Park, Martlesham Heath, Ipswich, UK
Mime-Version: 1.0
NNTP-Posting-Date: 10 Aug 2000 11:10:56 GMT
Newsgroups: comp.lang.java,comp.lang.java.api,comp.lang.java.gui,comp.lang.java.help,comp.lang.java.tech,algonet.www.java,alt.www.hotjava,aus.computers.java