00001
00025 package org.openmobileis.test.mock.common;
00026
00027 import org.openmobileis.common.user.User;
00028 import org.openmobileis.common.user.UserAlreadyExistException;
00029 import org.openmobileis.common.user.UserManagerFactory;
00030 import org.openmobileis.common.user.UserNotFoundException;
00031 import org.openmobileis.common.util.exception.ServiceException;
00032 import org.openmobileis.synchro.security.auth.Credential;
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 public final class MockUserManagerFactory implements UserManagerFactory {
00043 private Credential cred;
00044 private String group;
00045 private String profilid;
00049 public MockUserManagerFactory(String group, String profilid, Credential cred) {
00050 this.cred = cred;
00051 this.group = group;
00052 this.profilid = profilid;
00053 }
00054
00055
00056
00057
00058 public String authenticateUser(String login, String pass) throws ServiceException, UserNotFoundException {
00059 if (login.equals(cred.getPrincipal()) && pass.equals(cred.getPassword())) {
00060 return "1";
00061 }
00062 throw new UserNotFoundException();
00063 }
00064
00065 public void logoutUser(String userid) throws ServiceException {
00066
00067 }
00068
00069
00070
00071
00072 public void deleteUser(String userID) throws ServiceException, UserNotFoundException {
00073 }
00074
00075
00076
00077
00078 public User getUser(String userID) throws ServiceException, UserNotFoundException {
00079 User user = new User("1", cred.getPrincipal(), cred.getPassword());
00080 user.setGroup(this.group);
00081 user.setProfil(this.profilid);
00082 return user;
00083 }
00084
00085
00086
00087
00088 public void storeUser(User user) throws ServiceException, UserAlreadyExistException {
00089 }
00090
00091 }