1 13 14 package org.ejbca.core.model.authorization; 15 16 import java.io.Serializable ; 17 import java.util.Collection ; 18 import java.util.Iterator ; 19 26 public class AccessTree implements Serializable { 27 28 public AccessTree() {} 29 30 32 public void buildTree(Collection admingroups) { 33 rootnode = new AccessTreeNode("/"); 34 35 Iterator iter = admingroups.iterator(); 36 while(iter.hasNext()){ 38 AdminGroup admingroup = (AdminGroup) iter.next(); 39 Iterator iter2 = admingroup.getAccessRules().iterator(); 40 while(iter2.hasNext()){ 41 AccessRule accessrule = (AccessRule) iter2.next(); 42 rootnode.addAccessRule(accessrule.getAccessRule(),accessrule,admingroup); } 44 } 45 } 46 47 48 public boolean isAuthorized(AdminInformation admininformation, String resource){ 49 String checkresource = resource; 50 if((checkresource.toCharArray())[0] != '/') 52 checkresource = "/" + checkresource; 53 54 boolean retval = rootnode.isAuthorized(admininformation, checkresource); 56 return retval; 57 } 58 59 60 61 private AccessTreeNode rootnode = null; 63 64 } 65 | Popular Tags |