List of usage examples for java.security PermissionCollection implies
public abstract boolean implies(Permission permission);
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 ww. j a v a2 s . c o m*/ if (pc.implies(new FilePermission("C://test.txt", "read"))) { System.out.println("Permission for C://test.txt is read"); } }
From source file:Main.java
public static void main(String[] args) { // Build property permissions collection PropertyPermission permission = new PropertyPermission("java.*", "read"); PermissionCollection permissions = permission.newPermissionCollection(); permissions.add(permission);/* w w w . j a v a2 s .c o m*/ permissions.add(new PropertyPermission("java.home.*", "read,write")); if (permissions.implies(new PropertyPermission("java.home", "read"))) { System.out.println("Has permissions on " + "java.home" + " for read"); } if (permissions.implies(new PropertyPermission("java.home", "write"))) { System.out.println("Has permissions on " + "java.home" + " for write"); } }
From source file:com.stratuscom.harvester.deployer.StarterServiceDeployer.java
private static Permission[] expandUmbrella(Permission[] perms) { PermissionCollection pc = new Permissions(); for (Permission p : perms) { pc.add(p);/*from w w w . ja v a 2 s .c om*/ } if (pc.implies(new UmbrellaGrantPermission())) { List l = Collections.list(pc.elements()); pc.add(new GrantPermission((Permission[]) l.toArray(new Permission[l.size()]))); } List<Permission> permList = new ArrayList<Permission>(); for (Enumeration<Permission> en = pc.elements(); en.hasMoreElements();) { permList.add(en.nextElement()); } return permList.toArray(new Permission[0]); }