Author: gsim
Date: Wed Jan 30 04:18:53 2008
New Revision: 616736
URL: http://svn.apache.org/viewvc?rev=616736&view=rev
Log:
Parse out the userid and password from the response; a small step on the road
to authentication.
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp?rev=616736&r1=616735&r2=616736&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp Wed Jan 30
04:18:53 2008
@@ -181,6 +181,16 @@
return status;
}
+void Connection::setUserId(const string& uid)
+{
+ userId = uid;
+ QPID_LOG (debug, "UserId is " << userId);
+}
+
+const string& Connection::getUserId() const
+{
+ return userId;
+}
}}
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.h?rev=616736&r1=616735&r2=616736&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.h Wed Jan 30
04:18:53 2008
@@ -95,6 +95,9 @@
management::Manageable::status_t
ManagementMethod (uint32_t methodId, management::Args& args);
+ void setUserId(const string& uid);
+ const string& getUserId() const;
+
private:
typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
@@ -109,6 +112,7 @@
ConnectionHandler adapter;
management::Client::shared_ptr mgmtObject;
bool mgmtClosing;
+ string userId;
};
}}
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp?rev=616736&r1=616735&r2=616736&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp Wed Jan
30 04:18:53 2008
@@ -29,10 +29,17 @@
using namespace qpid::broker;
using namespace qpid::framing;
+
+namespace
+{
+const std::string PLAIN = "PLAIN";
+const std::string en_US = "en_US";
+}
+
void ConnectionHandler::init(const framing::ProtocolInitiation& header) {
FieldTable properties;
- string mechanisms("PLAIN");
- string locales("en_US");
+ string mechanisms(PLAIN);
+ string locales(en_US);
handler->client.start(header.getMajor(), header.getMinor(), properties,
mechanisms, locales);
}
@@ -59,9 +66,20 @@
ConnectionHandler::Handler:: Handler(Connection& c) : client(c.getOutput()),
connection(c) {}
void ConnectionHandler::Handler::startOk(const FieldTable&
/*clientProperties*/,
- const string& /*mechanism*/,
- const string& /*response*/, const string& /*locale*/)
+ const string& mechanism,
+ const string& response, const string& /*locale*/)
{
+ //TODO: handle SASL mechanisms more cleverly
+ if (mechanism == PLAIN) {
+ if (response.size() > 0 && response[0] == (char) 0) {
+ string temp = response.substr(1);
+ string::size_type i = temp.find((char)0);
+ string uid = temp.substr(0, i);
+ string pwd = temp.substr(i + 1);
+ //TODO: authentication
+ connection.setUserId(uid);
+ }
+ }
client.tune(framing::CHANNEL_MAX, connection.getFrameMax(),
connection.getHeartbeat());
}