I am running a Applet which does Socket connection i am getting
Exception java.security.AccessControlException: access denied (java.net.SocketPermission xxx.xxx.xxx.xxx:80 connect,resolve)
I googled and found out that it is because of Java's security manager so i added
grant{
java.net.SocketPermission xxx.xxx.xxx.xxx:80 "connect";
java.net.SocketPermission xxx.xxx.xxx.xxx:80 "resolve";
}
inside java.policy at C:\Program Files\Java\jre6\lib\security using policytool.exe successfully worked
But I wanted this to be done programmatically so i did the following
AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception {
socketchannel1 = SocketChannel.open();
socketchannel1.connect( new InetSocketAddress( xxx.xxx.xxx.xxx, 80 ) );
return null;} });}
here i am telling securityManager not to touch the code inside run this is also successful But Now I want to know if there is any other method with which i can specifically add SocketPermission to connect,resolve with Policy.setpolicy or something like setpermission or modifying the above itself. Thanks in advance