aboutsummaryrefslogtreecommitdiffstats
path: root/examples/example6.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2006-01-26 21:27:56 +0000
committerVincent Richard <[email protected]>2006-01-26 21:27:56 +0000
commit6d433ae67857625de956d9ec23bf2aba1e3664ea (patch)
tree3ebddfccda6a0ce1c2f16f06447650e6cff5445d /examples/example6.cpp
parentTreat 'inline' parts without Content-[Id/Location] as attachments. (diff)
downloadvmime-6d433ae67857625de956d9ec23bf2aba1e3664ea.tar.gz
vmime-6d433ae67857625de956d9ec23bf2aba1e3664ea.zip
Non-SASL authenticator.
Diffstat (limited to 'examples/example6.cpp')
-rw-r--r--examples/example6.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/examples/example6.cpp b/examples/example6.cpp
index 6d8fe92f..344a4d87 100644
--- a/examples/example6.cpp
+++ b/examples/example6.cpp
@@ -35,7 +35,9 @@ static vmime::ref <vmime::net::session> g_session
= vmime::create <vmime::net::session>();
-// Authentification handler
+#if VMIME_HAVE_SASL_SUPPORT
+
+// SASL authentication handler
class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator
{
const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
@@ -97,6 +99,46 @@ private:
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