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!