import java.net.SocketPermission;
import java.security.AccessControlException;
import java.security.AccessController;
public class AccessTest {
public static void main(String[] a) {
SocketPermission sp = new SocketPermission("www.java2java.com", "connect");
try {
AccessController.checkPermission(sp);
System.out.println("Ok to open socket");
} catch (AccessControlException ace) {
System.out.println(ace);
}
}
}
|