BMAMail  1.0.0
E-Mail System
/home/bradarant/barant/BMAMail/__SMTP_AUTH.h
Go to the documentation of this file.
1 #ifndef ____SMTP_AUTH_h__
2 #define ____SMTP_AUTH_h__
3 
4 #include "SMTPCommand.h"
5 #include "PString.h"
6 #include "Base64.h"
7 
8 namespace mail {
9 
10  class __SMTP_AUTH : public SMTPCommand {
11 
12  int processCommand(coreutils::PString request, SMTPSession &session, SMTPService &service, std::stringstream &data) {
13 
14  switch(session.authState) {
15 
16  case USER_UNKNOWN:
17  if(request[1].str() == "LOGIN") {
18 
19  data << "334 VXNlcm5hbWU6" << CRLF;
20 
21 // setTimer(10.0f);
22  session.authState = USER_QUERY;
23  session.server.commands.grabInput(*this);
24  }
25  else {
26  data << "530 AUTH method not supported." << CRLF;
27  }
28  break;
29 
30  case USER_QUERY:
31 
32  session.userName = request[0].str();
33 
34 // setTimer(0.0f);
35 
36  data << "334 UGFzc3dvcmQ6" << CRLF;
37 
38 // setTimer(10.0f);
39  session.authState = USER_SECRET_QUERY;
40  break;
41 
42  case USER_SECRET_QUERY:
43 
44  session.password = request[0].str();
45 
46 // setTimer(0.0f);
47 
48  coreutils::Base64 base64;
49  coreutils::Log(coreutils::LOG_INFO) << "Logging in with user '" << \
50  base64.decode(session.userName) << \
51  "' using password '" << \
52  base64.decode(session.password) << "'.";
53 
54  if(authLogin(base64.decode(session.userName), base64.decode(session.password))) {
55  data << "235 Authentication successful" << CRLF;
56  session.relay = true;
57  session.authState = USER_KNOWN;
58  session.server.commands.clearGrab();
59  }
60 
61  else {
62  data << "530 Login was unsuccessful." << CRLF;
63  }
64  }
65 
66  return 0;
67  }
68 
69  bool authLogin(std::string userName, std::string password) {
70  return true;
71  }
72 
73  };
74 
75 }
76 
77 #endif
Definition: SMTPSession.h:12
AuthState authState
Definition: SMTPSession.h:26
Definition: __SMTP_AUTH.h:10
bool relay
Definition: SMTPSession.h:28
Definition: __IMAP_APPEND.h:7
std::string password
Definition: SMTPSession.h:23
std::string userName
Definition: SMTPSession.h:22
Definition: SMTPCommand.h:9
#define CRLF
Definition: SMTPSession.h:7
Definition: SMTPSession.h:15
Definition: SMTPService.h:21
Definition: SMTPSession.h:12
Definition: SMTPSession.h:12
Definition: SMTPSession.h:12