Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie question : listing a directory & permission 1

Status
Not open for further replies.

RedGhost

Programmer
Jul 7, 2000
11
0
0
US
Well, I've been trying all day to list a directory in Java (under Win95 with Explorer 5.0), only to get an "AccessControlException : Permission denied" message. So, I've read the documentation of Policytool and put .java.policy file in my profile(giving myself all possible permission over this directory). It didn't change a thing. Besides, I didn't quite understand how to give permissions or forbid users from giving permissions to themselves. I mean, if anybody can give himself any permission he wants, it doesn't make sense.
 
I agree- giving anybody any kind of permission they want doesn't always make sense. However, the .policy file resides only on your computer, so you're the only one with access. I have not used the .policy file, and I only came close once. Actually, I came close to using the .security file, which I actually think might better help you. I think what you need to do is edit the java.security file to give yourself permissions to whatever is not currently available to you. You're not granting yourself permission to everything- just whatever you need. However, I'm not sure if that's the problem. Are you just trying to list the contents of a directory? What kind of machine are you running on? That shouldn't matter, it just helps.. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
It seems I just needed to add a line 'poly.url.3=file:/&lt;path of my policyfile&gt;' into my java.security file, so now it works all right in the appletviewer. Is there some way to make it work under Explorer ? Apparently, the damn thing looks for permissions as well (I saw a line about something called PermissionSearchEngine in the JavaConsole) ; so I guess I just have to do something similar ?
 
I'm just getting into Permissions myself- you can set your own permissions using SecurityManager.checkPermission() . Sun has a GREAT article on Permissions at <A HREF=" TARGET="_new"> , I suggest anyone reading up on Permissions should check it out. Also, get the O'Reilly book &quot;Java in a Nutshell&quot;, it'll be a great help to any Java developer.<br><br>There are other tools to use as well... for example, for editing the java.policy file, it may be easier to use the GUI policytool application that comes with the JDK rather than actually edit the text file... and if you're using the JDK for compiling, you can set security/policy info with the -D option.<br><br>Best of luck :eek:) <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Yeah, I'm spending a lot of time reading this site, but it doesn't have many informations on Explorer :(<br>I did use the policytool to create my .policy file, but I don't know how to do the same with IE<br>But thanks for your help anyway.
 
well in the line that throws the exception, try this:<br><br>try {<br>&nbsp;&nbsp;// line that throws exception<br>} catch (AccessControlException ace) {<br>&nbsp;&nbsp;ace.getPermission().getName();<br>}<br><br>then let me know what you find. That's the Permission that's being violated... if you can find that out, we might be able to find a way to handle that permission. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Never mind, I just d/l the Java plugin from Sun and it works all right in IE now (juste had to ctrl+c ctrl+v the line they use in the doc to call the applet, 'cause they use an OBJECT tag with special id). Just have to figure out how to reuse its methods from javascript, now :))<br><br>RedGhost<br>happy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top