Example usage for java.security PermissionCollection elements

List of usage examples for java.security PermissionCollection elements

Introduction

In this page you can find the example usage for java.security PermissionCollection elements.

Prototype

public abstract Enumeration<Permission> elements();

Source Link

Document

Returns an enumeration of all the Permission objects in the collection.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ProtectionDomain domain = String.class.getProtectionDomain();
    PermissionCollection pcoll = Policy.getPolicy().getPermissions(domain);
    Enumeration e = pcoll.elements();
    for (; e.hasMoreElements();) {
        Permission p = (Permission) e.nextElement();
    }// www.j a v a 2 s. c o m
}

From source file:Main.java

public static void main(String args[]) {
    ProtectionDomain domain = "".getClass().getProtectionDomain();

    PermissionCollection pcoll = Policy.getPolicy().getPermissions(domain);

    Enumeration e = pcoll.elements();
    for (; e.hasMoreElements();) {
        Permission p = (Permission) e.nextElement();
        System.out.println(p);/*from   w  ww . j a  v  a2  s .  co  m*/

    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    SecurityManager sm = new SecurityManager();
    System.setSecurityManager(sm);
    URL codebase = new URL("http://java.sun.com/");

    //codebase = new File("c:\\java\\").toURI().toURL();
    //codebase = new File(System.getProperty("user.home")).toURI().toURL();

    CodeSource cs = new CodeSource(codebase, (Certificate[]) null);

    PermissionCollection pcoll = Policy.getPolicy().getPermissions(cs);

    Enumeration e = pcoll.elements();
    for (; e.hasMoreElements();) {
        Permission p = (Permission) e.nextElement();
    }/*w w  w .j av  a2  s.c  om*/
}

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);//  w w  w.  j a va 2  s . c  o  m
    }
    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]);
}

From source file:com.seeburger.vfs2.util.VFSClassLoader.java

/**
 * Copies the permissions from src to dest.
 * @param src The source PermissionCollection.
 * @param dest The destination PermissionCollection.
 *///  w w  w .ja  va 2s  . c  o m
protected void copyPermissions(final PermissionCollection src, final PermissionCollection dest) {
    for (Enumeration<Permission> elem = src.elements(); elem.hasMoreElements();) {
        final Permission permission = elem.nextElement();
        dest.add(permission);
    }
}

From source file:org.jboss.dashboard.security.UIPolicy.java

public Permission getPermission(Principal prpal, Class permClass, String permName) {
    PermissionCollection permCollection = getPermissions(prpal);
    if (permCollection != null) {
        Enumeration en = permCollection.elements();
        while (en.hasMoreElements()) {
            Permission perm = (Permission) en.nextElement();
            if (perm.getName().equals(permName) && perm.getClass().getName().equals(permClass.getName())) {
                return perm;
            }//from  w  w w  .  j  av  a 2 s .co m
        }
    }
    return null;
}