Non-SASL authenticator.
This commit is contained in:
parent
1b7a7a7694
commit
6d433ae678
@ -35,7 +35,9 @@ static vmime::ref <vmime::net::session> g_session
|
|||||||
= vmime::create <vmime::net::session>();
|
= vmime::create <vmime::net::session>();
|
||||||
|
|
||||||
|
|
||||||
// Authentification handler
|
#if VMIME_HAVE_SASL_SUPPORT
|
||||||
|
|
||||||
|
// SASL authentication handler
|
||||||
class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator
|
class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator
|
||||||
{
|
{
|
||||||
const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
|
const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
|
||||||
@ -97,6 +99,46 @@ private:
|
|||||||
mutable vmime::string m_password;
|
mutable vmime::string m_password;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else // !VMIME_HAVE_SASL_SUPPORT
|
||||||
|
|
||||||
|
// Simple authentication handler
|
||||||
|
class interactiveAuthenticator : public vmime::security::defaultAuthenticator
|
||||||
|
{
|
||||||
|
const vmime::string getUsername() const
|
||||||
|
{
|
||||||
|
if (m_username.empty())
|
||||||
|
m_username = getUserInput("Username");
|
||||||
|
|
||||||
|
return m_username;
|
||||||
|
}
|
||||||
|
|
||||||
|
const vmime::string getPassword() const
|
||||||
|
{
|
||||||
|
if (m_password.empty())
|
||||||
|
m_password = getUserInput("Password");
|
||||||
|
|
||||||
|
return m_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const vmime::string getUserInput(const std::string& prompt)
|
||||||
|
{
|
||||||
|
std::cout << prompt << ": ";
|
||||||
|
std::cout.flush();
|
||||||
|
|
||||||
|
vmime::string res;
|
||||||
|
std::getline(std::cin, res);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
mutable vmime::string m_username;
|
||||||
|
mutable vmime::string m_password;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMIME_HAVE_SASL_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
#if VMIME_HAVE_TLS_SUPPORT
|
#if VMIME_HAVE_TLS_SUPPORT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user