1 package com.sslexplorer.policyframework; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 import java.util.Map ; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 import com.sslexplorer.boot.PropertyList; 13 import com.sslexplorer.core.CoreEvent; 14 import com.sslexplorer.core.CoreServlet; 15 import com.sslexplorer.security.Role; 16 import com.sslexplorer.security.SessionInfo; 17 import com.sslexplorer.security.User; 18 19 20 27 public abstract class AbstractPolicyDatabase implements PolicyDatabase { 28 29 protected Map resourceTypes = new HashMap (); 30 31 36 public void registerResourceType(ResourceType resourceType) throws Exception { 37 resourceTypes.put(String.valueOf(resourceType.getResourceTypeId()), resourceType); 38 } 39 40 45 public void deregisterResourceType(ResourceType resourceType) throws Exception { 46 resourceTypes.remove(String.valueOf(resourceType.getResourceTypeId())); 47 } 48 49 54 public ResourceType getResourceType(int resourceTypeId) { 55 return (ResourceType) resourceTypes.get(String.valueOf(resourceTypeId)); 56 } 57 58 63 public List getResourceTypes(String permissionClass) throws Exception { 64 List l = new ArrayList (); 65 Map.Entry entry; 66 for (Iterator i = resourceTypes.entrySet().iterator(); i.hasNext();) { 67 entry = (Map.Entry ) i.next(); 68 if (permissionClass == null || permissionClass.equals(((ResourceType) entry.getValue()).getPermissionClass())) { 69 l.add(entry.getValue()); 70 } 71 } 72 return l; 73 } 74 75 80 public int getResourceTypeCount() { 81 return resourceTypes.size(); 82 } 83 } 84 | Popular Tags |