activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r943731 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ decaf/internal/net/ decaf/internal/net/ssl/openssl/ decaf/internal/net/tcp/
Date Wed, 12 May 2010 22:40:19 GMT
Author: tabish
Date: Wed May 12 22:40:18 2010
New Revision: 943731

URL: http://svn.apache.org/viewvc?rev=943731&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-140

Add a SocketFileDescriptor to allow the OpenSSLSocket class to connect the APR socket fd to
a BIO structure.  Implement the guts of OpenSSLSocket.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.cpp
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.h
  (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=943731&r1=943730&r2=943731&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Wed May 12 22:40:18 2010
@@ -485,6 +485,7 @@ cc_sources = \
     decaf/internal/io/StandardInputStream.cpp \
     decaf/internal/io/StandardOutputStream.cpp \
     decaf/internal/net/Network.cpp \
+    decaf/internal/net/SocketFileDescriptor.cpp \
     decaf/internal/net/URIEncoderDecoder.cpp \
     decaf/internal/net/URIHelper.cpp \
     decaf/internal/net/ssl/DefaultSSLContext.cpp \
@@ -1164,6 +1165,7 @@ h_sources = \
     decaf/internal/io/StandardInputStream.h \
     decaf/internal/io/StandardOutputStream.h \
     decaf/internal/net/Network.h \
+    decaf/internal/net/SocketFileDescriptor.h \
     decaf/internal/net/URIEncoderDecoder.h \
     decaf/internal/net/URIHelper.h \
     decaf/internal/net/URIType.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.cpp?rev=943731&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.cpp
Wed May 12 22:40:18 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SocketFileDescriptor.h"
+
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::internal;
+using namespace decaf::internal::net;
+
+////////////////////////////////////////////////////////////////////////////////
+SocketFileDescriptor::SocketFileDescriptor( long value ) : FileDescriptor( value, false )
{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SocketFileDescriptor::~SocketFileDescriptor() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long SocketFileDescriptor::getValue() const {
+    return this->descriptor;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.h?rev=943731&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.h
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.h
Wed May 12 22:40:18 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_INTERNAL_NET_SOCKETFILEDESCRIPTOR_H_
+#define _DECAF_INTERNAL_NET_SOCKETFILEDESCRIPTOR_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/io/FileDescriptor.h>
+
+namespace decaf {
+namespace internal {
+namespace net {
+
+    /**
+     * File Descriptor type used internally by Decaf Socket objects.
+     *
+     * @since 1.0
+     */
+    class DECAF_API SocketFileDescriptor : public decaf::io::FileDescriptor {
+    public:
+
+        SocketFileDescriptor( long value );
+
+        virtual ~SocketFileDescriptor();
+
+        /**
+         * Gets the OS Level FileDescriptor
+         *
+         * @return a FileDescriptor value.
+         */
+        long getValue() const;
+
+    };
+
+}}}
+
+#endif /* _DECAF_INTERNAL_NET_SOCKETFILEDESCRIPTOR_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/SocketFileDescriptor.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp?rev=943731&r1=943730&r2=943731&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
Wed May 12 22:40:18 2010
@@ -19,13 +19,22 @@
 
 #ifdef HAVE_OPENSSL
     #include <openssl/ssl.h>
+    #include <openssl/x509.h>
+    #include <openssl/x509v3.h>
+    #include <openssl/bio.h>
 #endif
 
+#include <apr_strings.h>
+
 #include <decaf/net/SocketImpl.h>
 #include <decaf/io/IOException.h>
+#include <decaf/net/SocketException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/internal/net/SocketFileDescriptor.h>
 #include <decaf/internal/net/ssl/openssl/OpenSSLSocketException.h>
+#include <decaf/internal/net/ssl/openssl/OpenSSLSocketInputStream.h>
+#include <decaf/internal/net/ssl/openssl/OpenSSLSocketOutputStream.h>
 
 using namespace decaf;
 using namespace decaf::lang;
@@ -74,7 +83,8 @@ namespace openssl {
 }}}}}
 
 ////////////////////////////////////////////////////////////////////////////////
