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;
19 import java.util.TreeSet;
24 * @author Erik Brakkee
26 public class InMemoryUserSet extends AbstractUserSet {
28 * Users. All users in this set have their password validator and encoder
31 private Set<User> users;
34 * Constructs an empty user set.
36 public InMemoryUserSet(NameValidator aPasswordValidator,
37 MessageDigester aPasswordEncoder) {
38 super(aPasswordValidator, aPasswordEncoder);
39 users = new TreeSet<User>();
43 public void userModified(User aUser) {
45 setPasswordInfo(aUser);
50 public User find(String aName) {
51 for (User user : users) {
52 if (user.getName().equals(aName)) {
61 public boolean add(User aUser) {
62 setPasswordInfo(aUser);
64 return users.add(aUser);
68 public boolean contains(User aUser) {
69 return users.contains(aUser);
73 public boolean remove(User aUser) {
74 return users.remove(aUser);
78 public Set<User> list() {
79 Set<User> list = new TreeSet<User>();
85 public Set<User> list(Group aGroup) {
86 Set<User> result = new TreeSet<User>();
88 for (User user : users) {
89 if (user.getGroups().contains(aGroup)) {
103 public void clearCache() {