activemq-cpp-3.9.5
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
27
28namespace decaf {
29namespace internal {
30namespace net {
31namespace ssl {
32namespace openssl {
33
35 class SocketData;
36
43 class DECAF_API OpenSSLSocket: public decaf::net::ssl::SSLSocket {
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
66
67 OpenSSLSocket(OpenSSLParameters* parameters, const decaf::net::InetAddress* address, int port);
68
69 OpenSSLSocket(OpenSSLParameters* parameters, const decaf::net::InetAddress* address, int port, const decaf::net::InetAddress* localAddress, int localPort);
70
71 OpenSSLSocket(OpenSSLParameters* parameters, const std::string& host, int port);
72
73 OpenSSLSocket(OpenSSLParameters* parameters, const std::string& host, int port, const decaf::net::InetAddress* localAddress, int localPort);
74
75 virtual ~OpenSSLSocket();
76
77 public: // Socket Overrides.
78
82 virtual void connect(const std::string& host, int port, int timeout);
83
87 virtual void close();
88
93
98
102 virtual void shutdownInput();
103
107 virtual void shutdownOutput();
108
112 virtual void setOOBInline(bool value);
113
117 virtual void sendUrgentData(int data);
118
119 public: // SSLSocket Overrides
120
125
130
134 virtual std::vector<std::string> getSupportedCipherSuites() const;
135
139 virtual std::vector<std::string> getSupportedProtocols() const;
140
144 virtual std::vector<std::string> getEnabledCipherSuites() const;
145
149 virtual void setEnabledCipherSuites(const std::vector<std::string>& suites);
150
154 virtual std::vector<std::string> getEnabledProtocols() const;
155
159 virtual void setEnabledProtocols(const std::vector<std::string>& protocols);
160
164 virtual void startHandshake();
165
169 virtual void setUseClientMode(bool value);
170
174 virtual bool getUseClientMode() const;
175
179 virtual void setNeedClientAuth(bool value);
180
184 virtual bool getNeedClientAuth() const;
185
189 virtual void setWantClientAuth(bool value);
190
194 virtual bool getWantClientAuth() const;
195
196 public:
197
216 int read(unsigned char* buffer, int size, int offset, int length);
217
234 void write(const unsigned char* buffer, int size, int offset, int length);
235
244
245 private:
246
247 // Perform some additional checks on the Server's Certificate to ensure that
248 // its really valid.
249 void verifyServerCert(const std::string& serverName);
250
251 public:
252
254
255 };
256
257}}}}}
258
259#endif /* _DECAF_INTERNAL_NET_SSL_OPENSSL_OPENSSLSOCKET_H_ */
Container class for parameters that are Common to OpenSSL socket classes.
Definition OpenSSLParameters.h:41
virtual decaf::net::ssl::SSLParameters getSSLParameters() const
Returns an SSLParameters object for this SSLSocket instance.The cipherSuites and protocols vectors in...
virtual void setOOBInline(bool value)
Sets the value of the OOBINLINE for this socket, by default this option is disabled....
virtual void connect(const std::string &host, int port, int timeout)
Connects to the specified destination, with a specified timeout value.If a connection to the remote h...
virtual void setEnabledProtocols(const std::vector< std::string > &protocols)
Sets the Protocols that are to be enabled on the SSL Socket connection.Each of the named Protocols mu...
void write(const unsigned char *buffer, int size, int offset, int length)
Writes the specified data in the passed in buffer to the Socket.
virtual void setWantClientAuth(bool value)
Sets the Socket to request that a client authenticate itself by sending a valid Certificate that is t...
OpenSSLSocket(OpenSSLParameters *parameters)
virtual void close()
Closes the Socket.Once closed a Socket cannot be connected or otherwise operated upon,...
int available()
Gets the number of bytes in the Socket buffer that can be read without blocking.
virtual decaf::io::InputStream * getInputStream()
Gets the InputStream for this socket if its connected.The pointer returned is the property of the ass...
virtual void sendUrgentData(int data)
Sends on byte of urgent data to the Socket.
int read(unsigned char *buffer, int size, int offset, int length)
Reads the requested data from the Socket and write it into the passed in buffer.
virtual decaf::io::OutputStream * getOutputStream()
Gets the OutputStream for this socket if it is connected.The pointer returned is the property of the ...
virtual void setEnabledCipherSuites(const std::vector< std::string > &suites)
Sets the Cipher Suites that are to be enabled on the SSL Socket connection.Each of the named Cipher S...
virtual void setNeedClientAuth(bool value)
Sets the Socket to require that a client authenticate itself by sending a valid Certificate that is t...
virtual bool getUseClientMode() const
Gets whether this Socket is in Client or Server mode, true indicates that the mode is set to Client....
virtual void shutdownInput()
Shuts down the InputStream for this socket essentially marking it as EOF.The stream returns EOF for a...
virtual void setUseClientMode(bool value)
Determines the mode that the socket uses when a handshake is initiated, client or server....
virtual void shutdownOutput()
Shuts down the OutputStream for this socket, any data already written to the socket will be sent,...
virtual std::vector< std::string > getSupportedCipherSuites() const
Gets a vector containing the names of all the cipher suites that are supported by this SSLSocket....
virtual bool getNeedClientAuth() const
Returns if this socket is configured to require client authentication, true means that is has and tha...
virtual void setSSLParameters(const decaf::net::ssl::SSLParameters &value)
Sets the SSLParameters for this SSLSocket using the supplied SSLParameters instance....
virtual bool getWantClientAuth() const
Returns if this socket is configured to request client authentication, true means that is has and tha...
virtual std::vector< std::string > getEnabledCipherSuites() const
Returns a vector containing the names of all the currently enabled Cipher Suites for this SSL Socket....
OpenSSLSocket(OpenSSLParameters *parameters, const std::string &host, int port, const decaf::net::InetAddress *localAddress, int localPort)
virtual void startHandshake()
Initiates a handshake for this SSL Connection, this can be necessary for several reasons such as usin...
OpenSSLSocket(OpenSSLParameters *parameters, const decaf::net::InetAddress *address, int port)
OpenSSLSocket(OpenSSLParameters *parameters, const std::string &host, int port)
virtual std::vector< std::string > getEnabledProtocols() const
Returns a vector containing the names of all the currently enabled Protocols for this SSL Socket....
virtual std::vector< std::string > getSupportedProtocols() const
Gets a vector containing the names of all the protocols that could be enabled for this SSLSocket inst...
OpenSSLSocket(OpenSSLParameters *parameters, const decaf::net::InetAddress *address, int port, const decaf::net::InetAddress *localAddress, int localPort)
A base class that must be implemented by all classes wishing to provide a class that reads in a strea...
Definition InputStream.h:39
Base interface for any class that wants to represent an output stream of bytes.
Definition OutputStream.h:39
Represents an IP address.
Definition InetAddress.h:33
virtual void connect(const std::string &host, int port)
Connects to the specified destination.
Definition SSLParameters.h:30
Definition SSLSocket.h:34
#define DECAF_API
Definition Config.h:29
Definition OpenSSLContextSpi.h:29
Definition DefaultSSLContext.h:28
Definition DefaultServerSocketFactory.h:27
Definition AprPool.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25