-OpenSSLSocket::OpenSSLSocket( void* ssl ) : SSLSocket(), data( new SocketData() ) {
+OpenSSLSocket::OpenSSLSocket( void* ssl ) :
+    SSLSocket(), data( new SocketData() ), input( NULL ), output( NULL ) {
 
     if( ssl == NULL ) {
         throw NullPointerException(
@@ -100,12 +110,146 @@ OpenSSLSocket::~OpenSSLSocket() {
 #endif
 
         delete data;
+        delete input;
+        delete output;
     }
     DECAF_CATCH_NOTHROW( Exception )
     DECAF_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::connect( const std::string& host, int port, int timeout )
+    throw( decaf::io::IOException,
+           decaf::lang::exceptions::IllegalArgumentException ) {
+
+    try{
+
+        SSLSocket::connect( host, port, timeout );
+        if( isConnected() ) {
+
+            BIO* bio = BIO_new( BIO_s_socket() );
+            if( !bio ) {
+                throw SocketException(
+                    __FILE__, __LINE__, "Failed to create SSL IO Bindings");
+            }
+
+            const SocketFileDescriptor* fd =
+                dynamic_cast<const SocketFileDescriptor*>( this->impl->getFileDescriptor()
);
+
+            if( fd == NULL ) {
+                throw SocketException(
+                    __FILE__, __LINE__, "Invalid File Descriptor returned from Socket" );
+            }
+
+            BIO_set_fd( bio, (int)fd->getValue(), BIO_NOCLOSE );
+            SSL_set_bio( this->data->ssl, bio, bio );
+
+            int result = SSL_connect( this->data->ssl );
+
+            switch( SSL_get_error( this->data->ssl, result ) ) {
+                case SSL_ERROR_NONE:
+                    verifyServerCert( host );
+                    return;
+                case SSL_ERROR_SSL:
+                case SSL_ERROR_ZERO_RETURN:
+                case SSL_ERROR_SYSCALL:
+                    SSLSocket::close();
+                    throw OpenSSLSocketException( __FILE__, __LINE__ );
+            }
+        }
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( IllegalArgumentException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::close() throw( decaf::io::IOException ) {
+
+    try{
+
+        if( isClosed() ) {
+            return;
+        }
+
+        SSLSocket::close();
+
+        if( this->input != NULL ) {
+            this->input->close();
+        }
+        if( this->output != NULL ) {
+            this->output->close();
+        }
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+decaf::io::InputStream* OpenSSLSocket::getInputStream() throw( decaf::io::IOException ) {
+
+    checkClosed();
+
+    try{
+        if( this->input == NULL ) {
+            this->input = new OpenSSLSocketInputStream( this );
+        }
+
+        return this->input;
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+decaf::io::OutputStream* OpenSSLSocket::getOutputStream() throw( decaf::io::IOException )
{
+
+    checkClosed();
+
+    try{
+        if( this->output == NULL ) {
+            this->output = new OpenSSLSocketOutputStream( this );
+        }
+
+        return this->output;
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::shutdownInput() throw( decaf::io::IOException ) {
+
+    throw SocketException(
+        __FILE__, __LINE__, "Not supported for SSL Sockets" );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::shutdownOutput() throw( decaf::io::IOException ) {
+
+    throw SocketException(
+        __FILE__, __LINE__, "Not supported for SSL Sockets" );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::setOOBInline( bool value DECAF_UNUSED ) throw( SocketException ) {
+
+    throw SocketException(
+        __FILE__, __LINE__, "Not supported for SSL Sockets" );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::sendUrgentData( int data DECAF_UNUSED ) throw( decaf::io::IOException
) {
+
+    throw SocketException(
+        __FILE__, __LINE__, "Not supported for SSL Sockets" );
+}
+
+////////////////////////////////////////////////////////////////////////////////
 std::vector<std::string> OpenSSLSocket::getSupportedCipherSuites() const {
 
     return std::vector<std::string>();
@@ -251,7 +395,7 @@ void OpenSSLSocket::write( const unsigne
                 __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
         }
 
-        std::size_t remaining = length;
+        int remaining = length;
 
         while( remaining > 0 && !isClosed() ) {
 
@@ -291,3 +435,83 @@ int OpenSSLSocket::available() {
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLSocket::verifyServerCert( const std::string& serverName ) {
+
+    X509* cert = SSL_get_peer_certificate( this->data->ssl );
+
+    if( cert == NULL ) {
+        this->close();
+        throw OpenSSLSocketException(
+            __FILE__, __LINE__,
+            "No server certificate for verify for host: %s", serverName.c_str() );
+    }
+
+    class Finalizer {
+    private:
+
+        X509* cert;
+
+    public:
+
+        Finalizer( X509* cert ) : cert( cert ) {
+        }
+
+        ~Finalizer() {
+            if( cert != NULL ) {
+                X509_free( cert );
+            }
+        }
+    };
+
+    // We check the extensions first since newer x509v3 Certificates are recommended
+    // to store the FQDN in the dsnName field of the subjectAltName extension.  If we
+    // don't find it there then we can check the commonName field which is where older
+    // Certificates placed the FQDN.
+    int extensions = X509_get_ext_count( cert );
+
+    for( int ix = 0; ix < extensions; ix++ ) {
+
+        X509_EXTENSION* extension = X509_get_ext( cert, ix );
+        const char* extensionName = OBJ_nid2sn( OBJ_obj2nid( X509_EXTENSION_get_object( extension
) ) );
+
+        if( apr_strnatcmp( "subjectAltName", extensionName ) == 0 ) {
+
+            const X509V3_EXT_METHOD* method = X509V3_EXT_get( extension );
+            if( method == NULL ) {
+                break;
+            }
+
+            const unsigned char* data = extension->value->data;
+            STACK_OF(CONF_VALUE)* confValue =
+                method->i2v( method, method->d2i( NULL, &data, extension->value->length
), NULL );
+
+            CONF_VALUE* value = NULL;
+
+            for( int iy = 0; iy < sk_CONF_VALUE_num( confValue ); iy++ ) {
+                value = sk_CONF_VALUE_value( confValue, iy );
+                if( ( apr_strnatcmp( value->name, "DNS" ) == 0 ) &&
+                      apr_strnatcmp( value->value, serverName.c_str() ) == 0 ) {
+
+                    // Found it.
+                    return;
+                }
+            }
+        }
+    }
+
+    X509_NAME* subject = X509_get_subject_name( cert );
+    char buffer[256];
+
+    if( subject != NULL && X509_NAME_get_text_by_NID( subject, NID_commonName, buffer,
256 ) > 0 ) {
+        buffer[255] = 0;
+        if( apr_strnatcmp( buffer, serverName.c_str() ) == 0 ) {
+            return;
+        }
+    }
+
+    // We got here so no match to serverName in the Certificate
+    throw OpenSSLSocketException(
+        __FILE__, __LINE__, "Server Certificate Name doesn't match the URI Host Name value."
);
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h?rev=943731&r1=943730&r2=943731&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h
Wed May 12 22:40:18 2010
@@ -22,6 +22,9 @@
 
 #include <decaf/net/ssl/SSLSocket.h>
 
+#include <decaf/io/InputStream.h>
+#include <decaf/io/OutputStream.h>
+
 namespace decaf {
 namespace internal {
 namespace net {
@@ -39,15 +42,66 @@ namespace openssl {
     class DECAF_API OpenSSLSocket : public decaf::net::ssl::SSLSocket {
     private:
 
+        // Private data related to the OpenSSL Socket impl.
         SocketData* data;
 
+        // The InputStream owned by this Socket
+        decaf::io::InputStream* input;
+
+        // The OutputStream owned by this Socket
+        decaf::io::OutputStream* output;
+
     public:
 
         OpenSSLSocket( void* ssl );
 
         virtual ~OpenSSLSocket();
 
-    public:
+    public:  // Socket Overrides.
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual void connect( const std::string& host, int port, int timeout )
+            throw( decaf::io::IOException,
+                   decaf::lang::exceptions::IllegalArgumentException );
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual void close() throw( decaf::io::IOException );
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual decaf::io::InputStream* getInputStream() throw( decaf::io::IOException );
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual decaf::io::OutputStream* getOutputStream() throw( decaf::io::IOException
);
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual void shutdownInput() throw( decaf::io::IOException );
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual void shutdownOutput() throw( decaf::io::IOException );
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual void setOOBInline( bool value ) throw( decaf::net::SocketException );
+
+        /**
+         * {@inheritDoc}
+         */
+        virtual void sendUrgentData( int data ) throw( decaf::io::IOException );
+
+    public:  // SSLSocket Overrides
 
         /**
          * {@inheritDoc}
@@ -148,6 +202,12 @@ namespace openssl {
          */
         int available();
 
+    private:
+
+        // Perform some additional checks on the Server's Certificate to ensure that
+        // its really valid.
+        void verifyServerCert( const std::string& serverName );
+
     };
 
 }}}}}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp?rev=943731&r1=943730&r2=943731&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp
Wed May 12 22:40:18 2010
@@ -23,6 +23,8 @@
 #include <decaf/internal/net/ssl/openssl/OpenSSLSocket.h>
 #include <decaf/internal/net/ssl/openssl/OpenSSLContextSpi.h>
 
+#include <memory>
+
 #ifdef HAVE_OPENSSL
 #include <openssl/ssl.h>
 #endif
@@ -32,6 +34,7 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 using namespace decaf::io;
 using namespace decaf::net;
+using namespace decaf::net::ssl;
 using namespace decaf::internal;
 using namespace decaf::internal::net;
 using namespace decaf::internal::net::ssl;
@@ -81,11 +84,24 @@ Socket* OpenSSLSocketFactory::createSock
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Socket* OpenSSLSocketFactory::createSocket( const std::string& name, int port )
+Socket* OpenSSLSocketFactory::createSocket( const std::string& hostname, int port )
     throw( decaf::io::IOException, decaf::net::UnknownHostException ) {
 
-    return NULL;
-}
+    try{
+
+#ifdef HAVE_OPENSSL
+        // Create a new SSL object for the Socket then create a new unconnected Socket.
+        SSL_CTX* ctx = static_cast<SSL_CTX*>( this->parent->getOpenSSLCtx() );
+        std::auto_ptr<SSLSocket> socket( new OpenSSLSocket( SSL_new( ctx ) ) );
+        socket->connect( hostname, port );
+        return socket.release();
+#else
+        return NULL;
+#endif
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )}
 
 ////////////////////////////////////////////////////////////////////////////////
 Socket* OpenSSLSocketFactory::createSocket( Socket* socket DECAF_UNUSED,

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.h?rev=943731&r1=943730&r2=943731&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.h
Wed May 12 22:40:18 2010
@@ -54,7 +54,7 @@ namespace openssl {
         /**
          * {@inheritDoc}
          */
-        virtual decaf::net::Socket* createSocket( const std::string& name, int port )
+        virtual decaf::net::Socket* createSocket( const std::string& hostname, int port
)
             throw( decaf::io::IOException, decaf::net::UnknownHostException );
 
         /**

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp?rev=943731&r1=943730&r2=943731&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
Wed May 12 22:40:18 2010
@@ -17,6 +17,7 @@
 
 #include "TcpSocket.h"
 
+#include <decaf/internal/net/SocketFileDescriptor.h>
 #include <decaf/internal/net/tcp/TcpSocketInputStream.h>
 #include <decaf/internal/net/tcp/TcpSocketOutputStream.h>
 
@@ -59,22 +60,6 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-namespace {
-
-    class SocketFileDescriptor : public FileDescriptor {
-    public:
-
-        SocketFileDescriptor( apr_socket_t* socket ) : FileDescriptor() {
-            apr_os_sock_t osSocket = -1;
-            apr_os_sock_get( &osSocket, socket );
-            this->descriptor = (int)osSocket;
-        }
-
-    };
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
 TcpSocket::TcpSocket() throw ( SocketException )
   : socketHandle( NULL ),
     localAddress( NULL ),
@@ -128,7 +113,9 @@ void TcpSocket::create() throw( decaf::i
                                         APR_PROTO_TCP, apr_pool.getAprPool() ) );
 
         // Initialize the Socket's FileDescriptor
-        this->fd = new SocketFileDescriptor( socketHandle );
+        apr_os_sock_t osSocket = -1;
+        apr_os_sock_get( &osSocket, socketHandle );
+        this->fd = new SocketFileDescriptor( osSocket );
     }
     DECAF_CATCH_RETHROW( decaf::io::IOException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )



Mime
View raw message