Planeshift
authentclient.h
Go to the documentation of this file.
1 /*
2  * AuthentClient.h by Keith Fulton <keith@paqrat.com>
3  *
4  * Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  *
19  * This class subscribes to "AUTH" messages and receives either
20  * a "Character ID" message, telling the client what to request
21  * to instantiate the player, or a "Not Authorized" message which rejects
22  * the client.
23  *
24  */
25 #ifndef __AUTHENTICATIONCLIENT_H__
26 #define __AUTHENTICATIONCLIENT_H__
27 
28 //=============================================================================
29 // Crystal Space Includes
30 //=============================================================================
31 #include <csutil/ref.h>
32 #include <csutil/csstring.h>
33 
34 //=============================================================================
35 // Project Includes
36 //=============================================================================
37 #include "net/cmdbase.h" // Subscriber class
38 
39 //=============================================================================
40 // Local Includes
41 //=============================================================================
42 
43 
44 //=============================================================================
45 // FORWARD DECLARATIONS
46 //=============================================================================
47 class MsgEntry;
48 class MsgHandler;
49 
54 // Possible response types for logging in.
57 #define NO_RESPONSE 0
58 #define APPROVED 1
59 #define REJECTED 2
60 
61 
81 {
82 public:
83 
85  virtual ~psAuthenticationClient();
86 
96  bool Authenticate (const csString & user, const csString & pwd, const csString & pwd256);
97 
101  virtual void HandleMessage(MsgEntry *mh);
102 
106  const char* GetRejectMessage();
107 
118  int Status(void)
119  {
120  return iClientApproved;
121  };
122 
126  void Reset(void)
127  {
129  };
130 
131 protected:
132  csRef<MsgHandler> msghandler;
133  csString rejectmsg;
135  csString password;
136  csString password256;
137  csString username;
138 
139 
140 private:
141  void ShowError();
142 
144  void HandlePreAuth( MsgEntry* me );
145 
147  void HandleAuthApproved( MsgEntry* me );
148 
150  void HandleDisconnect( MsgEntry* me );
151 };
152 
155 #endif
156 
#define NO_RESPONSE
Definition: authentclient.h:57
int Status(void)
Get the current status of authentication.
Handles Authentication details from the client to the server.
Definition: authentclient.h:80
psAuthenticationClient(MsgHandler *myMsgQueue)
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
void Reset(void)
Clear the status of the login attempt.
csRef< MsgHandler > msghandler
bool Authenticate(const csString &user, const csString &pwd, const csString &pwd256)
Send a message to the server to login.
This class is the client&#39;s and server&#39;s main interface for either sending network messages out or get...
Definition: msghandler.h:106
virtual ~psAuthenticationClient()
virtual void HandleMessage(MsgEntry *mh)
Handle incomming messages based on the subscribed types.
const char * GetRejectMessage()
Return the reason ( if any ) for a client to be rejected.