summaryrefslogtreecommitdiff
path: root/src/operator-authenticate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/operator-authenticate.cc')
-rw-r--r--src/operator-authenticate.cc24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/operator-authenticate.cc b/src/operator-authenticate.cc
index 7802c47..2cb9ced 100644
--- a/src/operator-authenticate.cc
+++ b/src/operator-authenticate.cc
@@ -1,9 +1,10 @@
-/** --------------------------------------------------------------------
+/**
* @file operator-authenticate.cc
* @brief Implementation of the AUTHENTICATE command, incl. CRAM-MD5.
* @author Andreas Aardal Hanssen, Erwin Hoffmann
* @date 2002-2005, 2023
- * ----------------------------------------------------------------- **/
+ */
+
#include "authenticate.h"
#include "base64.h"
#include "convert.h"
@@ -18,28 +19,24 @@
#include <cstring>
#include <string>
-using namespace ::std;
using namespace Binc;
+using std::endl;
+using std::string;
-//----------------------------------------------------------------------
AuthenticateOperator::AuthenticateOperator(void) {}
-//----------------------------------------------------------------------
AuthenticateOperator::~AuthenticateOperator(void) {}
-//----------------------------------------------------------------------
const string AuthenticateOperator::getName(void) const
{
return "AUTHENTICATE";
}
-//----------------------------------------------------------------------
int AuthenticateOperator::getState(void) const
{
return Session::NONAUTHENTICATED;
}
-//------------------------------------------------------------------------
Operator::ProcessResult AuthenticateOperator::Login(string &username, string &password)
{
Session &session = Session::getInstance();
@@ -90,7 +87,6 @@ Operator::ProcessResult AuthenticateOperator::Login(string &username, string &pa
return OK;
}
-//------------------------------------------------------------------------
Operator::ProcessResult AuthenticateOperator::Plain(string &username, string &password)
{
Session &session = Session::getInstance();
@@ -139,14 +135,13 @@ Operator::ProcessResult AuthenticateOperator::Plain(string &username, string &pa
return OK;
}
-//------------------------------------------------------------------------
Operator::ProcessResult AuthenticateOperator::Cram(string &username, string &password, string &challenge)
{
Session &session = Session::getInstance();
// generate challenge first: <pid.time@fqdn> and deploy it to authenticator
time_t timer;
- struct tm y2k = {0};
+ struct tm y2k = {};
int timestamp;
y2k.tm_hour = 0;
y2k.tm_min = 0;
@@ -159,9 +154,9 @@ Operator::ProcessResult AuthenticateOperator::Cram(string &username, string &pas
timestamp = difftime(timer, mktime(&y2k));
challenge += "<";
- challenge += to_string(session.getPid());
+ challenge += std::to_string(session.getPid());
challenge += ".";
- challenge += to_string(timestamp);
+ challenge += std::to_string(timestamp);
challenge += "@";
challenge += session.getEnv("TCPLOCALHOST");
challenge += ">";
@@ -195,7 +190,6 @@ Operator::ProcessResult AuthenticateOperator::Cram(string &username, string &pas
return OK;
}
-//------------------------------------------------------------------------
Operator::ProcessResult AuthenticateOperator::process(Depot &depot, Request &command)
{
Session &session = Session::getInstance();
@@ -231,7 +225,6 @@ Operator::ProcessResult AuthenticateOperator::process(Depot &depot, Request &com
// this type can be used even over unencrypted connections
if ((r = Cram(username, password, challenge)) != OK) return r;
-
} else { // Any other disallowed
session.setLastError("The authentication method " + toImapString(authtype)
+ " is not supported. "
@@ -281,7 +274,6 @@ Operator::ProcessResult AuthenticateOperator::process(Depot &depot, Request &com
return NOTHING;
}
-//----------------------------------------------------------------------
Operator::ParseResult AuthenticateOperator::parse(Request &c_in) const
{
Session &session = Session::getInstance();