1 17 package org.alfresco.filesys.server.auth.acl; 18 19 import java.util.Vector ; 20 21 26 public class AccessControlList 27 { 28 29 31 private Vector <AccessControl> m_list; 32 33 35 private int m_defaultAccess = AccessControl.ReadWrite; 36 37 40 public AccessControlList() 41 { 42 m_list = new Vector <AccessControl>(); 43 } 44 45 50 public final int getDefaultAccessLevel() 51 { 52 return m_defaultAccess; 53 } 54 55 61 public final void setDefaultAccessLevel(int level) throws InvalidACLTypeException 62 { 63 64 66 if (level < AccessControl.NoAccess || level > AccessControl.MaxLevel) 67 throw new InvalidACLTypeException(); 68 69 71 m_defaultAccess = level; 72 } 73 74 79 public final void addControl(AccessControl accCtrl) 80 { 81 82 84 m_list.add(accCtrl); 85 } 86 87 93 public final AccessControl getControlAt(int idx) 94 { 95 if (idx < 0 || idx >= m_list.size()) 96 return null; 97 return m_list.get(idx); 98 } 99 100 105 public final int numberOfControls() 106 { 107 return m_list.size(); 108 } 109 110 113 public final void removeAllControls() 114 { 115 m_list.removeAllElements(); 116 } 117 118 124 public final AccessControl removeControl(int idx) 125 { 126 if (idx < 0 || idx >= m_list.size()) 127 return null; 128 return m_list.remove(idx); 129 } 130 131 136 public String toString() 137 { 138 StringBuffer str = new StringBuffer (); 139 140 str.append("["); 141 str.append(m_list.size()); 142 str.append(":"); 143 144 str.append(":"); 145 str.append(AccessControl.asAccessString(getDefaultAccessLevel())); 146 str.append(":"); 147 148 for (int i = 0; i < m_list.size(); i++) 149 { 150 AccessControl ctrl = m_list.get(i); 151 str.append(ctrl.toString()); 152 str.append(","); 153 } 154 str.append("]"); 155 156 return str.toString(); 157 } 158 } 159 | Popular Tags |