based on reworked servercore.

This commit is contained in:
barant committed 2020-02-29 19:25:13 -08:00
1 parent 50eb707f10
commit db3e82a18e
1698 files changed
+41157 -797

No files matched your search

+11 -87
View File
@@ -1,98 +1,22 @@
#ifndef ____SMTP_AUTH_h__
#define ____SMTP_AUTH_h__
# define ____SMTP_AUTH_h__
#include "Command.h"
# include "SMTPCommand.h"
# include "SMTPSession.h"
namespace mail {
class __SMTP_AUTH : public core::Command {
class SMTPServer;
class __SMTP_AUTH : public SMTPCommand {
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 {
}
}
public:
int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data);
bool authLogin(std::string userName, std::string password, SMTPServer &server);
httpRequest.response.addHeader("Content-Type", "script/javascript");
return 0;
}
};
}
#endif