| OLD | NEW |
| 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 // This file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
| 6 | 6 |
| 7 #include "remoting/host/remoting_me2me_host.h" | 7 #include "remoting/host/remoting_me2me_host.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 base::FilePath host_config_path_; | 284 base::FilePath host_config_path_; |
| 285 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; | 285 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; |
| 286 | 286 |
| 287 // Accessed on the network thread. | 287 // Accessed on the network thread. |
| 288 HostState state_; | 288 HostState state_; |
| 289 | 289 |
| 290 scoped_ptr<ConfigFileWatcher> config_watcher_; | 290 scoped_ptr<ConfigFileWatcher> config_watcher_; |
| 291 | 291 |
| 292 std::string host_id_; | 292 std::string host_id_; |
| 293 protocol::SharedSecretHash host_secret_hash_; | 293 protocol::SharedSecretHash host_secret_hash_; |
| 294 HostKeyPair key_pair_; | 294 protocol::KeyPair key_pair_; |
| 295 std::string oauth_refresh_token_; | 295 std::string oauth_refresh_token_; |
| 296 std::string serialized_config_; | 296 std::string serialized_config_; |
| 297 std::string xmpp_login_; | 297 std::string xmpp_login_; |
| 298 std::string xmpp_auth_token_; | 298 std::string xmpp_auth_token_; |
| 299 std::string xmpp_auth_service_; | 299 std::string xmpp_auth_service_; |
| 300 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 300 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
| 301 bool allow_nat_traversal_; | 301 bool allow_nat_traversal_; |
| 302 std::string talkgadget_prefix_; | 302 std::string talkgadget_prefix_; |
| 303 | 303 |
| 304 scoped_ptr<CurtainMode> curtain_; | 304 scoped_ptr<CurtainMode> curtain_; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 516 |
| 517 std::string local_certificate = key_pair_.GenerateCertificate(); | 517 std::string local_certificate = key_pair_.GenerateCertificate(); |
| 518 if (local_certificate.empty()) { | 518 if (local_certificate.empty()) { |
| 519 LOG(ERROR) << "Failed to generate host certificate."; | 519 LOG(ERROR) << "Failed to generate host certificate."; |
| 520 ShutdownHost(kInitializationFailed); | 520 ShutdownHost(kInitializationFailed); |
| 521 return; | 521 return; |
| 522 } | 522 } |
| 523 | 523 |
| 524 scoped_ptr<protocol::AuthenticatorFactory> factory( | 524 scoped_ptr<protocol::AuthenticatorFactory> factory( |
| 525 new protocol::Me2MeHostAuthenticatorFactory( | 525 new protocol::Me2MeHostAuthenticatorFactory( |
| 526 local_certificate, *key_pair_.private_key(), host_secret_hash_)); | 526 local_certificate, key_pair_.Copy(), host_secret_hash_)); |
| 527 #if defined(OS_POSIX) | 527 #if defined(OS_POSIX) |
| 528 // On Linux and Mac, perform a PAM authorization step after authentication. | 528 // On Linux and Mac, perform a PAM authorization step after authentication. |
| 529 factory.reset(new PamAuthorizationFactory(factory.Pass())); | 529 factory.reset(new PamAuthorizationFactory(factory.Pass())); |
| 530 #endif | 530 #endif |
| 531 host_->SetAuthenticatorFactory(factory.Pass()); | 531 host_->SetAuthenticatorFactory(factory.Pass()); |
| 532 } | 532 } |
| 533 | 533 |
| 534 // IPC::Listener implementation. | 534 // IPC::Listener implementation. |
| 535 bool HostProcess::OnMessageReceived(const IPC::Message& message) { | 535 bool HostProcess::OnMessageReceived(const IPC::Message& message) { |
| 536 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 536 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 | 678 |
| 679 // Applies the host config, returning true if successful. | 679 // Applies the host config, returning true if successful. |
| 680 bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) { | 680 bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) { |
| 681 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 681 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 682 | 682 |
| 683 if (!config->GetString(kHostIdConfigPath, &host_id_)) { | 683 if (!config->GetString(kHostIdConfigPath, &host_id_)) { |
| 684 LOG(ERROR) << "host_id is not defined in the config."; | 684 LOG(ERROR) << "host_id is not defined in the config."; |
| 685 return false; | 685 return false; |
| 686 } | 686 } |
| 687 | 687 |
| 688 if (!key_pair_.Load(*config)) { | 688 std::string key_base64; |
| 689 if (!config->GetString(kPrivateKeyConfigPath, &key_base64)) { |
| 690 LOG(ERROR) << "Private key wasn't found in the config file."; |
| 689 return false; | 691 return false; |
| 690 } | 692 } |
| 691 | 693 |
| 694 if (!key_pair_.LoadFromString(key_base64)) { |
| 695 return false; |
| 696 } |
| 697 |
| 692 std::string host_secret_hash_string; | 698 std::string host_secret_hash_string; |
| 693 if (!config->GetString(kHostSecretHashConfigPath, | 699 if (!config->GetString(kHostSecretHashConfigPath, |
| 694 &host_secret_hash_string)) { | 700 &host_secret_hash_string)) { |
| 695 host_secret_hash_string = "plain:"; | 701 host_secret_hash_string = "plain:"; |
| 696 } | 702 } |
| 697 | 703 |
| 698 if (!host_secret_hash_.Parse(host_secret_hash_string)) { | 704 if (!host_secret_hash_.Parse(host_secret_hash_string)) { |
| 699 LOG(ERROR) << "Invalid host_secret_hash."; | 705 LOG(ERROR) << "Invalid host_secret_hash."; |
| 700 return false; | 706 return false; |
| 701 } | 707 } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 return exit_code; | 1157 return exit_code; |
| 1152 } | 1158 } |
| 1153 | 1159 |
| 1154 } // namespace remoting | 1160 } // namespace remoting |
| 1155 | 1161 |
| 1156 #if !defined(OS_WIN) | 1162 #if !defined(OS_WIN) |
| 1157 int main(int argc, char** argv) { | 1163 int main(int argc, char** argv) { |
| 1158 return remoting::HostProcessMain(argc, argv); | 1164 return remoting::HostProcessMain(argc, argv); |
| 1159 } | 1165 } |
| 1160 #endif // !defined(OS_WIN) | 1166 #endif // !defined(OS_WIN) |
| OLD | NEW |