KjSslConnection.h

Go to the documentation of this file.
00001 
00013 /***************************************************************************
00014  *   Copyright (C) 2007 by Jan Koci   *
00015  *   honza.koci@email.cz   *
00016  *   http://kengine.sourceforge.net/tutorial/
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   (at your option) any later version.                                   *
00022  *                                                                         *
00023  *   This program is distributed in the hope that it will be useful,       *
00024  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00025  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00026  *   GNU General Public License for more details.                          *
00027  *                                                                         *
00028  *   You should have received a copy of the GNU General Public License     *
00029  *   along with this program; if not, write to the                         *
00030  *   Free Software Foundation, Inc.,                                       *
00031  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00032  ***************************************************************************/
00033 
00034 #pragma once
00035 
00036 #include "KjSslObject.h"
00037 #include "KjDefines.h"
00038 
00039 #include <sstream>
00040 using namespace std;
00041 
00042 #define KJ_SSL_READ_CHUNK_SIZE 55
00043 
00044 class KjSslServer;
00045 
00050 class KjSslConnection: public virtual KjSslObject
00051 {       
00052 public:
00053         enum EKjSslConType 
00054         {
00055                 KJ_SSL_SERVER,
00056                 KJ_SSL_CLIENT
00057         };
00058 
00059 private:
00060         SSL* m_pSsl;                    
00061         X509* m_pCert;                  
00062         EKjSslConType m_eType;  
00063         BIO* m_pBio;                    
00064         bool m_bIsValid;                
00065         int m_iId;                              
00066         
00067         bool ServerConnect(char* _strConn);
00068         bool ClientConnect(char* _strConn);
00069         bool Init(const string& _strCertFile,  const string& _strKeyFile);
00070         bool CheckSslState();
00071 
00072 public:
00073         KjSslConnection(KjSslConnection::EKjSslConType _eType, char* _strConn,const string &_strCertFile="", const string &_strKeyFile="");
00074         KjSslConnection(BIO* _pBio,const string &_strCertFile="", const string &_strKeyFile="");
00075         ~KjSslConnection();
00076 
00077         int Write(const string& _str);
00078     int Read(string& _str);
00079 
00080         bool GetIsValid()
00081         {
00082                 return m_bIsValid;
00083         }
00084 
00085         int &GetId()
00086         {
00087                 return m_iId;
00088         }
00089 
00090         BIO* GetBio()
00091         {
00092                 return m_pBio;
00093         }
00094 };

Generated on Tue Jul 24 10:03:19 2007 for KjSslSocket by  doxygen 1.4.6