aboutsummaryrefslogtreecommitdiffstats
path: root/src/security/sasl
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-11-21 21:16:57 +0000
committerVincent Richard <[email protected]>2013-11-21 21:16:57 +0000
commitf9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 (patch)
tree2bdc90e361a8f6e0a81164cf67afec9f78f9b959 /src/security/sasl
parentPer-protocol include files. (diff)
downloadvmime-f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8.tar.gz
vmime-f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8.zip
Boost/C++11 shared pointers.
Diffstat (limited to 'src/security/sasl')
-rw-r--r--src/security/sasl/SASLContext.cpp24
-rw-r--r--src/security/sasl/SASLMechanismFactory.cpp8
-rw-r--r--src/security/sasl/SASLSession.cpp26
-rw-r--r--src/security/sasl/SASLSocket.cpp2
-rw-r--r--src/security/sasl/builtinSASLMechanism.cpp8
-rw-r--r--src/security/sasl/defaultSASLAuthenticator.cpp24
6 files changed, 46 insertions, 46 deletions
diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp
index 7b24f1e3..c4d60bd9 100644
--- a/src/security/sasl/SASLContext.cpp
+++ b/src/security/sasl/SASLContext.cpp
@@ -62,27 +62,27 @@ SASLContext::~SASLContext()
}
-ref <SASLSession> SASLContext::createSession
+shared_ptr <SASLSession> SASLContext::createSession
(const string& serviceName,
- ref <authenticator> auth, ref <SASLMechanism> mech)
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
{
- return vmime::create <SASLSession>
- (serviceName, thisRef().dynamicCast <SASLContext>(), auth, mech);
+ return make_shared <SASLSession>
+ (serviceName, dynamicCast <SASLContext>(shared_from_this()), auth, mech);
}
-ref <SASLMechanism> SASLContext::createMechanism(const string& name)
+shared_ptr <SASLMechanism> SASLContext::createMechanism(const string& name)
{
return SASLMechanismFactory::getInstance()->create
- (thisRef().dynamicCast <SASLContext>(), name);
+ (dynamicCast <SASLContext>(shared_from_this()), name);
}
-ref <SASLMechanism> SASLContext::suggestMechanism
- (const std::vector <ref <SASLMechanism> >& mechs)
+shared_ptr <SASLMechanism> SASLContext::suggestMechanism
+ (const std::vector <shared_ptr <SASLMechanism> >& mechs)
{
if (mechs.empty())
- return 0;
+ return null;
std::ostringstream oss;
@@ -102,7 +102,7 @@ ref <SASLMechanism> SASLContext::suggestMechanism
}
}
- return 0;
+ return null;
}
@@ -113,7 +113,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe
utility::inputStreamStringAdapter is(input);
utility::outputStreamStringAdapter os(res);
- ref <utility::encoder::encoder> dec =
+ shared_ptr <utility::encoder::encoder> dec =
utility::encoder::encoderFactory::getInstance()->create("base64");
dec->decode(is, os);
@@ -134,7 +134,7 @@ const string SASLContext::encodeB64(const byte_t* input, const long inputLen)
utility::inputStreamByteBufferAdapter is(input, inputLen);
utility::outputStreamStringAdapter os(res);
- ref <utility::encoder::encoder> enc =
+ shared_ptr <utility::encoder::encoder> enc =
utility::encoder::encoderFactory::getInstance()->create("base64");
enc->encode(is, os);
diff --git a/src/security/sasl/SASLMechanismFactory.cpp b/src/security/sasl/SASLMechanismFactory.cpp
index 0f2dd3af..255a13f1 100644
--- a/src/security/sasl/SASLMechanismFactory.cpp
+++ b/src/security/sasl/SASLMechanismFactory.cpp
@@ -68,15 +68,15 @@ SASLMechanismFactory* SASLMechanismFactory::getInstance()
}
-ref <SASLMechanism> SASLMechanismFactory::create
- (ref <SASLContext> ctx, const string& name_)
+shared_ptr <SASLMechanism> SASLMechanismFactory::create
+ (shared_ptr <SASLContext> ctx, const string& name_)
{
const string name(utility::stringUtils::toUpper(name_));
// Check for built-in mechanisms
if (isMechanismSupported(name))
{
- return vmime::create <builtinSASLMechanism>(ctx, name);
+ return make_shared <builtinSASLMechanism>(ctx, name);
}
// Check for registered mechanisms
else
@@ -88,7 +88,7 @@ ref <SASLMechanism> SASLMechanismFactory::create
}
throw exceptions::no_such_mechanism(name);
- return 0;
+ return null;
}
diff --git a/src/security/sasl/SASLSession.cpp b/src/security/sasl/SASLSession.cpp
index c34bdd7f..1bdd0889 100644
--- a/src/security/sasl/SASLSession.cpp
+++ b/src/security/sasl/SASLSession.cpp
@@ -43,8 +43,8 @@ namespace security {
namespace sasl {
-SASLSession::SASLSession(const string& serviceName, ref <SASLContext> ctx,
- ref <authenticator> auth, ref <SASLMechanism> mech)
+SASLSession::SASLSession(const string& serviceName, shared_ptr <SASLContext> ctx,
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
: m_serviceName(serviceName), m_context(ctx), m_auth(auth),
m_mech(mech), m_gsaslContext(0), m_gsaslSession(0)
{
@@ -61,38 +61,38 @@ SASLSession::SASLSession(const string& serviceName, ref <SASLContext> ctx,
SASLSession::~SASLSession()
{
gsasl_finish(m_gsaslSession);
- m_gsaslSession = 0;
+ m_gsaslSession = NULL;
gsasl_done(m_gsaslContext);
- m_gsaslContext = 0;
+ m_gsaslContext = NULL;
}
void SASLSession::init()
{
- ref <SASLAuthenticator> saslAuth = m_auth.dynamicCast <SASLAuthenticator>();
+ shared_ptr <SASLAuthenticator> saslAuth = dynamicCast <SASLAuthenticator>(m_auth);
if (saslAuth)
{
saslAuth->setSASLMechanism(m_mech);
- saslAuth->setSASLSession(thisRef().dynamicCast <SASLSession>());
+ saslAuth->setSASLSession(dynamicCast <SASLSession>(shared_from_this()));
}
}
-ref <authenticator> SASLSession::getAuthenticator()
+shared_ptr <authenticator> SASLSession::getAuthenticator()
{
return m_auth;
}
-ref <SASLMechanism> SASLSession::getMechanism()
+shared_ptr <SASLMechanism> SASLSession::getMechanism()
{
return m_mech;
}
-ref <SASLContext> SASLSession::getContext()
+shared_ptr <SASLContext> SASLSession::getContext()
{
return m_context;
}
@@ -102,14 +102,14 @@ bool SASLSession::evaluateChallenge
(const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
{
- return m_mech->step(thisRef().dynamicCast <SASLSession>(),
+ return m_mech->step(dynamicCast <SASLSession>(shared_from_this()),
challenge, challengeLen, response, responseLen);
}
-ref <net::socket> SASLSession::getSecuredSocket(ref <net::socket> sok)
+shared_ptr <net::socket> SASLSession::getSecuredSocket(shared_ptr <net::socket> sok)
{
- return vmime::create <SASLSocket>(thisRef().dynamicCast <SASLSession>(), sok);
+ return make_shared <SASLSocket>(dynamicCast <SASLSession>(shared_from_this()), sok);
}
@@ -126,7 +126,7 @@ int SASLSession::gsaslCallback
SASLSession* sess = reinterpret_cast <SASLSession*>(gsasl_callback_hook_get(ctx));
if (!sess) return GSASL_AUTHENTICATION_ERROR;
- ref <authenticator> auth = sess->getAuthenticator();
+ shared_ptr <authenticator> auth = sess->getAuthenticator();
try
{
diff --git a/src/security/sasl/SASLSocket.cpp b/src/security/sasl/SASLSocket.cpp
index b6b1d272..37e297dc 100644
--- a/src/security/sasl/SASLSocket.cpp
+++ b/src/security/sasl/SASLSocket.cpp
@@ -43,7 +43,7 @@ namespace sasl {
-SASLSocket::SASLSocket(ref <SASLSession> sess, ref <net::socket> wrapped)
+SASLSocket::SASLSocket(shared_ptr <SASLSession> sess, shared_ptr <net::socket> wrapped)
: m_session(sess), m_wrapped(wrapped),
m_pendingBuffer(0), m_pendingPos(0), m_pendingLen(0)
{
diff --git a/src/security/sasl/builtinSASLMechanism.cpp b/src/security/sasl/builtinSASLMechanism.cpp
index 86b429bf..e7bd723e 100644
--- a/src/security/sasl/builtinSASLMechanism.cpp
+++ b/src/security/sasl/builtinSASLMechanism.cpp
@@ -45,7 +45,7 @@ namespace security {
namespace sasl {
-builtinSASLMechanism::builtinSASLMechanism(ref <SASLContext> ctx, const string& name)
+builtinSASLMechanism::builtinSASLMechanism(shared_ptr <SASLContext> ctx, const string& name)
: m_context(ctx), m_name(name), m_complete(false)
{
}
@@ -63,7 +63,7 @@ const string builtinSASLMechanism::getName() const
bool builtinSASLMechanism::step
- (ref <SASLSession> sess, const byte_t* challenge, const long challengeLen,
+ (shared_ptr <SASLSession> sess, const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
{
char* output = 0;
@@ -121,7 +121,7 @@ bool builtinSASLMechanism::isComplete() const
void builtinSASLMechanism::encode
- (ref <SASLSession> sess, const byte_t* input, const long inputLen,
+ (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
{
char* coutput = 0;
@@ -154,7 +154,7 @@ void builtinSASLMechanism::encode
void builtinSASLMechanism::decode
- (ref <SASLSession> sess, const byte_t* input, const long inputLen,
+ (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
{
char* coutput = 0;
diff --git a/src/security/sasl/defaultSASLAuthenticator.cpp b/src/security/sasl/defaultSASLAuthenticator.cpp
index bb72e56f..7fe9b3eb 100644
--- a/src/security/sasl/defaultSASLAuthenticator.cpp
+++ b/src/security/sasl/defaultSASLAuthenticator.cpp
@@ -51,14 +51,14 @@ defaultSASLAuthenticator::~defaultSASLAuthenticator()
}
-const std::vector <ref <SASLMechanism> >
+const std::vector <shared_ptr <SASLMechanism> >
defaultSASLAuthenticator::getAcceptableMechanisms
- (const std::vector <ref <SASLMechanism> >& available,
- ref <SASLMechanism> suggested) const
+ (const std::vector <shared_ptr <SASLMechanism> >& available,
+ shared_ptr <SASLMechanism> suggested) const
{
if (suggested)
{
- std::vector <ref <SASLMechanism> > res;
+ std::vector <shared_ptr <SASLMechanism> > res;
res.push_back(suggested);
@@ -103,42 +103,42 @@ const string defaultSASLAuthenticator::getAnonymousToken() const
const string defaultSASLAuthenticator::getServiceName() const
{
- return m_saslSession.acquire()->getServiceName();
+ return m_saslSession.lock()->getServiceName();
}
-void defaultSASLAuthenticator::setService(ref <net::service> serv)
+void defaultSASLAuthenticator::setService(shared_ptr <net::service> serv)
{
m_service = serv;
m_default.setService(serv);
}
-weak_ref <net::service> defaultSASLAuthenticator::getService() const
+weak_ptr <net::service> defaultSASLAuthenticator::getService() const
{
return m_service;
}
-void defaultSASLAuthenticator::setSASLSession(ref <SASLSession> sess)
+void defaultSASLAuthenticator::setSASLSession(shared_ptr <SASLSession> sess)
{
m_saslSession = sess;
}
-ref <SASLSession> defaultSASLAuthenticator::getSASLSession() const
+shared_ptr <SASLSession> defaultSASLAuthenticator::getSASLSession() const
{
- return m_saslSession.acquire().constCast <SASLSession>();
+ return constCast <SASLSession>(m_saslSession.lock());
}
-void defaultSASLAuthenticator::setSASLMechanism(ref <SASLMechanism> mech)
+void defaultSASLAuthenticator::setSASLMechanism(shared_ptr <SASLMechanism> mech)
{
m_saslMech = mech;
}
-ref <SASLMechanism> defaultSASLAuthenticator::getSASLMechanism() const
+shared_ptr <SASLMechanism> defaultSASLAuthenticator::getSASLMechanism() const
{
return m_saslMech;
}