1 package org.jbpm.identity.security; 2 3 import java.security.*; 4 import java.util.*; 5 import org.jbpm.identity.Entity; 6 7 12 public class IdentityPolicy extends Policy { 13 14 public static final PermissionCollection ALL_PERMISSIONSCOLLECTION = new Permissions(); 15 static { 16 ALL_PERMISSIONSCOLLECTION.add(new AllPermission()); 17 ALL_PERMISSIONSCOLLECTION.setReadOnly(); 18 } 19 20 public void refresh() { 21 } 22 23 public PermissionCollection getPermissions(CodeSource codesource) { 24 return ALL_PERMISSIONSCOLLECTION; 27 } 28 29 public PermissionCollection getPermissions(ProtectionDomain domain) { 30 PermissionCollection permissionCollection = new Permissions(); 31 32 Principal[] principals = domain.getPrincipals(); 33 if (principals!=null) { 35 for (int i=0; i<principals.length; i++) { 37 if (Entity.class.isAssignableFrom(principals[i].getClass())) { 39 Iterator iter = ((Entity)principals[i]).getPermissions().iterator(); 41 while (iter.hasNext()) { 42 permissionCollection.add((Permission) iter.next()); 43 } 44 } 45 } 46 } 47 48 return super.getPermissions(domain); 49 } 50 51 public boolean implies(ProtectionDomain domain, Permission permission) { 52 return getPermissions(domain).implies(permission); 53 } 54 } 55 | Popular Tags |