| 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 #include "remoting/host/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "remoting/host/host_key_pair.h" | 21 #include "remoting/host/host_key_pair.h" |
| 22 #include "remoting/host/screen_recorder.h" | 22 #include "remoting/host/screen_recorder.h" |
| 23 #include "remoting/host/user_authenticator.h" | 23 #include "remoting/host/user_authenticator.h" |
| 24 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 24 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 25 #include "remoting/protocol/connection_to_client.h" | 25 #include "remoting/protocol/connection_to_client.h" |
| 26 #include "remoting/protocol/client_stub.h" | 26 #include "remoting/protocol/client_stub.h" |
| 27 #include "remoting/protocol/host_stub.h" | 27 #include "remoting/protocol/host_stub.h" |
| 28 #include "remoting/protocol/input_stub.h" | 28 #include "remoting/protocol/input_stub.h" |
| 29 #include "remoting/protocol/jingle_session_manager.h" | 29 #include "remoting/protocol/jingle_session_manager.h" |
| 30 #include "remoting/protocol/session_config.h" | 30 #include "remoting/protocol/session_config.h" |
| 31 #include "remoting/protocol/simple_host_authenticator.h" |
| 31 | 32 |
| 32 using remoting::protocol::ConnectionToClient; | 33 using remoting::protocol::ConnectionToClient; |
| 33 using remoting::protocol::InputStub; | 34 using remoting::protocol::InputStub; |
| 34 | 35 |
| 35 namespace remoting { | 36 namespace remoting { |
| 36 | 37 |
| 37 // static | 38 // static |
| 38 ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context, | 39 ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context, |
| 39 MutableHostConfig* config, | 40 MutableHostConfig* config, |
| 40 DesktopEnvironment* environment, | 41 DesktopEnvironment* environment, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 (*it)->OnClientAuthenticated(jid); | 202 (*it)->OnClientAuthenticated(jid); |
| 202 } | 203 } |
| 203 // TODO(jamiewalch): Tidy up actions to be taken on connect/disconnect, | 204 // TODO(jamiewalch): Tidy up actions to be taken on connect/disconnect, |
| 204 // including closing the connection on failure of a critical operation. | 205 // including closing the connection on failure of a critical operation. |
| 205 EnableCurtainMode(true); | 206 EnableCurtainMode(true); |
| 206 | 207 |
| 207 std::string username = jid.substr(0, jid.find('/')); | 208 std::string username = jid.substr(0, jid.find('/')); |
| 208 desktop_environment_->OnConnect(username); | 209 desktop_environment_->OnConnect(username); |
| 209 } | 210 } |
| 210 | 211 |
| 212 void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) { |
| 213 // Notify observers. |
| 214 for (StatusObserverList::iterator it = status_observers_.begin(); |
| 215 it != status_observers_.end(); ++it) { |
| 216 (*it)->OnAccessDenied(); |
| 217 } |
| 218 } |
| 219 |
| 211 void ChromotingHost::OnSessionClosed(ClientSession* client) { | 220 void ChromotingHost::OnSessionClosed(ClientSession* client) { |
| 212 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 221 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 213 | 222 |
| 214 scoped_ptr<ClientSession> client_destroyer(client); | 223 scoped_ptr<ClientSession> client_destroyer(client); |
| 215 | 224 |
| 216 ClientList::iterator it = std::find(clients_.begin(), clients_.end(), client); | 225 ClientList::iterator it = std::find(clients_.begin(), clients_.end(), client); |
| 217 CHECK(it != clients_.end()); | 226 CHECK(it != clients_.end()); |
| 218 clients_.erase(it); | 227 clients_.erase(it); |
| 219 | 228 |
| 220 if (recorder_.get()) { | 229 if (recorder_.get()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 protocol::Session* session, | 308 protocol::Session* session, |
| 300 protocol::SessionManager::IncomingSessionResponse* response) { | 309 protocol::SessionManager::IncomingSessionResponse* response) { |
| 301 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 310 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 302 | 311 |
| 303 if (state_ != kStarted) { | 312 if (state_ != kStarted) { |
| 304 *response = protocol::SessionManager::DECLINE; | 313 *response = protocol::SessionManager::DECLINE; |
| 305 return; | 314 return; |
| 306 } | 315 } |
| 307 | 316 |
| 308 // Check that the client has access to the host. | 317 // Check that the client has access to the host. |
| 309 if (!access_verifier_->VerifyPermissions(session->jid(), | 318 if (!access_verifier_->VerifyPermissions(session->jid())) { |
| 310 session->initiator_token())) { | |
| 311 *response = protocol::SessionManager::DECLINE; | 319 *response = protocol::SessionManager::DECLINE; |
| 312 | 320 |
| 313 // Notify observers. | 321 // Notify observers. |
| 314 for (StatusObserverList::iterator it = status_observers_.begin(); | 322 for (StatusObserverList::iterator it = status_observers_.begin(); |
| 315 it != status_observers_.end(); ++it) { | 323 it != status_observers_.end(); ++it) { |
| 316 (*it)->OnAccessDenied(); | 324 (*it)->OnAccessDenied(); |
| 317 } | 325 } |
| 318 return; | 326 return; |
| 319 } | 327 } |
| 320 | 328 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 336 protocol::SessionConfig config; | 344 protocol::SessionConfig config; |
| 337 if (!protocol_config_->Select(session->candidate_config(), | 345 if (!protocol_config_->Select(session->candidate_config(), |
| 338 true /* force_host_resolution */, &config)) { | 346 true /* force_host_resolution */, &config)) { |
| 339 LOG(WARNING) << "Rejecting connection from " << session->jid() | 347 LOG(WARNING) << "Rejecting connection from " << session->jid() |
| 340 << " because no compatible configuration has been found."; | 348 << " because no compatible configuration has been found."; |
| 341 *response = protocol::SessionManager::INCOMPATIBLE; | 349 *response = protocol::SessionManager::INCOMPATIBLE; |
| 342 return; | 350 return; |
| 343 } | 351 } |
| 344 | 352 |
| 345 session->set_config(config); | 353 session->set_config(config); |
| 346 session->set_receiver_token( | |
| 347 GenerateHostAuthToken(session->initiator_token())); | |
| 348 | |
| 349 // Provide the Access Code as shared secret for SSL channel authentication. | 354 // Provide the Access Code as shared secret for SSL channel authentication. |
| 350 session->set_shared_secret(access_code_); | 355 session->set_shared_secret(access_code_); |
| 351 | 356 |
| 352 *response = protocol::SessionManager::ACCEPT; | 357 *response = protocol::SessionManager::ACCEPT; |
| 353 | 358 |
| 354 LOG(INFO) << "Client connected: " << session->jid(); | 359 LOG(INFO) << "Client connected: " << session->jid(); |
| 355 | 360 |
| 356 // Create a client object. | 361 // Create a client object. |
| 357 protocol::ConnectionToClient* connection = | 362 protocol::ConnectionToClient* connection = |
| 358 new protocol::ConnectionToClient(session); | 363 new protocol::ConnectionToClient(session); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 return EncoderRowBased::CreateVerbatimEncoder(); | 416 return EncoderRowBased::CreateVerbatimEncoder(); |
| 412 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { | 417 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { |
| 413 return EncoderRowBased::CreateZlibEncoder(); | 418 return EncoderRowBased::CreateZlibEncoder(); |
| 414 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | 419 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
| 415 return new remoting::EncoderVp8(); | 420 return new remoting::EncoderVp8(); |
| 416 } | 421 } |
| 417 | 422 |
| 418 return NULL; | 423 return NULL; |
| 419 } | 424 } |
| 420 | 425 |
| 421 std::string ChromotingHost::GenerateHostAuthToken( | |
| 422 const std::string& encoded_client_token) { | |
| 423 // TODO(ajwong): Return the signature of this instead. | |
| 424 return encoded_client_token; | |
| 425 } | |
| 426 | |
| 427 int ChromotingHost::AuthenticatedClientsCount() const { | 426 int ChromotingHost::AuthenticatedClientsCount() const { |
| 428 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 427 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 429 | 428 |
| 430 int authenticated_clients = 0; | 429 int authenticated_clients = 0; |
| 431 for (ClientList::const_iterator it = clients_.begin(); it != clients_.end(); | 430 for (ClientList::const_iterator it = clients_.begin(); it != clients_.end(); |
| 432 ++it) { | 431 ++it) { |
| 433 if ((*it)->authenticated()) | 432 if ((*it)->authenticated()) |
| 434 ++authenticated_clients; | 433 ++authenticated_clients; |
| 435 } | 434 } |
| 436 return authenticated_clients; | 435 return authenticated_clients; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 485 } |
| 487 | 486 |
| 488 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 487 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 489 it != shutdown_tasks_.end(); ++it) { | 488 it != shutdown_tasks_.end(); ++it) { |
| 490 it->Run(); | 489 it->Run(); |
| 491 } | 490 } |
| 492 shutdown_tasks_.clear(); | 491 shutdown_tasks_.clear(); |
| 493 } | 492 } |
| 494 | 493 |
| 495 } // namespace remoting | 494 } // namespace remoting |
| OLD | NEW |