AccessController: checkPermission(Permission perm)
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