1 22 package org.jboss.test.jacc.test.portal; 23 24 import org.jboss.logging.Logger; 25 26 import java.io.Serializable ; 27 import java.security.Permission ; 28 import java.security.PermissionCollection ; 29 import java.util.Enumeration ; 30 import java.util.Iterator ; 31 import java.util.Vector ; 32 33 40 public final class PortalObjectPermissionCollection extends PermissionCollection implements Serializable 41 { 42 private static Logger log = Logger.getLogger(PortalObjectPermissionCollection.class); 43 private final Vector permissions; 44 private boolean trace; 45 46 public PortalObjectPermissionCollection() 47 { 48 trace = log.isTraceEnabled(); 49 if (trace) 50 { 51 log.trace("creating portal object permission collection..."); 52 } 53 54 permissions = new Vector (); 55 } 56 57 public void add(Permission permission) 58 { 59 if (trace) 60 { 61 log.trace("adding " + permission); 62 } 63 64 if (!(permission instanceof PortalObjectPermission)) 65 { 66 throw new IllegalArgumentException (); 67 } 68 permissions.add(permission); 69 } 70 71 public boolean implies(Permission permission) 72 { 73 if (trace) 74 { 75 log.trace("implies ? " + permission); 76 } 77 if (!(permission instanceof PortalObjectPermission)) 78 { 79 return false; 80 } 81 82 Iterator permIterator = permissions.iterator(); 83 while (permIterator.hasNext()) 84 { 85 PortalObjectPermission p = (PortalObjectPermission)permIterator.next(); 86 if (p.implies(permission)) 87 { 88 return true; 89 } 90 } 91 92 return false; 93 } 94 95 public Enumeration elements() 96 { 97 return permissions.elements(); 98 } 99 } 100 | Popular Tags |