MockUserManagerFactory.java

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  * Title:        OpenMobileIS project source <BR>
00036  * Description:
00037  * @author      Philippe Delrieu
00038  * @since       JDK 1.1
00039  * @version 1.0.
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   /* (non-Javadoc)
00056    * @see org.openmobileis.common.user.UserManagerFactory#authenticateUser(java.lang.String, java.lang.String)
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   /* (non-Javadoc)
00066    * @see org.openmobileis.common.user.UserManagerFactory#deleteUser(java.lang.String)
00067    */
00068   public void deleteUser(String userID) throws ServiceException, UserNotFoundException {
00069   }
00070 
00071   /* (non-Javadoc)
00072    * @see org.openmobileis.common.user.UserManagerFactory#getUser(java.lang.String)
00073    */
00074   public User getUser(String userID) throws ServiceException, UserNotFoundException {
00075     User user = new User("1", cred.getPrincipal(), cred.getPassword());
00076     user.setGroup(this.group);
00077     user.setProfil(this.profilid);
00078     return user;
00079   }
00080 
00081   /* (non-Javadoc)
00082    * @see org.openmobileis.common.user.UserManagerFactory#storeUser(org.openmobileis.common.user.User)
00083    */
00084   public void storeUser(User user) throws ServiceException, UserAlreadyExistException {
00085   }
00086 
00087 }

Generated on Mon Dec 4 11:03:28 2006 for OpenMobileIS by  doxygen 1.5.1-p1