41 using std::ostringstream ;
52 #if defined HAVE_OPENSSL && defined NOTTHERE
53 #include "SSLClient.h"
79 PPTClient::get_secure_files()
83 if( !found || _cfile.empty() )
85 string err =
"Unable to determine client certificate file." ;
91 if( !found || _cafile.empty() )
93 string err =
"Unable to determine client certificate authority file." ;
99 if( !found || _kfile.empty() )
101 string err =
"Unable to determine client key file." ;
128 string msg =
"Failed to initialize connection to server\n" ;
135 const int ppt_buffer_size = 64 ;
136 char *inBuff =
new char[ppt_buffer_size+1] ;
141 string err =
"Could not connect to server, server may be down or busy" ;
145 if( bytesRead > ppt_buffer_size )
146 bytesRead = ppt_buffer_size ;
147 inBuff[bytesRead] =
'\0' ;
148 string status( inBuff, 0, bytesRead ) ;
153 string err =
"Could not connect to server, server may be down or busy" ;
159 authenticateWithServer() ;
163 string err =
"Server reported an invalid connection, \""
170 PPTClient::authenticateWithServer()
172 #if defined HAVE_OPENSSL && defined NOTTHERE
182 const int ppt_buffer_size = 64 ;
183 char *inBuff =
new char[ppt_buffer_size+1] ;
188 string err =
"Expecting secure port number response" ;
192 if( bytesRead > ppt_buffer_size )
194 bytesRead = ppt_buffer_size ;
196 inBuff[bytesRead] =
'\0' ;
197 ostringstream portResponse( inBuff ) ;
200 int portVal = atoi( portResponse.str().c_str() ) ;
203 string err =
"Expecting valid secure port number response" ;
208 SSLClient client( _host, portVal, _cfile, _cafile, _kfile ) ;
209 client.initConnection() ;
210 client.closeConnection() ;
215 throw BESInternalError(
"Server has requested authentication, but OpenSSL is not built into this client", __FILE__, __LINE__ ) ;
232 cerr <<
"Failed to inform server that the client is exiting, "
233 <<
"continuing" << endl ;
255 << (
void *)
this <<
")" << endl ;
static string PPTCLIENT_REQUEST_AUTHPORT
exception thrown if inernal error encountered
virtual bool isConnected()
static string PPT_PROTOCOL_UNDEFINED
static string PPTCLIENT_TESTING_CONNECTION
virtual void closeConnection()
error thrown if there is a user syntax error in the request or any other user error ...
virtual string get_message()
get the error message for this exception
PPTClient(const string &hostStr, int portVal, int timeout)
static string PPTSERVER_AUTHENTICATE
virtual void initConnection()
virtual void sendExit()
Send the exit token as an extension.
static ostream & LMarg(ostream &strm)
virtual int readBufferNonBlocking(char *inBuff, const int buff_size)
read a buffer of data from the socket without blocking
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
dumps information about this object
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