00001 /* 00002 * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM) 00003 * Copyright (C) 2004-2006 Philippe Delrieu 00004 * All rights reserved. 00005 * Contact: pdelrieu@openmobileis.org 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * 00022 * Author : Philippe Delrieu 00023 * 00024 */ 00025 package org.openmobileis.common.user.impl; 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 00040 public final class MonoUserUserManagerFactory implements UserManagerFactory { 00041 private User defaultUser; 00045 public MonoUserUserManagerFactory() { 00046 super(); 00047 defaultUser = new User(); 00048 defaultUser.setId("1"); 00049 defaultUser.setLogin("test"); 00050 defaultUser.setPassword("test"); 00051 defaultUser.setProfil("default"); 00052 defaultUser.setGroup("default"); 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(defaultUser.getLogin())) && (pass.equals(defaultUser.getPassword()))) { 00060 return defaultUser.getId(); 00061 } else { 00062 throw new UserNotFoundException("Bad authentication for login :"+login); 00063 } 00064 } 00065 00066 /* (non-Javadoc) 00067 * @see org.openmobileis.common.user.UserManagerFactory#storeUser(org.openmobileis.common.user.User) 00068 */ 00069 public void storeUser(User user) throws ServiceException, UserAlreadyExistException { 00070 // do nothing 00071 00072 } 00073 00074 /* (non-Javadoc) 00075 * @see org.openmobileis.common.user.UserManagerFactory#getUser(java.lang.String) 00076 */ 00077 public User getUser(String userID) throws ServiceException, UserNotFoundException { 00078 if (userID.equals(defaultUser.getId())) { 00079 return defaultUser; 00080 } else { 00081 throw new UserNotFoundException("No user found for Id :"+userID); 00082 } 00083 } 00084 00085 /* (non-Javadoc) 00086 * @see org.openmobileis.common.user.UserManagerFactory#deleteUser(java.lang.String) 00087 */ 00088 public void deleteUser(String userID) throws ServiceException, UserNotFoundException { 00089 // Do nothing 00090 00091 } 00092 00093 }