activemq-cpp-3.6.0
OpenSSLSocket.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_
19 #define _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_
20 
21 #include <decaf/util/Config.h>
22 
24 
25 #include <decaf/io/InputStream.h>
26 #include <decaf/io/OutputStream.h>
27 
28 namespace decaf {
29 namespace internal {
30 namespace net {
31 namespace ssl {
32 namespace openssl {
33 
34  class OpenSSLParameters;
35  class SocketData;
36 
44  private:
45 
46  // Private data related to the OpenSSL Socket impl.
47  SocketData* data;
48 
49  // Parameters object containing the OpenSSL settings and objects for this Socket.
50  OpenSSLParameters* parameters;
51 
52  // The InputStream owned by this Socket
54 
55  // The OutputStream owned by this Socket
57 
58  private:
59 
60  OpenSSLSocket( const OpenSSLSocket& );
61  OpenSSLSocket& operator= ( const OpenSSLSocket& );
62 
63  public:
64 
65  OpenSSLSocket( OpenSSLParameters* parameters );
66 
67  OpenSSLSocket( OpenSSLParameters* parameters, const decaf::net::InetAddress* address, int port );
68 
69  OpenSSLSocket( OpenSSLParameters* parameters, const decaf::net::InetAddress* address, int port,
70  const decaf::net::InetAddress* localAddress, int localPort );
71 
72  OpenSSLSocket( OpenSSLParameters* parameters, const std::string& host, int port );
73 
74  OpenSSLSocket( OpenSSLParameters* parameters, const std::string& host, int port,
75  const decaf::net::InetAddress* localAddress, int localPort );
76 
77  virtual ~OpenSSLSocket();
78 
79  public: // Socket Overrides.
80 
84  virtual void connect( const std::string& host, int port, int timeout );
85 
89  virtual void close();
90 
94  virtual decaf::io::InputStream* getInputStream();
95 
99  virtual decaf::io::OutputStream* getOutputStream();
100 
104  virtual void shutdownInput();
105 
109  virtual void shutdownOutput();
110 
114  virtual void setOOBInline( bool value );
115 
119  virtual void sendUrgentData( int data );
120 
121  public: // SSLSocket Overrides
122 
126  virtual std::vector<std::string> getSupportedCipherSuites() const;
127 
131  virtual std::vector<std::string> getSupportedProtocols() const;
132 
136  virtual std::vector<std::string> getEnabledCipherSuites() const;
137 
141  virtual void setEnabledCipherSuites( const std::vector<std::string>& suites );
142 
146  virtual std::vector<std::string> getEnabledProtocols() const;
147 
151  virtual void setEnabledProtocols( const std::vector<std::string>& protocols );
152 
156  virtual void startHandshake();
157 
161  virtual void setUseClientMode( bool value );
162 
166  virtual bool getUseClientMode() const;
167 
171  virtual void setNeedClientAuth( bool value );
172 
176  virtual bool getNeedClientAuth() const;
177 
181  virtual void setWantClientAuth( bool value );
182 
186  virtual bool getWantClientAuth() const;
187 
188  public:
189 
208  int read( unsigned char* buffer, int size, int offset, int length );
209 
226  void write( const unsigned char* buffer, int size, int offset, int length );
227 
235  int available();
236 
237  private:
238 
239  // Perform some additional checks on the Server's Certificate to ensure that
240  // its really valid.
241  void verifyServerCert( const std::string& serverName );
242 
243  };
244 
245 }}}}}
246 
247 #endif /* _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_ */