ionflux.org | Impressum

TCPAuthServer.hpp

Go to the documentation of this file.
00001 #ifndef IONFLUX_TOOLS_TCPAUTHSERVER
00002 #define IONFLUX_TOOLS_TCPAUTHSERVER
00003 /* ==========================================================================
00004  * Ionflux Tools
00005  * Copyright (c) 2004 Joern P. Meier
00006  * mail@ionflux.org
00007  * --------------------------------------------------------------------------
00008  * TCPAuthServer.hpp                   Authenticated TCP server.
00009  * ==========================================================================
00010  * 
00011  * This file is part of Ionflux Tools.
00012  * 
00013  * Ionflux Tools is free software; you can redistribute it and/or modify it 
00014  * under the terms of the GNU General Public License as published by the Free
00015  * Software Foundation; either version 2 of the License, or (at  your option)
00016  * any later version.
00017  * 
00018  * Ionflux Tools is distributed in the hope that it will be useful, but 
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00020  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00021  * for more details.
00022  * 
00023  * You should have received a copy of the GNU General Public License
00024  * along with Ionflux Tools; if not, write to the Free Software Foundation, 
00025  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00026  * 
00027  * ========================================================================== */
00028 
00029 #include <string>
00030 #include <iostream>
00031 #include <vector>
00032 #include "ionflux/tools.hpp"
00033 #include "ionflux/TCPMessageServer.hpp"
00034 #include "ionflux/AuthFile.hpp"
00035 
00036 namespace Ionflux
00037 {
00038 
00039 namespace Tools
00040 {
00041 
00057 class TCPAuthServer
00058 : public TCPMessageServer
00059 {
00060     protected:
00062         Auth* auth;
00064         std::string authFileName;
00066         unsigned int currentMsgID;
00068         MTRand *randomizer;
00069         
00078         virtual void onConnect(TCPRemotePeer &client);
00079         
00091         virtual void onAuthMessage(TCPRemotePeer &peer);
00092         
00102         virtual void onAuthOK(TCPRemotePeer &peer);
00103         
00113         virtual void onAuthFailed(TCPRemotePeer &peer);
00114         
00115     public:
00117         static const std::string MAGIC_WORD;
00119         static const unsigned int AUTH_VERSION;
00121         static const unsigned int AUTH_VERSION_UPPER;
00123         static const unsigned int AUTH_VERSION_LOWER;
00125         static const int MSGID_HELLO;
00127         static const int MSGID_WELCOME;
00129         static const int MSGID_AUTH;
00131         static const int MSGID_AUTH_OK;
00133         static const int MSGID_AUTH_FAILED;
00135         static const int PS_WAIT_HELLO;
00137         static const int PS_WAIT_AUTH;
00139         static const int PS_AUTH_OK;
00140         
00145         TCPAuthServer();
00146         
00153         TCPAuthServer(const std::string& initAuthFileName);
00154         
00159         virtual ~TCPAuthServer();
00160         
00171         virtual void onMessage(TCPRemotePeer &peer);
00172         
00181         virtual void onInvalidMessage(TCPRemotePeer &peer);
00182         
00189         virtual void broadcast(const std::string &bytes);
00190         
00197         virtual void setAuth(Auth* newAuth);
00198         
00205         virtual void setAuthFileName(const std::string& newAuthFileName);
00206         
00213         virtual void setCurrentMsgID(unsigned int newCurrentMsgID);
00214         
00219         virtual Auth* getAuth();
00220         
00226         virtual std::string getAuthFileName();
00227         
00232         virtual unsigned int getCurrentMsgID();
00233 };
00234 
00235 }
00236 
00237 }
00238 
00242 #endif

Generated on Tue Mar 14 20:58:30 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6