Author: gsim
Date: Mon Apr 14 06:57:36 2008
New Revision: 647800
URL: http://svn.apache.org/viewvc?rev=647800&view=rev
Log:
QPID-648: keep the sasl_conn member in the handler to avoid the need for friend
declaration
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.h
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.cpp?rev=647800&r1=647799&r2=647800&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.cpp
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.cpp Mon Apr
14 06:57:36 2008
@@ -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 @@
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 () {
-#if HAVE_LIBSASL2
- if (NULL != sasl_conn) {
- sasl_dispose(&sasl_conn);
- sasl_conn = NULL;
- }
-#endif
}
void PreviewConnection::received(framing::AMQFrame& frame){
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.h?rev=647800&r1=647799&r2=647800&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.h Mon Apr
14 06:57:36 2008
@@ -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 ();
@@ -85,11 +77,6 @@
management::ManagementObject::shared_ptr GetManagementObject (void) const;
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;
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.cpp?rev=647800&r1=647799&r2=647800&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
Mon Apr 14 06:57:36 2008
@@ -79,8 +79,23 @@
}
}
-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 @@
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 @@
// 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
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.h?rev=647800&r1=647799&r2=647800&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.h
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.h
Mon Apr 14 06:57:36 2008
@@ -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 @@
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);