1 17 18 package org.apache.lenya.ac.file; 19 20 import java.io.File ; 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 import org.apache.lenya.ac.AccessControlException; 25 import org.apache.lenya.ac.Item; 26 import org.apache.lenya.ac.Role; 27 import org.apache.lenya.ac.RoleManager; 28 29 33 public final class FileRoleManager extends FileItemManager implements RoleManager { 34 protected static final String SUFFIX = ".rml"; 35 private static Map instances = new HashMap (); 36 37 44 protected FileRoleManager(File configurationDirectory) 45 throws AccessControlException { 46 super(configurationDirectory); 47 } 48 49 55 public static FileRoleManager instance(File configurationDirectory) 56 throws AccessControlException { 57 if (!instances.containsKey(configurationDirectory)) { 58 instances.put(configurationDirectory, new FileRoleManager(configurationDirectory)); 59 } 60 61 return (FileRoleManager) instances.get(configurationDirectory); 62 } 63 64 70 public Role getRole(String roleId) { 71 return (Role) getItem(roleId); 72 } 73 74 77 protected String getSuffix() { 78 return SUFFIX; 79 } 80 81 86 public Role[] getRoles() { 87 Item[] items = super.getItems(); 88 Role[] roles = new Role[items.length]; 89 for (int i = 0; i < roles.length; i++) { 90 roles[i] = (Role) items[i]; 91 } 92 return roles; 93 } 94 95 101 public void add(Role role) throws AccessControlException { 102 super.add(role); 103 } 104 105 111 public void remove(Role role) throws AccessControlException { 112 super.remove(role); 113 } 114 } 115 | Popular Tags |