Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: remoting/host/client_session.cc

Issue 138753005: Add gnubby authentication to remoting host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "remoting/host/client_session.h" 5 #include "remoting/host/client_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "remoting/base/capabilities.h" 10 #include "remoting/base/capabilities.h"
11 #include "remoting/base/logging.h" 11 #include "remoting/base/logging.h"
12 #include "remoting/codec/audio_encoder.h" 12 #include "remoting/codec/audio_encoder.h"
13 #include "remoting/codec/audio_encoder_opus.h" 13 #include "remoting/codec/audio_encoder_opus.h"
14 #include "remoting/codec/audio_encoder_verbatim.h" 14 #include "remoting/codec/audio_encoder_verbatim.h"
15 #include "remoting/codec/video_encoder.h" 15 #include "remoting/codec/video_encoder.h"
16 #include "remoting/codec/video_encoder_verbatim.h" 16 #include "remoting/codec/video_encoder_verbatim.h"
17 #include "remoting/codec/video_encoder_vpx.h" 17 #include "remoting/codec/video_encoder_vpx.h"
18 #include "remoting/host/audio_capturer.h" 18 #include "remoting/host/audio_capturer.h"
19 #include "remoting/host/audio_scheduler.h" 19 #include "remoting/host/audio_scheduler.h"
20 #include "remoting/host/desktop_environment.h" 20 #include "remoting/host/desktop_environment.h"
21 #include "remoting/host/gnubby_connection_factory.h"
21 #include "remoting/host/input_injector.h" 22 #include "remoting/host/input_injector.h"
22 #include "remoting/host/screen_controls.h" 23 #include "remoting/host/screen_controls.h"
23 #include "remoting/host/screen_resolution.h" 24 #include "remoting/host/screen_resolution.h"
24 #include "remoting/host/video_scheduler.h" 25 #include "remoting/host/video_scheduler.h"
25 #include "remoting/proto/control.pb.h" 26 #include "remoting/proto/control.pb.h"
26 #include "remoting/proto/event.pb.h" 27 #include "remoting/proto/event.pb.h"
27 #include "remoting/protocol/client_stub.h" 28 #include "remoting/protocol/client_stub.h"
28 #include "remoting/protocol/clipboard_thread_proxy.h" 29 #include "remoting/protocol/clipboard_thread_proxy.h"
29 #include "remoting/protocol/pairing_registry.h" 30 #include "remoting/protocol/pairing_registry.h"
30 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" 31 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
31 32
32 // Default DPI to assume for old clients that use notifyClientDimensions. 33 // Default DPI to assume for old clients that use notifyClientDimensions.
33 const int kDefaultDPI = 96; 34 const int kDefaultDPI = 96;
34 35
35 namespace remoting { 36 namespace remoting {
36 37
37 ClientSession::ClientSession( 38 ClientSession::ClientSession(
38 EventHandler* event_handler, 39 EventHandler* event_handler,
39 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, 40 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
40 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 41 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
41 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, 42 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
42 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, 43 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 44 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
44 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 45 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
45 scoped_ptr<protocol::ConnectionToClient> connection, 46 scoped_ptr<protocol::ConnectionToClient> connection,
46 DesktopEnvironmentFactory* desktop_environment_factory, 47 DesktopEnvironmentFactory* desktop_environment_factory,
47 const base::TimeDelta& max_duration, 48 const base::TimeDelta& max_duration,
48 scoped_refptr<protocol::PairingRegistry> pairing_registry) 49 scoped_refptr<protocol::PairingRegistry> pairing_registry,
50 bool enable_gnubby_auth)
49 : event_handler_(event_handler), 51 : event_handler_(event_handler),
50 connection_(connection.Pass()), 52 connection_(connection.Pass()),
51 client_jid_(connection_->session()->jid()), 53 client_jid_(connection_->session()->jid()),
52 control_factory_(this), 54 control_factory_(this),
53 desktop_environment_factory_(desktop_environment_factory), 55 desktop_environment_factory_(desktop_environment_factory),
54 input_tracker_(&host_input_filter_), 56 input_tracker_(&host_input_filter_),
55 remote_input_filter_(&input_tracker_), 57 remote_input_filter_(&input_tracker_),
56 mouse_clamping_filter_(&remote_input_filter_), 58 mouse_clamping_filter_(&remote_input_filter_),
57 disable_input_filter_(mouse_clamping_filter_.input_filter()), 59 disable_input_filter_(mouse_clamping_filter_.input_filter()),
58 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), 60 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
59 auth_input_filter_(&disable_input_filter_), 61 auth_input_filter_(&disable_input_filter_),
60 auth_clipboard_filter_(&disable_clipboard_filter_), 62 auth_clipboard_filter_(&disable_clipboard_filter_),
61 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), 63 client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
62 max_duration_(max_duration), 64 max_duration_(max_duration),
63 audio_task_runner_(audio_task_runner), 65 audio_task_runner_(audio_task_runner),
64 input_task_runner_(input_task_runner), 66 input_task_runner_(input_task_runner),
65 video_capture_task_runner_(video_capture_task_runner), 67 video_capture_task_runner_(video_capture_task_runner),
66 video_encode_task_runner_(video_encode_task_runner), 68 video_encode_task_runner_(video_encode_task_runner),
67 network_task_runner_(network_task_runner), 69 network_task_runner_(network_task_runner),
68 ui_task_runner_(ui_task_runner), 70 ui_task_runner_(ui_task_runner),
69 pairing_registry_(pairing_registry) { 71 pairing_registry_(pairing_registry),
72 enable_gnubby_auth_(enable_gnubby_auth) {
70 connection_->SetEventHandler(this); 73 connection_->SetEventHandler(this);
71 74
72 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be 75 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be
73 // set before channels are connected. Make it possible to set stubs 76 // set before channels are connected. Make it possible to set stubs
74 // later and set them only when connection is authenticated. 77 // later and set them only when connection is authenticated.
75 connection_->set_clipboard_stub(&auth_clipboard_filter_); 78 connection_->set_clipboard_stub(&auth_clipboard_filter_);
76 connection_->set_host_stub(this); 79 connection_->set_host_stub(this);
77 connection_->set_input_stub(&auth_input_filter_); 80 connection_->set_input_stub(&auth_input_filter_);
78 81
79 // |auth_*_filter_|'s states reflect whether the session is authenticated. 82 // |auth_*_filter_|'s states reflect whether the session is authenticated.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void ClientSession::DeliverClientMessage( 193 void ClientSession::DeliverClientMessage(
191 const protocol::ExtensionMessage& message) { 194 const protocol::ExtensionMessage& message) {
192 if (message.has_type()) { 195 if (message.has_type()) {
193 if (message.type() == "test-echo") { 196 if (message.type() == "test-echo") {
194 protocol::ExtensionMessage reply; 197 protocol::ExtensionMessage reply;
195 reply.set_type("test-echo-reply"); 198 reply.set_type("test-echo-reply");
196 if (message.has_data()) 199 if (message.has_data())
197 reply.set_data(message.data().substr(0, 16)); 200 reply.set_data(message.data().substr(0, 16));
198 connection_->client_stub()->DeliverHostMessage(reply); 201 connection_->client_stub()->DeliverHostMessage(reply);
199 return; 202 return;
203 } else if (message.type() == "gnubby-auth") {
Sergey Ulanov 2014/01/25 02:03:33 we added ExtensionMessage as a hack that allows to
psj 2014/01/29 09:07:15 Wez said that I should use the extension message.
204 if (gnubby_auth_handler_) {
205 gnubby_auth_handler_->DeliverClientMessage(message.data());
206 } else {
207 HOST_LOG << "gnubby auth is not enabled";
208 }
209 return;
200 } 210 }
201 } 211 }
202 // No messages are currently supported.
203 HOST_LOG << "Unexpected message received: " 212 HOST_LOG << "Unexpected message received: "
204 << message.type() << ": " << message.data(); 213 << message.type() << ": " << message.data();
205 } 214 }
206 215
207 void ClientSession::OnConnectionAuthenticated( 216 void ClientSession::OnConnectionAuthenticated(
208 protocol::ConnectionToClient* connection) { 217 protocol::ConnectionToClient* connection) {
209 DCHECK(CalledOnValidThread()); 218 DCHECK(CalledOnValidThread());
210 DCHECK_EQ(connection_.get(), connection); 219 DCHECK_EQ(connection_.get(), connection);
211 DCHECK(!audio_scheduler_.get()); 220 DCHECK(!audio_scheduler_.get());
212 DCHECK(!desktop_environment_); 221 DCHECK(!desktop_environment_);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (connection_->session()->config().is_audio_enabled()) { 290 if (connection_->session()->config().is_audio_enabled()) {
282 scoped_ptr<AudioEncoder> audio_encoder = 291 scoped_ptr<AudioEncoder> audio_encoder =
283 CreateAudioEncoder(connection_->session()->config()); 292 CreateAudioEncoder(connection_->session()->config());
284 audio_scheduler_ = new AudioScheduler( 293 audio_scheduler_ = new AudioScheduler(
285 audio_task_runner_, 294 audio_task_runner_,
286 network_task_runner_, 295 network_task_runner_,
287 desktop_environment_->CreateAudioCapturer(), 296 desktop_environment_->CreateAudioCapturer(),
288 audio_encoder.Pass(), 297 audio_encoder.Pass(),
289 connection_->audio_stub()); 298 connection_->audio_stub());
290 } 299 }
300
301 if (enable_gnubby_auth_) {
302 // Create a GnubbyAuthHandler to proxy gnubbyd messages.
303 gnubby_auth_handler_.reset(
304 new GnubbyAuthHandler(network_task_runner_,
305 GnubbyConnectionFactory::GetDefaultFactory(),
306 connection_->client_stub()));
307 }
291 } 308 }
292 309
293 void ClientSession::OnConnectionChannelsConnected( 310 void ClientSession::OnConnectionChannelsConnected(
294 protocol::ConnectionToClient* connection) { 311 protocol::ConnectionToClient* connection) {
295 DCHECK(CalledOnValidThread()); 312 DCHECK(CalledOnValidThread());
296 DCHECK_EQ(connection_.get(), connection); 313 DCHECK_EQ(connection_.get(), connection);
297 314
298 // Negotiate capabilities with the client. 315 // Negotiate capabilities with the client.
299 if (connection_->session()->config().SupportsCapabilities()) { 316 if (connection_->session()->config().SupportsCapabilities()) {
300 VLOG(1) << "Host capabilities: " << host_capabilities_; 317 VLOG(1) << "Host capabilities: " << host_capabilities_;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void ClientSession::SetDisableInputs(bool disable_inputs) { 422 void ClientSession::SetDisableInputs(bool disable_inputs) {
406 DCHECK(CalledOnValidThread()); 423 DCHECK(CalledOnValidThread());
407 424
408 if (disable_inputs) 425 if (disable_inputs)
409 input_tracker_.ReleaseAll(); 426 input_tracker_.ReleaseAll();
410 427
411 disable_input_filter_.set_enabled(!disable_inputs); 428 disable_input_filter_.set_enabled(!disable_inputs);
412 disable_clipboard_filter_.set_enabled(!disable_inputs); 429 disable_clipboard_filter_.set_enabled(!disable_inputs);
413 } 430 }
414 431
432 void ClientSession::SetGnubbyAuthHandlerForTesting(
433 GnubbyAuthHandler* gnubby_auth_handler) {
434 gnubby_auth_handler_.reset(gnubby_auth_handler);
435 }
436
415 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { 437 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() {
416 DCHECK(CalledOnValidThread()); 438 DCHECK(CalledOnValidThread());
417 439
418 return scoped_ptr<protocol::ClipboardStub>( 440 return scoped_ptr<protocol::ClipboardStub>(
419 new protocol::ClipboardThreadProxy( 441 new protocol::ClipboardThreadProxy(
420 client_clipboard_factory_.GetWeakPtr(), 442 client_clipboard_factory_.GetWeakPtr(),
421 base::MessageLoopProxy::current())); 443 base::MessageLoopProxy::current()));
422 } 444 }
423 445
424 // TODO(sergeyu): Move this to SessionManager? 446 // TODO(sergeyu): Move this to SessionManager?
(...skipping 19 matching lines...) Expand all
444 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); 466 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim());
445 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { 467 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
446 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); 468 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus());
447 } 469 }
448 470
449 NOTREACHED(); 471 NOTREACHED();
450 return scoped_ptr<AudioEncoder>(); 472 return scoped_ptr<AudioEncoder>();
451 } 473 }
452 474
453 } // namespace remoting 475 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698