40 using std::ostringstream ;
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" ) ;
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 ;
156 if( welcomeClient( ) != -1 )
159 _handler->
handle(
this ) ;
177 PPTServer::welcomeClient()
185 unsigned int ppt_buffer_size = 64 ;
186 char *inBuff =
new char[ppt_buffer_size+1] ;
190 if( bytesRead == -1 )
197 string status( inBuff, bytesRead ) ;
206 string err(
"PPT cannot negotiate, " ) ;
207 err +=
" client started the connection with " + status ;
221 authenticateClient() ;
228 PPTServer::authenticateClient()
231 BESDEBUG(
"ppt",
"requiring secure connection: port = " 232 << _securePort << endl ) ;
239 unsigned int ppt_buffer_size = 64 ;
240 char *inBuff =
new char[ppt_buffer_size] ;
242 string portRequest( inBuff, bytesRead ) ;
246 string err(
"Secure connection ... expecting request for port" ) ;
247 err +=
" client requested " + portRequest ;
252 ostringstream portResponse ;
254 send( portResponse.str() ) ;
257 SSLServer server( _securePort, _cfile, _cafile, _kfile ) ;
258 server.initConnection() ;
259 server.closeConnection() ;
264 string err = (string)
"Authentication requested for this server " 265 +
"but OpenSSL is not built into the server" ;
280 << (
void *)
this <<
")" << endl ;
286 _handler->
dump( strm ) ;
297 _listener->
dump( strm ) ;
virtual int readBufferNonBlocking(char *inBuff, const unsigned int buff_size)
read a buffer of data from the socket without blocking
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 ...
virtual void dump(ostream &strm) const
dumps information about this object
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 void dump(ostream &strm) const
dumps information about this object
virtual int receive(char *inBuff, const int inSize)
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
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
virtual void dump(ostream &strm) const
dumps information about this object
static BESKeys * TheKeys()
virtual void send(const string &buffer)
sends the buffer to the socket
static string PPTSERVER_CONNECTION_OK