aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2014-02-13 21:08:37 +0100
committerVincent Richard <[email protected]>2014-02-13 21:08:37 +0100
commitc655495025d970df5945413fd877691618b2e7c2 (patch)
treee65f8d577600b9704cd77778eae5d7d06e6da6b3 /src
parentDemonstrates extraction of attachments from a message in a remote store. (diff)
downloadvmime-c655495025d970df5945413fd877691618b2e7c2.tar.gz
vmime-c655495025d970df5945413fd877691618b2e7c2.zip
Fixed problem when custom registered mechanism is used.
User-defined mechanisms should be tested first. Added function to determine whether a mechanism is built-in.
Diffstat (limited to 'src')
-rw-r--r--src/vmime/security/sasl/SASLMechanismFactory.cpp27
-rw-r--r--src/vmime/security/sasl/SASLMechanismFactory.hpp9
2 files changed, 23 insertions, 13 deletions
diff --git a/src/vmime/security/sasl/SASLMechanismFactory.cpp b/src/vmime/security/sasl/SASLMechanismFactory.cpp
index 255a13f1..7ccdce8d 100644
--- a/src/vmime/security/sasl/SASLMechanismFactory.cpp
+++ b/src/vmime/security/sasl/SASLMechanismFactory.cpp
@@ -73,19 +73,15 @@ shared_ptr <SASLMechanism> SASLMechanismFactory::create
{
const string name(utility::stringUtils::toUpper(name_));
- // Check for built-in mechanisms
- if (isMechanismSupported(name))
- {
- return make_shared <builtinSASLMechanism>(ctx, name);
- }
// Check for registered mechanisms
- else
- {
- MapType::iterator it = m_mechs.find(name);
+ MapType::iterator it = m_mechs.find(name);
- if (it != m_mechs.end())
- return (*it).second->create(ctx, name);
- }
+ if (it != m_mechs.end())
+ return (*it).second->create(ctx, name);
+
+ // Check for built-in mechanisms
+ if (isBuiltinMechanism(name))
+ return make_shared <builtinSASLMechanism>(ctx, name);
throw exceptions::no_such_mechanism(name);
return null;
@@ -130,8 +126,13 @@ const std::vector <string> SASLMechanismFactory::getSupportedMechanisms() const
bool SASLMechanismFactory::isMechanismSupported(const string& name) const
{
- return (gsasl_client_support_p(m_gsaslContext, name.c_str()) != 0 ||
- m_mechs.find(name) != m_mechs.end());
+ return isBuiltinMechanism(name) || m_mechs.find(name) != m_mechs.end();
+}
+
+
+bool SASLMechanismFactory::isBuiltinMechanism(const string& name) const
+{
+ return gsasl_client_support_p(m_gsaslContext, name.c_str()) != 0;
}
diff --git a/src/vmime/security/sasl/SASLMechanismFactory.hpp b/src/vmime/security/sasl/SASLMechanismFactory.hpp
index 3503f71b..6d328f01 100644
--- a/src/vmime/security/sasl/SASLMechanismFactory.hpp
+++ b/src/vmime/security/sasl/SASLMechanismFactory.hpp
@@ -121,6 +121,15 @@ public:
*/
bool isMechanismSupported(const string& name) const;
+ /** Test whether an authentication mechanism is directly supported
+ * by the underlying SASL library.
+ *
+ * @param name mechanism name
+ * @return true if the specified mechanism is built-in,
+ * or false otherwise
+ */
+ bool isBuiltinMechanism(const string& name) const;
+
private:
#ifdef GSASL_VERSION