summaryrefslogtreecommitdiff
path: root/cpp/src
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
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')
-rw-r--r--cpp/src/qpid/broker/PreviewConnection.cpp13
-rw-r--r--cpp/src/qpid/broker/PreviewConnection.h13
-rw-r--r--cpp/src/qpid/broker/PreviewConnectionHandler.cpp27
-rw-r--r--cpp/src/qpid/broker/PreviewConnectionHandler.h8
4 files changed, 29 insertions, 32 deletions
diff --git a/cpp/src/qpid/broker/PreviewConnection.cpp b/cpp/src/qpid/broker/PreviewConnection.cpp
index 6f411c99d6..56de374b4d 100644
--- a/cpp/src/qpid/broker/PreviewConnection.cpp
+++ b/cpp/src/qpid/broker/PreviewConnection.cpp
@@ -39,10 +39,6 @@
#include <iostream>
#include <assert.h>
-#if HAVE_SASL
-#include <sasl/sasl.h>
-#endif
-
using namespace boost;
using namespace qpid::sys;
using namespace qpid::framing;
@@ -94,9 +90,6 @@ public:
PreviewConnection::PreviewConnection(ConnectionOutputHandler* out_, Broker& broker_, const std::string& mgmtId_, bool isLink) :
ConnectionState(out_, broker_),
-#if HAVE_SASL
- sasl_conn(NULL),
-#endif
adapter(*this, isLink),
mgmtClosing(false),
mgmtId(mgmtId_)
@@ -119,12 +112,6 @@ PreviewConnection::PreviewConnection(ConnectionOutputHandler* out_, Broker& brok
}
PreviewConnection::~PreviewConnection () {
-#if HAVE_LIBSASL2
- if (NULL != sasl_conn) {
- sasl_dispose(&sasl_conn);
- sasl_conn = NULL;
- }
-#endif
}
void PreviewConnection::received(framing::AMQFrame& frame){
diff --git a/cpp/src/qpid/broker/PreviewConnection.h b/cpp/src/qpid/broker/PreviewConnection.h
index c9e8b115d3..1faf4195b5 100644
--- a/cpp/src/qpid/broker/PreviewConnection.h
+++ b/cpp/src/qpid/broker/PreviewConnection.h
@@ -49,19 +49,11 @@
#include <boost/ptr_container/ptr_map.hpp>
-#if HAVE_SASL
-#include <sasl/sasl.h>
-#endif
-
namespace qpid {
namespace broker {
class PreviewConnection : public sys::ConnectionInputHandler, public ConnectionState
{
-#if HAVE_SASL
- friend class PreviewConnectionHandler;
-#endif
-
public:
PreviewConnection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false);
~PreviewConnection ();
@@ -86,11 +78,6 @@ class PreviewConnection : public sys::ConnectionInputHandler, public ConnectionS
management::Manageable::status_t
ManagementMethod (uint32_t methodId, management::Args& args);
- protected:
-#if HAVE_SASL
- sasl_conn_t *sasl_conn;
-#endif
-
private:
typedef boost::ptr_map<framing::ChannelId, PreviewSessionHandler> ChannelMap;
typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
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
diff --git a/cpp/src/qpid/broker/PreviewConnectionHandler.h b/cpp/src/qpid/broker/PreviewConnectionHandler.h
index 7c3636373a..0b729628a5 100644
--- a/cpp/src/qpid/broker/PreviewConnectionHandler.h
+++ b/cpp/src/qpid/broker/PreviewConnectionHandler.h
@@ -33,6 +33,10 @@
#include "qpid/framing/ProtocolVersion.h"
#include "qpid/Exception.h"
+#if HAVE_SASL
+#include <sasl/sasl.h>
+#endif
+
namespace qpid {
namespace broker {
@@ -44,12 +48,16 @@ class PreviewConnectionHandler : public framing::FrameHandler
struct Handler : public framing::AMQP_ServerOperations::ConnectionHandler,
public framing::AMQP_ClientOperations::ConnectionHandler
{
+#if HAVE_SASL
+ sasl_conn_t *sasl_conn;
+#endif
framing::AMQP_ClientProxy::Connection client;
framing::AMQP_ServerProxy::Connection server;
PreviewConnection& connection;
bool serverMode;
Handler(PreviewConnection& connection);
+ ~Handler();
void startOk(const qpid::framing::FieldTable& clientProperties,
const std::string& mechanism, const std::string& response,
const std::string& locale);