1 19 20 package org.apache.james.imapserver.mock; 21 22 import java.util.Arrays ; 23 import java.util.Iterator ; 24 25 import org.apache.james.imapserver.TestConstants; 26 import org.apache.james.services.User; 27 import org.apache.james.services.UsersRepository; 28 29 public class MockUsersRepository implements UsersRepository, TestConstants 30 { 31 32 public boolean addUser(User user) 33 { 34 throw new RuntimeException ("not implemented"); 35 } 36 37 public void addUser(String name, Object attributes) 38 { 39 throw new RuntimeException ("not implemented"); 40 } 41 42 public boolean addUser(String username, String password) 43 { 44 throw new RuntimeException ("not implemented"); 45 } 46 47 public User getUserByName(String name) 48 { 49 if (USER_NAME.equals(name)) { 50 return new MockUser(); 51 } 52 return null; 53 } 54 55 public User getUserByNameCaseInsensitive(String name) 56 { 57 if (USER_NAME.equalsIgnoreCase(name)) { 58 return new MockUser(); 59 } 60 return null; 61 } 62 63 public String getRealName(String name) 64 { 65 if (USER_NAME.equalsIgnoreCase(name)) { 66 return USER_REALNAME; 67 } else { 68 return null; 69 } 70 } 71 72 public boolean updateUser(User user) 73 { 74 throw new RuntimeException ("not implemented"); 75 76 } 77 78 public void removeUser(String name) 79 { 80 throw new RuntimeException ("not implemented"); 81 82 } 83 84 public boolean contains(String name) 85 { 86 if (USER_NAME.equals(name)) { 87 return true; 88 } else { 89 return false; 90 } 91 } 92 93 public boolean containsCaseInsensitive(String name) 94 { 95 if (USER_NAME.equalsIgnoreCase(name)) { 96 return true; 97 } else { 98 return false; 99 } 100 } 101 102 public boolean test(String name, String password) 103 { 104 User user=getUserByName(name); 105 if (user!=null) { 106 return user.verifyPassword(password); 107 } 108 return false; 109 } 110 111 public int countUsers() 112 { 113 return 1; 114 } 115 116 public Iterator list() 117 { 118 return Arrays.asList(new String [] { USER_NAME }).iterator(); 119 } 120 121 } 122 | Popular Tags |