OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_PROTOCOL_JINGLE_STREAM_CONNECTOR_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_STREAM_CONNECTOR_H_ |
6 #define REMOTING_PROTOCOL_JINGLE_STREAM_CONNECTOR_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_STREAM_CONNECTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // initiator authenticates the channel to the recipient by sending a digest | 34 // initiator authenticates the channel to the recipient by sending a digest |
35 // based on a secret shared by the two parties, and keying material derived | 35 // based on a secret shared by the two parties, and keying material derived |
36 // from the SSL session's master secret and nonces. | 36 // from the SSL session's master secret and nonces. |
37 class JingleStreamConnector : public JingleChannelConnector { | 37 class JingleStreamConnector : public JingleChannelConnector { |
38 public: | 38 public: |
39 JingleStreamConnector(JingleSession* session, | 39 JingleStreamConnector(JingleSession* session, |
40 const std::string& name, | 40 const std::string& name, |
41 const Session::StreamChannelCallback& callback); | 41 const Session::StreamChannelCallback& callback); |
42 virtual ~JingleStreamConnector(); | 42 virtual ~JingleStreamConnector(); |
43 | 43 |
44 // Starts connection process for the channel. |local_private_key| is | 44 // JingleChannelConnector implementation. |
45 // owned by the caller, and must exist until this object is | 45 virtual void Connect(ChannelAuthenticator* authenticator, |
46 // destroyed. | |
47 virtual void Connect(bool initiator, | |
48 const std::string& local_cert, | |
49 const std::string& remote_cert, | |
50 crypto::RSAPrivateKey* local_private_key, | |
51 cricket::TransportChannel* raw_channel) OVERRIDE; | 46 cricket::TransportChannel* raw_channel) OVERRIDE; |
52 | 47 |
53 private: | 48 private: |
54 bool EstablishTCPConnection(net::Socket* socket); | 49 bool EstablishTCPConnection(net::Socket* socket); |
55 void OnTCPConnect(int result); | 50 void OnTCPConnect(int result); |
56 | 51 void OnAuthenticationDone(net::Error error, net::StreamSocket* socket); |
57 bool EstablishSSLConnection(); | |
58 void OnSSLConnect(int result); | |
59 | |
60 void AuthenticateChannel(); | |
61 void OnAuthenticationDone(ChannelAuthenticator::Result result); | |
62 | 52 |
63 void NotifyDone(net::StreamSocket* socket); | 53 void NotifyDone(net::StreamSocket* socket); |
64 void NotifyError(); | 54 void NotifyError(); |
65 | 55 |
66 JingleSession* session_; | 56 JingleSession* session_; |
67 std::string name_; | 57 std::string name_; |
68 Session::StreamChannelCallback callback_; | 58 Session::StreamChannelCallback callback_; |
69 | 59 |
70 bool initiator_; | |
71 std::string local_cert_; | |
72 std::string remote_cert_; | |
73 crypto::RSAPrivateKey* local_private_key_; | |
74 | |
75 cricket::TransportChannel* raw_channel_; | 60 cricket::TransportChannel* raw_channel_; |
76 scoped_ptr<net::StreamSocket> tcp_socket_; | 61 scoped_ptr<net::StreamSocket> tcp_socket_; |
77 scoped_ptr<net::SSLSocket> socket_; | 62 scoped_ptr<net::SSLSocket> socket_; |
78 | 63 |
79 // Used to verify the certificate received in SSLClientSocket. | |
80 scoped_ptr<net::CertVerifier> cert_verifier_; | |
81 | |
82 scoped_ptr<ChannelAuthenticator> authenticator_; | 64 scoped_ptr<ChannelAuthenticator> authenticator_; |
83 | 65 |
84 // Callback called by the TCP and SSL layers. | 66 // Callback called by the TCP and SSL layers. |
85 net::OldCompletionCallbackImpl<JingleStreamConnector> tcp_connect_callback_; | 67 net::OldCompletionCallbackImpl<JingleStreamConnector> tcp_connect_callback_; |
86 net::OldCompletionCallbackImpl<JingleStreamConnector> ssl_connect_callback_; | |
87 | 68 |
88 DISALLOW_COPY_AND_ASSIGN(JingleStreamConnector); | 69 DISALLOW_COPY_AND_ASSIGN(JingleStreamConnector); |
89 }; | 70 }; |
90 | 71 |
91 } // namespace protocol | 72 } // namespace protocol |
92 } // namespace remoting | 73 } // namespace remoting |
93 | 74 |
94 #endif // REMOTING_PROTOCOL_JINGLE_STREAM_CONNECTOR_H_ | 75 #endif // REMOTING_PROTOCOL_JINGLE_STREAM_CONNECTOR_H_ |
OLD | NEW |