121 * @param permission The permission that has to be part of
122 * the permission set in the entry.
123 * @return true if the permission passed is part of the
124 * permission set in the entry, false otherwise.
125 */
126 public boolean checkPermission(Permission permission) {
127 return permissionSet.contains(permission);
128 }
129
130 /**
131 * return an enumeration of the permissions in this ACL entry.
132 */
133 public Enumeration<Permission> permissions() {
134 return permissionSet.elements();
135 }
136
137 /**
138 * Return a string representation of the contents of the ACL entry.
139 */
140 public String toString() {
141 StringBuffer s = new StringBuffer();
142 if (negative)
143 s.append("-");
144 else
145 s.append("+");
146 if (user instanceof Group)
147 s.append("Group.");
148 else
149 s.append("User.");
150 s.append(user + "=");
151 Enumeration<Permission> e = permissions();
152 while(e.hasMoreElements()) {
153 Permission p = e.nextElement();
154 s.append(p);
155 if (e.hasMoreElements())
156 s.append(",");
157 }
158 return new String(s);
159 }
160
161 /**
162 * Clones an AclEntry.
163 */
164 @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
165 public synchronized Object clone() {
166 AclEntryImpl cloned;
167 cloned = new AclEntryImpl(user);
168 cloned.permissionSet = (Vector<Permission>) permissionSet.clone();
169 cloned.negative = negative;
170 return cloned;
171 }
172
173 /**
174 * Return the Principal associated in this ACL entry.
175 * The method returns null if the entry uses a group
176 * instead of a principal.
177 */
178 public Principal getPrincipal() {
|
121 * @param permission The permission that has to be part of
122 * the permission set in the entry.
123 * @return true if the permission passed is part of the
124 * permission set in the entry, false otherwise.
125 */
126 public boolean checkPermission(Permission permission) {
127 return permissionSet.contains(permission);
128 }
129
130 /**
131 * return an enumeration of the permissions in this ACL entry.
132 */
133 public Enumeration<Permission> permissions() {
134 return permissionSet.elements();
135 }
136
137 /**
138 * Return a string representation of the contents of the ACL entry.
139 */
140 public String toString() {
141 StringBuffer sb = new StringBuffer();
142 if (negative) {
143 sb.append('-');
144 } else {
145 sb.append('+');
146 }
147 if (user instanceof Group) {
148 sb.append("Group.");
149 } else {
150 sb.append("User.");
151 }
152 sb.append(user).append('=');
153
154 Enumeration<Permission> e = permissions();
155 while (e.hasMoreElements()) {
156 Permission p = e.nextElement();
157 sb.append(p);
158 if (e.hasMoreElements()) {
159 sb.append(',');
160 }
161 }
162 return sb.toString();
163 }
164
165 /**
166 * Clones an AclEntry.
167 */
168 @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
169 public synchronized Object clone() {
170 AclEntryImpl cloned;
171 cloned = new AclEntryImpl(user);
172 cloned.permissionSet = (Vector<Permission>) permissionSet.clone();
173 cloned.negative = negative;
174 return cloned;
175 }
176
177 /**
178 * Return the Principal associated in this ACL entry.
179 * The method returns null if the entry uses a group
180 * instead of a principal.
181 */
182 public Principal getPrincipal() {
|