40 using std::ostringstream ;
53 #if defined HAVE_OPENSSL && defined NOTTHERE
54 #include "SSLServer.h"
57 #define PPT_SERVER_DEFAULT_TIMEOUT 1
64 _listener( listener ),
69 string err(
"Null handler passed to PPTServer" ) ;
74 string err(
"Null listener passed to PPTServer" ) ;
77 #if !defined HAVE_OPENSSL && defined NOTTHERE
80 string err(
"Server requested to be secure but OpenSSL is not built in");
97 PPTServer::get_secure_files()
101 if( !found || _cfile.empty() )
103 string err =
"Unable to determine server certificate file." ;
109 if( !found || _cafile.empty() )
111 string err =
"Unable to determine server certificate authority file." ;
117 if( !found || _kfile.empty() )
119 string err =
"Unable to determine server key file." ;
126 if( !found || portstr.empty() )
128 string err =
"Unable to determine secure connection port." ;
131 _securePort = atoi( portstr.c_str() ) ;
134 string err = (string)
"Unable to determine secure connection port "
135 +
"from string " + portstr ;
155 if (welcomeClient() != -1) {
181 int PPTServer::welcomeClient()
189 unsigned int ppt_buffer_size = 64;
190 char *inBuff =
new char[ppt_buffer_size + 1];
201 string status(inBuff, bytesRead);
210 string err(
"PPT cannot negotiate, ");
211 err +=
" client started the connection with " + status;
225 authenticateClient();
232 PPTServer::authenticateClient()
234 #if defined HAVE_OPENSSL && defined NOTTHERE
235 BESDEBUG(
"ppt",
"requiring secure connection: port = "
236 << _securePort << endl ) ;
243 unsigned int ppt_buffer_size = 64 ;
244 char *inBuff =
new char[ppt_buffer_size] ;
246 string portRequest( inBuff, bytesRead ) ;
250 string err(
"Secure connection ... expecting request for port" ) ;
251 err +=
" client requested " + portRequest ;
256 ostringstream portResponse ;
258 send( portResponse.str() ) ;
261 SSLServer server( _securePort, _cfile, _cafile, _kfile ) ;
262 server.initConnection() ;
263 server.closeConnection() ;
268 string err = (string)
"Authentication requested for this server "
269 +
"but OpenSSL is not built into the server" ;
284 << (
void *)
this <<
")" << endl ;
290 _handler->
dump( strm ) ;
301 _listener->
dump( strm ) ;
static string PPTCLIENT_REQUEST_AUTHPORT
exception thrown if inernal error encountered
static string PPT_COMPLETE_DATA_TRANSMITION
static string PPTCLIENT_TESTING_CONNECTION
virtual bool allowConnection()=0
#define PPT_SERVER_DEFAULT_TIMEOUT
error thrown if there is a user syntax error in the request or any other user error ...
static string PPTSERVER_AUTHENTICATE
virtual void initConnection()
Using the info passed into the SocketLister, wait for an inbound request (see SocketListener::accept(...
PPTServer(ServerHandler *handler, SocketListener *listener, bool isSecure)
virtual void closeConnection()
virtual void handle(Connection *c)=0
virtual Socket * accept()
Use the select() system call to wait for an incoming connection.
static ostream & LMarg(ostream &strm)
virtual int readBufferNonBlocking(char *inBuff, const int buff_size)
read a buffer of data from the socket without blocking
virtual int receive(char *inBuff, const int inSize)
virtual void dump(ostream &strm) const
dumps information about this object
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
virtual void dump(ostream &strm) const =0
dump the contents of this object to the specified ostream
virtual void dump(ostream &strm) const
dumps information about this object
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
static BESKeys * TheKeys()
virtual void send(const string &buffer)
sends the buffer to the socket
static string PPTSERVER_CONNECTION_OK
virtual void dump(ostream &strm) const
dumps information about this object