Conversion of MailFileSystem object to MString.
This commit is contained in:
parent
8e7834a320
commit
09c6163a74
@ -4,39 +4,37 @@
|
||||
|
||||
namespace mail {
|
||||
|
||||
MailFileSystem::MailFileSystem(std::string mailPath) : mailPath(mailPath) {}
|
||||
MailFileSystem::MailFileSystem(coreutils::ZString &mailPath) : mailPath(mailPath) {}
|
||||
|
||||
bool MailFileSystem::ifMailBoxExists(std::string mailbox) {
|
||||
bool MailFileSystem::ifMailBoxExists(coreutils::ZString &mailbox) {
|
||||
std::cout << "{" << mailbox << "}" << std::endl;
|
||||
|
||||
if(stat(getMailBoxPath(mailbox).c_str(), &statbuf) != -1)
|
||||
if(S_ISDIR(statbuf.st_mode))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MailFileSystem::ifAliasExists(std::string alias) {
|
||||
bool MailFileSystem::ifAliasExists(coreutils::ZString &alias) {
|
||||
if(stat(getMailBoxPath(alias).c_str(), &statbuf) != -1)
|
||||
if(S_ISREG(statbuf.st_mode))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string MailFileSystem::getMailBoxPath(std::string mailbox) {
|
||||
coreutils::ZString email(mailbox);
|
||||
email.split("@", 1);
|
||||
std::cout << email[0] << "-" << email[1] << std::endl;
|
||||
std::string path = mailPath + "/" + email[1].str() + "/" + email[0].str();
|
||||
coreutils::MString MailFileSystem::getMailBoxPath(coreutils::ZString &mailbox) {
|
||||
mailbox.split("@", 1);
|
||||
std::cout << mailbox[0] << "-" << mailbox[1] << std::endl;
|
||||
coreutils::MString path(mailPath + "/" + mailbox[1] + "/" + mailbox[0]);
|
||||
std::cout << "{" << path << "}" << std::endl;
|
||||
return path;
|
||||
}
|
||||
|
||||
std::vector<std::string> MailFileSystem::getAliasMailboxes(std::string alias) {
|
||||
std::vector<std::string> returnValue;
|
||||
std::vector<coreutils::MString> MailFileSystem::getAliasMailboxes(coreutils::ZString &alias) {
|
||||
std::vector<coreutils::MString> returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
std::string MailFileSystem::getMailPath() {
|
||||
coreutils::ZString& MailFileSystem::getMailPath() {
|
||||
return mailPath;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __MailFileSystem_h__
|
||||
# define __MailFileSystem_h__
|
||||
|
||||
# include "ZString.h"
|
||||
# include "MString.h"
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <unistd.h>
|
||||
@ -11,15 +11,15 @@ namespace mail {
|
||||
class MailFileSystem {
|
||||
|
||||
public:
|
||||
MailFileSystem(std::string mailPath);
|
||||
bool ifMailBoxExists(std::string mailbox);
|
||||
bool ifAliasExists(std::string alias);
|
||||
std::string getMailBoxPath(std::string mailbox);
|
||||
std::vector<std::string> getAliasMailboxes(std::string alias);
|
||||
std::string getMailPath();
|
||||
MailFileSystem(coreutils::ZString &mailPath);
|
||||
bool ifMailBoxExists(coreutils::ZString &mailbox);
|
||||
bool ifAliasExists(coreutils::ZString &alias);
|
||||
coreutils::MString getMailBoxPath(coreutils::ZString &mailbox);
|
||||
std::vector<coreutils::MString> getAliasMailboxes(coreutils::ZString &alias);
|
||||
coreutils::ZString& getMailPath();
|
||||
|
||||
private:
|
||||
std::string mailPath;
|
||||
coreutils::ZString &mailPath;
|
||||
struct stat statbuf;
|
||||
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "__SMTP_AUTH.h"
|
||||
#include "Base64.h"
|
||||
#include "SMTPServer.h"
|
||||
|
||||
namespace mail {
|
||||
|
||||
@ -20,7 +21,7 @@ namespace mail {
|
||||
return 1;
|
||||
|
||||
case USER_QUERY:
|
||||
session.userName = request[0].str();
|
||||
session.userName = request[0];
|
||||
// setTimer(0.0f);
|
||||
session.out << "334 UGFzc3dvcmQ6" << CRLF;
|
||||
// setTimer(10.0f);
|
||||
@ -28,10 +29,10 @@ namespace mail {
|
||||
return 1;
|
||||
|
||||
case USER_SECRET_QUERY:
|
||||
session.password = request[0].str();
|
||||
session.password = request[0];
|
||||
// setTimer(0.0f);
|
||||
coreutils::Base64 base64;
|
||||
if(authLogin(session.userName, session.password)) {
|
||||
if(authLogin(session.userName, session.password, server)) {
|
||||
session.out << "235 2.7.0 Authentication successful" << CRLF;
|
||||
session.relay = true;
|
||||
session.authState = USER_KNOWN;
|
||||
@ -45,12 +46,11 @@ namespace mail {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __SMTP_AUTH::authLogin(coreutils::ZString userName, coreutils::ZString password) {
|
||||
// std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
|
||||
// coreutils::File secret(secretPath);
|
||||
// secret.read();
|
||||
// return secret.asString() == password;
|
||||
return true;
|
||||
bool __SMTP_AUTH::authLogin(coreutils::ZString &userName, coreutils::ZString &password, SMTPServer &server) {
|
||||
std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
|
||||
coreutils::File secret(secretPath);
|
||||
secret.read();
|
||||
return password == secret.asString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace mail {
|
||||
|
||||
public:
|
||||
int processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) override;
|
||||
bool authLogin(coreutils::ZString userName, coreutils::ZString password);
|
||||
bool authLogin(coreutils::ZString &userName, coreutils::ZString &password, SMTPServer &server);
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
namespace mail {
|
||||
|
||||
// class SMTPServer;
|
||||
|
||||
class __SMTP_MAIL : public SMTPCommand {
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user