99 lines
2.4 KiB
C++
99 lines
2.4 KiB
C++
#ifndef ____SMTP_AUTH_h__
|
|
#define ____SMTP_AUTH_h__
|
|
|
|
#include "Command.h"
|
|
|
|
namespace mail {
|
|
|
|
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
|