new SocketPermission(String host, String action)
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.java2s.com", "connect");
try {
AccessController.checkPermission(sp);
System.out.println("Ok to open socket");
} catch (AccessControlException ace) {
System.out.println(ace);
}
}
}
Related examples in the same category