Created initial SMTP handlers.
This commit is contained in:
1 parent
1751d431c9
commit
caa8dd7d90
11 files changed
+608
-12
No files matched your search
@@ -0,0 +1,98 @@
|
||||
#ifndef ____SMTP_AUTH_h__
|
||||
#define ____SMTP_AUTH_h__
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __SMTP_AUTH : public core::Command {
|
||||
|
||||
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||
|
||||
data << "" << std::endl;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// AUTH command request handling.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
else if(command(input) == "AUTH") {
|
||||
|
||||
if(input.length() > 5) {
|
||||
string method = input.substr(5);
|
||||
|
||||
string userName;
|
||||
string password;
|
||||
|
||||
//--------------------------------
|
||||
// Check for AUTH LOGIN method.
|
||||
//--------------------------------
|
||||
|
||||
if(method == "LOGIN") {
|
||||
|
||||
cout << "334 VXNlcm5hbWU6" << CRLF;
|
||||
|
||||
alarm(10);
|
||||
|
||||
if(!getline(cin, userName)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
alarm(0);
|
||||
|
||||
if(userName[userName.length() - 1] == '\r')
|
||||
userName.erase(userName.length() - 1);
|
||||
|
||||
cout << "334 UGFzc3dvcmQ6" << CRLF;
|
||||
|
||||
alarm(10);
|
||||
|
||||
if(!getline(cin, password)) {
|
||||
return -1;
|
||||
}
|
||||
alarm(0);
|
||||
|
||||
if(password[password.length() - 1] == '\r')
|
||||
password.erase(password.length() - 1);
|
||||
|
||||
BASE64 base64;
|
||||
|
||||
log.message("Logging in with user '" + base64.decode(userName) + "' using password '" + base64.decode(password) + "'.");
|
||||
|
||||
if(authLogin(base64.decode(userName), base64.decode(password))) {
|
||||
cout << "235 Authentication successful" << CRLF;
|
||||
log.message("Response: 235 Authentication successful.");
|
||||
relay = true;
|
||||
}
|
||||
|
||||
else {
|
||||
cout << "530 Login was unsuccessful." << CRLF;
|
||||
log.message("Response: 530 Login was unsuccessful.");
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
cout << "530 AUTH method not supported." << CRLF;
|
||||
log.message("Response: 530 AUTH method not supported.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
httpRequest.response.addHeader("Content-Type", "script/javascript");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user