/home/bradarant/barant/BMAMail/__SMTP_AUTH.h
Go to the documentation of this file.
#ifndef ____SMTP_AUTH_h__
#define ____SMTP_AUTH_h__
#include "SMTPCommand.h"
#include "PString.h"
#include "Base64.h"
namespace mail {
class __SMTP_AUTH : public SMTPCommand {
int processCommand(coreutils::PString request, SMTPSession &session, SMTPService &service, std::stringstream &data) {
switch(session.authState) {
case USER_UNKNOWN:
if(request[1].str() == "LOGIN") {
data << "334 VXNlcm5hbWU6" << CRLF;
// setTimer(10.0f);
session.authState = USER_QUERY;
session.server.commands.grabInput(*this);
}
else {
data << "530 AUTH method not supported." << CRLF;
}
break;
case USER_QUERY:
session.userName = request[0].str();
// setTimer(0.0f);
data << "334 UGFzc3dvcmQ6" << CRLF;
// setTimer(10.0f);
session.authState = USER_SECRET_QUERY;
break;
case USER_SECRET_QUERY:
session.password = request[0].str();
// setTimer(0.0f);
coreutils::Base64 base64;
coreutils::Log(coreutils::LOG_INFO) << "Logging in with user '" << \
base64.decode(session.userName) << \
"' using password '" << \
base64.decode(session.password) << "'.";
if(authLogin(base64.decode(session.userName), base64.decode(session.password))) {
data << "235 Authentication successful" << CRLF;
session.relay = true;
session.authState = USER_KNOWN;
session.server.commands.clearGrab();
}
else {
data << "530 Login was unsuccessful." << CRLF;
}
}
return 0;
}
bool authLogin(std::string userName, std::string password) {
return true;
}
};
}
#endif
mail::USER_UNKNOWN
Definition: SMTPSession.h:12
mail::SMTPSession::authState
AuthState authState
Definition: SMTPSession.h:26
mail::__SMTP_AUTH
Definition: __SMTP_AUTH.h:10
mail::SMTPSession::relay
bool relay
Definition: SMTPSession.h:28
mail
Definition: __IMAP_APPEND.h:7
mail::SMTPSession::password
std::string password
Definition: SMTPSession.h:23
mail::SMTPSession::userName
std::string userName
Definition: SMTPSession.h:22
SMTPCommand.h
mail::SMTPCommand
Definition: SMTPCommand.h:9
CRLF
#define CRLF
Definition: SMTPSession.h:7
mail::SMTPSession
Definition: SMTPSession.h:15
mail::SMTPService
Definition: SMTPService.h:21
mail::USER_QUERY
Definition: SMTPSession.h:12
mail::USER_KNOWN
Definition: SMTPSession.h:12
mail::USER_SECRET_QUERY
Definition: SMTPSession.h:12