List of usage examples for java.lang System setSecurityManager
public static void setSecurityManager(SecurityManager sm)
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); sm.checkRead("test.txt"); System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); sm.checkPermission(new FilePermission("test.txt", "read,write")); System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); FileDescriptor fd = new FileDescriptor(); sm.checkRead(fd);/* w ww .j a v a 2s . c om*/ System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); sm.checkWrite("test.txt"); System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); FileDescriptor fd = new FileDescriptor(); sm.checkWrite(fd);/*ww w . j a v a2 s.c om*/ System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new SecurityManager(); System.setSecurityManager(sm); // perform the check sm.checkCreateClassLoader();// w w w.j a v a 2 s. c o m System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) throws Exception { InetAddress add = InetAddress.getLocalHost(); System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); sm.checkMulticast(add);/*w ww . j a v a 2 s .co m*/ System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { AccessControlContext acc = AccessController.getContext(); System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new SecurityManager(); System.setSecurityManager(sm); // perform the check sm.checkConnect("www.java2s.com", 8080, acc); System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); // perform the check sm.checkListen(8080);/*from w w w . j a v a 2 s . c om*/ System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); Main sm = new Main(); System.setSecurityManager(sm); // check if accepting access for thread is enabled sm.checkAccess(Thread.currentThread()); System.out.println("Allowed!"); }