List of usage examples for java.io FilePermission FilePermission
FilePermission(String path, int mask)
From source file:Main.java
public static void main(String[] args) throws IOException { FilePermission fp = new FilePermission("C://test.txt", "read"); // the canonical string representation of the action String s = fp.getActions();/* ww w . ja v a2 s.com*/ System.out.print("Action: " + s); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Permission perm1 = new FilePermission("/tmp/*", "read,write"); Permission perm2 = new FilePermission("/tmp/abc", "read"); if (perm1.implies(perm2)) { System.out.println("perm1 implies perm2"); }/* ww w.j a v a2s . c o m*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { FilePermission fp = new FilePermission("C://test.txt", "read"); // the hash code value int hash = fp.hashCode(); System.out.print("Hash Code: " + hash); }
From source file:Main.java
public static void main(String[] argv) throws Exception { AccessController.checkPermission(new FilePermission("/tmp/*", "read,write")); }
From source file:Main.java
public static void main(String[] args) throws IOException { FilePermission fp = new FilePermission("C://test.txt", "read"); FilePermission fp1 = new FilePermission("C://test1.txt", "read"); FilePermission fp2 = new FilePermission("C://test.txt", "write"); FilePermission fp3 = new FilePermission("C://test.txt", "read"); boolean bool = fp.equals(fp1); System.out.println(bool);// w w w. ja va 2s. c om bool = fp.equals(fp2); System.out.println(bool); bool = fp.equals(fp3); System.out.print(bool); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { FilePermission fp = new FilePermission("c:\\autoexec.bat", "read"); AccessController.checkPermission(fp); }
From source file:Main.java
public static void main(String[] args) throws IOException { // create new file permissions FilePermission fp = new FilePermission("C://test.txt", "read"); FilePermission fp1 = new FilePermission("C://test.txt", "write"); FilePermission fp2 = new FilePermission("C://test1.txt", "read"); FilePermission fp3 = new FilePermission("C://test.txt", "read"); // tests if implied by this object boolean bool = fp.implies(fp1); // print//from w ww . ja v a 2s . co m System.out.println(bool); bool = fp.implies(fp2); System.out.println(bool); bool = fp.implies(fp3); System.out.print(bool); }
From source file:Main.java
public static void main(String[] args) throws IOException { // create new file permissions FilePermission fp = new FilePermission("C://test.txt", "read"); // create new permission collection PermissionCollection pc = fp.newPermissionCollection(); // add permission to the permission collection pc.add(fp);/*from w w w . j ava 2s . c om*/ if (pc.implies(new FilePermission("C://test.txt", "read"))) { System.out.println("Permission for C://test.txt is read"); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { SecurityManager sm = System.getSecurityManager(); if (sm != null) { FilePermission fp = new FilePermission("c:\\autoexec.bat", "read"); sm.checkPermission(fp);/*from ww w . ja v a2s .c om*/ } if (sm != null) { AWTPermission ap = new AWTPermission("accessClipboard"); sm.checkPermission(ap); } System.out.println("Has AWTPermission to access AWT Clipboard"); }
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!"); }