Planeshift
|
00001 /* 00002 * AuthentClient.h by Keith Fulton <[email protected]> 00003 * 00004 * Copyright (C) 2001 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 * 00019 * This class subscribes to "AUTH" messages and receives either 00020 * a "Character ID" message, telling the client what to request 00021 * to instantiate the player, or a "Not Authorized" message which rejects 00022 * the client. 00023 * 00024 */ 00025 #ifndef __AUTHENTICATIONCLIENT_H__ 00026 #define __AUTHENTICATIONCLIENT_H__ 00027 00028 //============================================================================= 00029 // Crystal Space Includes 00030 //============================================================================= 00031 #include <csutil/ref.h> 00032 #include <csutil/csstring.h> 00033 00034 //============================================================================= 00035 // Project Includes 00036 //============================================================================= 00037 #include "net/cmdbase.h" // Subscriber class 00038 00039 //============================================================================= 00040 // Local Includes 00041 //============================================================================= 00042 00043 00044 //============================================================================= 00045 // FORWARD DECLARATIONS 00046 //============================================================================= 00047 class MsgEntry; 00048 class MsgHandler; 00049 00054 00055 // Possible response types for logging in. 00057 #define NO_RESPONSE 0 00058 #define APPROVED 1 00059 #define REJECTED 2 00060 00061 00080 class psAuthenticationClient : public psClientNetSubscriber 00081 { 00082 public: 00083 00084 psAuthenticationClient(MsgHandler *myMsgQueue); 00085 virtual ~psAuthenticationClient(); 00086 00096 bool Authenticate (const csString & user, const csString & pwd, const csString & pwd256); 00097 00101 virtual void HandleMessage(MsgEntry *mh); 00102 00106 const char* GetRejectMessage(); 00107 00118 int Status(void) 00119 { 00120 return iClientApproved; 00121 }; 00122 00126 void Reset(void) 00127 { 00128 iClientApproved = NO_RESPONSE; 00129 }; 00130 00131 protected: 00132 csRef<MsgHandler> msghandler; 00133 csString rejectmsg; 00134 int iClientApproved; 00135 csString password; 00136 csString password256; 00137 csString username; 00138 00139 00140 private: 00141 void ShowError(); 00142 00144 void HandlePreAuth( MsgEntry* me ); 00145 00147 void HandleAuthApproved( MsgEntry* me ); 00148 00150 void HandleDisconnect( MsgEntry* me ); 00151 }; 00152 00155 #endif 00156