activemq-cpp-3.4.0

src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_
00019 #define _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_
00020 
00021 #include <decaf/util/Config.h>
00022 
00023 #include <decaf/net/ssl/SSLSocket.h>
00024 
00025 #include <decaf/io/InputStream.h>
00026 #include <decaf/io/OutputStream.h>
00027 
00028 namespace decaf {
00029 namespace internal {
00030 namespace net {
00031 namespace ssl {
00032 namespace openssl {
00033 
00034     class OpenSSLParameters;
00035     class SocketData;
00036 
00043     class DECAF_API OpenSSLSocket : public decaf::net::ssl::SSLSocket {
00044     private:
00045 
00046         // Private data related to the OpenSSL Socket impl.
00047         SocketData* data;
00048 
00049         // Parameters object containing the OpenSSL settings and objects for this Socket.
00050         OpenSSLParameters* parameters;
00051 
00052         // The InputStream owned by this Socket
00053         decaf::io::InputStream* input;
00054 
00055         // The OutputStream owned by this Socket
00056         decaf::io::OutputStream* output;
00057 
00058     private:
00059 
00060         OpenSSLSocket( const OpenSSLSocket& );
00061         OpenSSLSocket& operator= ( const OpenSSLSocket& );
00062 
00063     public:
00064 
00065         OpenSSLSocket( OpenSSLParameters* parameters );
00066 
00067         OpenSSLSocket( OpenSSLParameters* parameters, const decaf::net::InetAddress* address, int port );
00068 
00069         OpenSSLSocket( OpenSSLParameters* parameters, const decaf::net::InetAddress* address, int port,
00070                        const decaf::net::InetAddress* localAddress, int localPort );
00071 
00072         OpenSSLSocket( OpenSSLParameters* parameters, const std::string& host, int port );
00073 
00074         OpenSSLSocket( OpenSSLParameters* parameters, const std::string& host, int port,
00075                        const decaf::net::InetAddress* localAddress, int localPort );
00076 
00077         virtual ~OpenSSLSocket();
00078 
00079     public:  // Socket Overrides.
00080 
00084         virtual void connect( const std::string& host, int port, int timeout );
00085 
00089         virtual void close();
00090 
00094         virtual decaf::io::InputStream* getInputStream();
00095 
00099         virtual decaf::io::OutputStream* getOutputStream();
00100 
00104         virtual void shutdownInput();
00105 
00109         virtual void shutdownOutput();
00110 
00114         virtual void setOOBInline( bool value );
00115 
00119         virtual void sendUrgentData( int data );
00120 
00121     public:  // SSLSocket Overrides
00122 
00126         virtual std::vector<std::string> getSupportedCipherSuites() const;
00127 
00131         virtual std::vector<std::string> getSupportedProtocols() const;
00132 
00136         virtual std::vector<std::string> getEnabledCipherSuites() const;
00137 
00141         virtual void setEnabledCipherSuites( const std::vector<std::string>& suites );
00142 
00146         virtual std::vector<std::string> getEnabledProtocols() const;
00147 
00151         virtual void setEnabledProtocols( const std::vector<std::string>& protocols );
00152 
00156         virtual void startHandshake();
00157 
00161         virtual void setUseClientMode( bool value );
00162 
00166         virtual bool getUseClientMode() const;
00167 
00171         virtual void setNeedClientAuth( bool value );
00172 
00176         virtual bool getNeedClientAuth() const;
00177 
00181         virtual void setWantClientAuth( bool value );
00182 
00186         virtual bool getWantClientAuth() const;
00187 
00188     public:
00189 
00208         int read( unsigned char* buffer, int size, int offset, int length );
00209 
00226         void write( const unsigned char* buffer, int size, int offset, int length );
00227 
00235         int available();
00236 
00237     private:
00238 
00239         // Perform some additional checks on the Server's Certificate to ensure that
00240         // its really valid.
00241         void verifyServerCert( const std::string& serverName );
00242 
00243     };
00244 
00245 }}}}}
00246 
00247 #endif /* _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_ */