• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enforcing custom policies using policytool - reg.

 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 -Djava.security.manager -Djava.security.policy=test.policy Connector

java.security.AccessControlException: access denied (java.net.SocketPermission 209.85.153.104:80 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at Connector.main(Connector.java:6)

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

Thanks in Advance!
 
Norm Radder
Ranch Hand
Posts: 733
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/-" {
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic