added NTLM authentication to SMTPClientSession

This commit is contained in:
Günter Obiltschnig
2019-04-02 16:47:12 +02:00
parent 32ef30384a
commit fa84db6d65
6 changed files with 148 additions and 85 deletions

View File

@@ -101,9 +101,6 @@ private:
HTTPNTLMCredentials& operator = (const HTTPNTLMCredentials&);
std::string createNTLMMessage(const std::string& ntlmChallengeBase64);
static void splitUsername(const std::string& usernameAndDomain, std::string& username, std::string& domain);
static std::string toBase64(const std::vector<unsigned char>& buffer);
static std::vector<unsigned char> fromBase64(const std::string& base64);
std::string _username;
std::string _password;

View File

@@ -160,6 +160,16 @@ public:
static void writeBufferDesc(Poco::BinaryWriter& writer, const BufferDesc& desc);
/// Writes a buffer descriptor.
static void splitUsername(const std::string& usernameAndDomain, std::string& username, std::string& domain);
/// Splits a username containing a domain into plain username and domain.
/// Supported formats are <DOMAIN>\<username> and <username>@<DOMAIN>.
static std::string toBase64(const std::vector<unsigned char>& buffer);
/// Converts the buffer to a base64-encoded string.
static std::vector<unsigned char> fromBase64(const std::string& base64);
/// Decodes the given base64-encoded string.
static const std::string NTLMSSP;
/// Message signature string.
};

View File

@@ -51,7 +51,8 @@ public:
AUTH_CRAM_SHA1,
AUTH_LOGIN,
AUTH_PLAIN,
AUTH_XOAUTH2
AUTH_XOAUTH2,
AUTH_NTLM
};
explicit SMTPClientSession(const StreamSocket& socket);
@@ -68,7 +69,7 @@ public:
void setTimeout(const Poco::Timespan& timeout);
/// Sets the timeout for socket read operations.
Poco::Timespan getTimeout() const;
/// Returns the timeout for socket read operations.
@@ -92,7 +93,7 @@ public:
void login(LoginMethod loginMethod, const std::string& username, const std::string& password);
/// Logs in to the SMTP server using the given authentication method and the given
/// credentials.
void open();
/// Reads the initial response from the SMTP server.
///
@@ -103,7 +104,7 @@ public:
/// Does nothing if called more than once.
void close();
/// Sends a QUIT command and closes the connection to the server.
/// Sends a QUIT command and closes the connection to the server.
///
/// Throws a SMTPException in case of a SMTP-specific error, or a
/// NetException in case of a general network communication failure.
@@ -169,7 +170,7 @@ protected:
};
enum
{
DEFAULT_TIMEOUT = 30000000 // 30 seconds default timeout for socket operations
DEFAULT_TIMEOUT = 30000000 // 30 seconds default timeout for socket operations
};
static bool isPositiveCompletion(int status);
@@ -184,6 +185,7 @@ protected:
void loginUsingLogin(const std::string& username, const std::string& password);
void loginUsingPlain(const std::string& username, const std::string& password);
void loginUsingXOAUTH2(const std::string& username, const std::string& password);
void loginUsingNTLM(const std::string& username, const std::string& password);
DialogSocket& socket();
private: