2 * Copyright 2005-2010 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.security.authentication;
20 import java.util.TreeSet;
25 * @author Erik Brakkee
27 public class InMemoryUserSet extends AbstractUserSet {
29 * Users. All users in this set have their password validator and encoder
32 private Set<User> users;
35 * Constructs an empty user set.
37 public InMemoryUserSet(NameValidator aPasswordValidator,
38 MessageDigester aPasswordEncoder) {
39 super(aPasswordValidator, aPasswordEncoder);
40 users = new TreeSet<User>();
44 public void userModified(User aUser) {
46 setPasswordInfo(aUser);
51 public User find(String aName) {
52 for (User user : users) {
53 if (user.getName().equals(aName)) {
62 public boolean add(User aUser) {
63 setPasswordInfo(aUser);
65 return users.add(aUser);
69 public boolean contains(User aUser) {
70 return users.contains(aUser);
74 public boolean remove(User aUser) {
75 return users.remove(aUser);
79 public Set<User> list() {
80 Set<User> list = new TreeSet<User>();
86 public Set<User> list(Group aGroup) {
87 Set<User> result = new TreeSet<User>();
89 for (User user : users) {
90 if (user.getGroups().contains(aGroup)) {
104 public void clearCache() {