1 17 package org.alfresco.filesys.server.auth.acl; 18 19 import org.alfresco.config.ConfigElement; 20 21 26 public abstract class AccessControlParser 27 { 28 29 33 public final static String ParameterAccess = "access"; 34 35 37 private final static String [] _accessTypes = { "None", "Read", "Write" }; 38 39 44 public abstract String getType(); 45 46 53 public abstract AccessControl createAccessControl(ConfigElement params) throws ACLParseException; 54 55 62 protected final int parseAccessType(ConfigElement params) throws ACLParseException 63 { 64 65 67 if (params == null) 68 throw new ACLParseException("Empty parameter list"); 69 70 72 String accessType = params.getAttribute(ParameterAccess); 73 74 if (accessType == null || accessType.length() == 0) 75 throw new ACLParseException("Required parameter 'access' missing"); 76 77 79 return parseAccessTypeString(accessType); 80 } 81 82 89 public static final int parseAccessTypeString(String accessType) throws ACLParseException 90 { 91 92 94 if (accessType == null || accessType.length() == 0) 95 throw new ACLParseException("Empty access type string"); 96 97 99 int access = -1; 100 101 for (int i = 0; i < _accessTypes.length; i++) 102 { 103 104 106 if (accessType.equalsIgnoreCase(_accessTypes[i])) 107 access = i; 108 } 109 110 112 if (access == -1) 113 throw new ACLParseException("Invalid access type, " + accessType); 114 115 117 return access; 118 } 119 120 125 public String toString() 126 { 127 StringBuffer str = new StringBuffer (); 128 129 str.append("["); 130 str.append(getType()); 131 str.append("]"); 132 133 return str.toString(); 134 } 135 } 136 | Popular Tags |