summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-04-14 13:57:36 +0000
committerGordon Sim <gsim@apache.org>2008-04-14 13:57:36 +0000
commit88fd894652067d48d9b1988d36ee081ae46f365f (patch)
treedb5dcd4db28aad2a37c1d442015b6a816982939b /cpp/src/qpid/broker/PreviewConnectionHandler.cpp
parentf58096364147d54676f520efc003c58fa7897d0f (diff)
downloadqpid-python-88fd894652067d48d9b1988d36ee081ae46f365f.tar.gz
QPID-648: keep the sasl_conn member in the handler to avoid the need for friend declaration
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@647800 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/PreviewConnectionHandler.cpp')
-rw-r--r--cpp/src/qpid/broker/PreviewConnectionHandler.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/cpp/src/qpid/broker/PreviewConnectionHandler.cpp b/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
index 5c5f2f263e..48b8997545 100644
--- a/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
+++ b/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
@@ -79,8 +79,23 @@ PreviewConnectionHandler::PreviewConnectionHandler(PreviewConnection& connection
}
}
-PreviewConnectionHandler::Handler:: Handler(PreviewConnection& c) : client(c.getOutput()), server(c.getOutput()),
- connection(c), serverMode(false) {}
+PreviewConnectionHandler::Handler::Handler(PreviewConnection& c) :
+#if HAVE_SASL
+ sasl_conn(NULL),
+#endif
+ client(c.getOutput()), server(c.getOutput()),
+ connection(c), serverMode(false)
+ {}
+
+PreviewConnectionHandler::Handler::~Handler()
+{
+#if HAVE_LIBSASL2
+ if (NULL != sasl_conn) {
+ sasl_dispose(&sasl_conn);
+ sasl_conn = NULL;
+ }
+#endif
+}
void PreviewConnectionHandler::Handler::startOk(const framing::FieldTable& /*clientProperties*/,
const string& mechanism,
@@ -99,18 +114,18 @@ void PreviewConnectionHandler::Handler::startOk(const framing::FieldTable& /*cli
if (connection.getBroker().getOptions().auth) {
int code = sasl_server_new(BROKER_SASL_NAME,
NULL, NULL, NULL, NULL, NULL, 0,
- &connection.sasl_conn);
+ &sasl_conn);
if (SASL_OK != code) {
QPID_LOG(info, "SASL Plain: Connection creation failed: "
- << sasl_errdetail(connection.sasl_conn));
+ << sasl_errdetail(sasl_conn));
// TODO: Change this to an exception signaling
// server error, when one is available
throw CommandInvalidException("Unable to perform authentication");
}
- code = sasl_checkpass(connection.sasl_conn,
+ code = sasl_checkpass(sasl_conn,
uid.c_str(), uid.length(),
pwd.c_str(), pwd.length());
if (SASL_OK == code) {
@@ -119,7 +134,7 @@ void PreviewConnectionHandler::Handler::startOk(const framing::FieldTable& /*cli
// See man sasl_errors(3) or sasl/sasl.h for possible errors
QPID_LOG(info, "SASL Plain: Authentication rejected for "
<< uid << ": "
- << sasl_errdetail(connection.sasl_conn));
+ << sasl_errdetail(sasl_conn));
// TODO: Change this to an exception signaling
// authentication failure, when one is available