File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Enforcing custom policies using policytool - reg. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enforcing custom policies using policytool - reg." Watch "Enforcing custom policies using policytool - reg." New topic

Enforcing custom policies using policytool - reg.

dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Hi Friends,

I have written a small code to connect to google. Here is the code:

And here is my policy file:

Then, I tried to execute the Connector class in the presence of DefaultSecurityManager and this policy file using the following command line:

java Connector access denied ( connect,resolve)
at Source)
at Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at Source)
at Source)
at<init>(Unknown Source)
at<init>(Unknown Source)
at Connector.main(

Can anybody help me to find what is wrong in my approach?

Thanks in Advance!
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 691
I've had problems with policytool in the past writing bad java.policy files and I've had to manually edit them.
Here's a grant line from my policy file. Note the single / after file:
grant codeBase "file:/D:/Testing/-" {
I agree. Here's the link:
subject: Enforcing custom policies using policytool - reg.
It's not a secret anymore!