00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #include <server/ScorchedServerUtil.h> 00022 #include <server/ScorchedServer.h> 00023 #include <server/ServerAuthHandlerForumLogin.h> 00024 #include <server/ServerAuthHandlerPrefered.h> 00025 #include <server/ServerAuthHandlerMinKills.h> 00026 #include <server/ServerAuthHandlerDefault.h> 00027 #include <common/OptionsScorched.h> 00028 #include <common/Logger.h> 00029 00030 ScorchedServerUtil *ScorchedServerUtil::instance_ = 0; 00031 00032 ScorchedServerUtil *ScorchedServerUtil::instance() 00033 { 00034 if (!instance_) instance_ = new ScorchedServerUtil; 00035 return instance_; 00036 } 00037 00038 ScorchedServerUtil::ScorchedServerUtil() : authHandler_(0) 00039 { 00040 } 00041 00042 ScorchedServerUtil::~ScorchedServerUtil() 00043 { 00044 } 00045 00046 ServerAuthHandler *ScorchedServerUtil::getAuthHandler() 00047 { 00048 if (authHandler_) return authHandler_; 00049 00050 const char *handler = ScorchedServer::instance()->getOptionsGame().getAuthHandler(); 00051 if (0 == strcmp("none", handler)) 00052 { 00053 authHandler_ = new ServerAuthHandlerDefault; 00054 } 00055 else if (0 == strcmp("prefered", handler)) 00056 { 00057 authHandler_ = new ServerAuthHandlerPrefered; 00058 } 00059 #ifdef HAVE_MYSQL 00060 else if (0 == strcmp("forumlogin", handler)) 00061 { 00062 authHandler_ = new ServerAuthHandlerForumLogin; 00063 } 00064 #endif 00065 else if (0 == strcmp("minkills", handler)) 00066 { 00067 authHandler_ = new ServerAuthHandlerMinKills; 00068 } 00069 else 00070 { 00071 S3D::dialogExit("ServerAuthHandler", 00072 S3D::formatStringBuffer("Unknown auth handler \"%s\"", handler)); 00073 } 00074 00075 Logger::log(S3D::formatStringBuffer("Using \"%s\" authentication handler.", handler)); 00076 return authHandler_; 00077 }
1.5.3