qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1546628 - in /qpid/trunk/qpid/cpp/src/qpid: amqp/Sasl.cpp amqp/Sasl.h messaging/amqp/ConnectionContext.cpp messaging/amqp/ConnectionContext.h messaging/amqp/Sasl.cpp messaging/amqp/Sasl.h
Date Fri, 29 Nov 2013 19:17:59 GMT
Author: gsim
Date: Fri Nov 29 19:17:59 2013
New Revision: 1546628

URL: http://svn.apache.org/r1546628
Log:
QPID-5379: fix security layer for 1.0 client

Modified:
    qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.cpp
    qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.h
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.h

Modified: qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.cpp?rev=1546628&r1=1546627&r2=1546628&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.cpp Fri Nov 29 19:17:59 2013
@@ -59,7 +59,7 @@ void Sasl::endFrame(void* frame)
 std::size_t Sasl::read(const char* data, size_t available)
 {
     size_t consumed = 0;
-    while (available - consumed > 4/*framesize*/) {
+    while (!stopReading() && available - consumed > 4/*framesize*/) {
         Decoder decoder(data+consumed, available-consumed);
         //read frame-header
         uint32_t frameSize = decoder.readUInt();
@@ -133,4 +133,9 @@ std::size_t Sasl::writeProtocolHeader(ch
     }
 }
 
+bool Sasl::stopReading()
+{
+    return false;
+}
+
 }} // namespace qpid::amqp

Modified: qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.h?rev=1546628&r1=1546627&r2=1546628&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/amqp/Sasl.h Fri Nov 29 19:17:59 2013
@@ -48,6 +48,7 @@ class Sasl : protected Reader
 
     void* startFrame();
     void endFrame(void*);
+    virtual bool stopReading();
 };
 }} // namespace qpid::amqp
 

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp?rev=1546628&r1=1546627&r2=1546628&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp Fri Nov 29 19:17:59
2013
@@ -34,6 +34,7 @@
 #include "qpid/framing/ProtocolInitiation.h"
 #include "qpid/framing/Uuid.h"
 #include "qpid/log/Statement.h"
+#include "qpid/sys/SecurityLayer.h"
 #include "qpid/sys/SystemInfo.h"
 #include "qpid/sys/Time.h"
 #include <vector>
@@ -53,7 +54,8 @@ ConnectionContext::ConnectionContext(con
       writeHeader(false),
       readHeader(false),
       haveOutput(false),
-      state(DISCONNECTED)
+      state(DISCONNECTED),
+      codecAdapter(*this)
 {
     urls.insert(urls.begin(), url);
     if (pn_transport_bind(engine, connection)) {
@@ -997,5 +999,24 @@ bool ConnectionContext::restartSessions(
     }
 }
 
+void ConnectionContext::initSecurityLayer(qpid::sys::SecurityLayer& s)
+{
+    s.init(&codecAdapter);
+}
+
+ConnectionContext::CodecAdapter::CodecAdapter(ConnectionContext& c) : context(c) {}
+std::size_t ConnectionContext::CodecAdapter::decode(const char* buffer, std::size_t size)
+{
+    return context.decodePlain(buffer, size);
+}
+std::size_t ConnectionContext::CodecAdapter::encode(char* buffer, std::size_t size)
+{
+    return context.encodePlain(buffer, size);
+}
+bool ConnectionContext::CodecAdapter::canEncode()
+{
+    return context.canEncodePlain();
+}
+
 
 }}} // namespace qpid::messaging::amqp

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h?rev=1546628&r1=1546627&r2=1546628&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h Fri Nov 29 19:17:59 2013
@@ -45,6 +45,7 @@ namespace framing {
 class ProtocolVersion;
 }
 namespace sys {
+class SecurityLayer;
 struct SecuritySettings;
 }
 namespace messaging {
@@ -112,9 +113,20 @@ class ConnectionContext : public qpid::s
     void reconnect();
     std::string getUrl() const;
     const qpid::sys::SecuritySettings* getTransportSecuritySettings();
+    void initSecurityLayer(qpid::sys::SecurityLayer&);
 
   private:
     typedef std::map<std::string, boost::shared_ptr<SessionContext> > SessionMap;
+    class CodecAdapter : public qpid::sys::Codec
+    {
+      public:
+        CodecAdapter(ConnectionContext&);
+        std::size_t decode(const char* buffer, std::size_t size);
+        std::size_t encode(char* buffer, std::size_t size);
+        bool canEncode();
+      private:
+        ConnectionContext& context;
+    };
 
     boost::shared_ptr<DriverImpl> driver;
     boost::shared_ptr<Transport> transport;
@@ -134,6 +146,7 @@ class ConnectionContext : public qpid::s
         CONNECTED
     } state;
     std::auto_ptr<Sasl> sasl;
+    CodecAdapter codecAdapter;
 
     void check();
     void wait();

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp?rev=1546628&r1=1546627&r2=1546628&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp Fri Nov 29 19:17:59 2013
@@ -131,11 +131,16 @@ void Sasl::outcome(uint8_t result)
 
     securityLayer = sasl->getSecurityLayer(context.maxFrameSize);
     if (securityLayer.get()) {
-        securityLayer->init(&context);
+        context.initSecurityLayer(*securityLayer);
     }
     context.activateOutput();
 }
 
+bool Sasl::stopReading()
+{
+    return state != NONE;
+}
+
 qpid::sys::Codec* Sasl::getSecurityLayer()
 {
     return securityLayer.get();

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.h?rev=1546628&r1=1546627&r2=1546628&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/Sasl.h Fri Nov 29 19:17:59 2013
@@ -67,6 +67,8 @@ class Sasl : public qpid::sys::Codec, qp
     void challenge(); //null != empty string
     void outcome(uint8_t result, const std::string&);
     void outcome(uint8_t result);
+  protected:
+    bool stopReading();
 };
 }}} // namespace qpid::messaging::amqp
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message