19 #include <ndb_global.h>
21 #include <SocketClient.hpp>
22 #include <SocketAuthenticator.hpp>
23 #include <InputStream.hpp>
24 #include <OutputStream.hpp>
27 SocketAuthSimple::SocketAuthSimple(
const char *username,
const char *passwd) {
29 m_username= strdup(username);
33 m_passwd= strdup(passwd);
38 SocketAuthSimple::~SocketAuthSimple()
41 free((
void*)m_passwd);
43 free((
void*)m_username);
46 bool SocketAuthSimple::client_authenticate(NDB_SOCKET_TYPE sockfd)
51 s_output.println(
"%s", m_username ? m_username :
"");
52 s_output.println(
"%s", m_passwd ? m_passwd :
"");
55 if (s_input.gets(buf, 16) == 0)
return false;
56 if (strncmp(
"ok", buf, 2) == 0)
62 bool SocketAuthSimple::server_authenticate(NDB_SOCKET_TYPE sockfd)
70 if (s_input.gets(buf, 256) == 0)
return false;
73 free((
void*)m_username);
74 m_username= strdup(buf);
76 if (s_input.gets(buf, 256) == 0)
return false;
79 free((
void*)m_passwd);
80 m_passwd= strdup(buf);
82 s_output.println(
"ok");