File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Security and the fly likes Problem with policy file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » Security
Reply Bookmark "Problem with policy file" Watch "Problem with policy file" New topic
Author

Problem with policy file

Kurro Zaki
Greenhorn

Joined: Dec 08, 2009
Posts: 14
I have a weird problem with my policy file.
I want code in F:\Users\xxxxxx\Documents\NetBeansProjects\Nimbus\build\classes\org\nimbus\kernel\ to have all permissions. So I write the following policy file:




But if I now want to open a PrintStream to F:\Users\xxxxxx\Documents\NetBeansProjects\Nimbus\build\classes\log\1260255799533.log I get a java.security.AccessControlException

The code:




the stacktrace:




The only way I can get around the exception is by changing the codebase to file:/F:/Users/Jan-Pieter/Documents/NetBeansProjects/Nimbus/build/classes

But this is unacceptable as I don't trust all the code in that directory. I only want file:/F:/Users/xxxxxx/Documents/NetBeansProjects/Nimbus/build/classes/org/nimbus/kernel to get all the permissions


What is the problem with this? I can't figure it out.

Thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
codeBase works somewhat like the classpath - you can specify a jar file or a directory containing the root of a class file hierarchy, but not arbitrary directories in the middle of the package hierarchy.

The easiest would probably be to move the class needing special permissions to its own jar file, and grant that jar file the permission. Handling that can easily be automated in the build file.


Android appsImageJ pluginsJava web charts
Kurro Zaki
Greenhorn

Joined: Dec 08, 2009
Posts: 14
That was the problem. Thanks very much.
 
 
subject: Problem with policy file
 
Threads others viewed
Triangle Problem
JSP error again
System.out & System.err to log files in iPlanet Web Server 6.0
How to redirect an OutputStream
Using Collator / CollationKey objects for String comparision
developer file tools