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 public void logoutUser(String userid) throws ServiceException { 00067 00068 } 00069 00070 /* (non-Javadoc) 00071 * @see org.openmobileis.common.user.UserManagerFactory#storeUser(org.openmobileis.common.user.User) 00072 */ 00073 public void storeUser(User user) throws ServiceException, UserAlreadyExistException { 00074 // do nothing 00075 00076 } 00077 00078 /* (non-Javadoc) 00079 * @see org.openmobileis.common.user.UserManagerFactory#getUser(java.lang.String) 00080 */ 00081 public User getUser(String userID) throws ServiceException, UserNotFoundException { 00082 if (userID.equals(defaultUser.getId())) { 00083 return defaultUser; 00084 } else { 00085 throw new UserNotFoundException("No user found for Id :"+userID); 00086 } 00087 } 00088 00089 /* (non-Javadoc) 00090 * @see org.openmobileis.common.user.UserManagerFactory#deleteUser(java.lang.String) 00091 */ 00092 public void deleteUser(String userID) throws ServiceException, UserNotFoundException { 00093 // Do nothing 00094 00095 } 00096 00097 }