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

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

Issue 12316083: Move HostKeyPair into protocol::KeyPair. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 base::FilePath host_config_path_; 278 base::FilePath host_config_path_;
279 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; 279 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
280 280
281 // Accessed on the network thread. 281 // Accessed on the network thread.
282 HostState state_; 282 HostState state_;
283 283
284 scoped_ptr<ConfigFileWatcher> config_watcher_; 284 scoped_ptr<ConfigFileWatcher> config_watcher_;
285 285
286 std::string host_id_; 286 std::string host_id_;
287 protocol::SharedSecretHash host_secret_hash_; 287 protocol::SharedSecretHash host_secret_hash_;
288 HostKeyPair key_pair_; 288 scoped_refptr<RsaKeyPair> key_pair_;
289 std::string oauth_refresh_token_; 289 std::string oauth_refresh_token_;
290 std::string serialized_config_; 290 std::string serialized_config_;
291 std::string xmpp_login_; 291 std::string xmpp_login_;
292 std::string xmpp_auth_token_; 292 std::string xmpp_auth_token_;
293 std::string xmpp_auth_service_; 293 std::string xmpp_auth_service_;
294 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 294 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
295 bool allow_nat_traversal_; 295 bool allow_nat_traversal_;
296 std::string talkgadget_prefix_; 296 std::string talkgadget_prefix_;
297 297
298 scoped_ptr<CurtainMode> curtain_; 298 scoped_ptr<CurtainMode> curtain_;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 ShutdownHost(kSuccessExitCode); 504 ShutdownHost(kSuccessExitCode);
505 } 505 }
506 #endif // OS_POSIX 506 #endif // OS_POSIX
507 507
508 void HostProcess::CreateAuthenticatorFactory() { 508 void HostProcess::CreateAuthenticatorFactory() {
509 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 509 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
510 510
511 if (state_ != HOST_STARTED) 511 if (state_ != HOST_STARTED)
512 return; 512 return;
513 513
514 std::string local_certificate = key_pair_.GenerateCertificate(); 514 std::string local_certificate = key_pair_->GenerateCertificate();
515 if (local_certificate.empty()) { 515 if (local_certificate.empty()) {
516 LOG(ERROR) << "Failed to generate host certificate."; 516 LOG(ERROR) << "Failed to generate host certificate.";
517 ShutdownHost(kInitializationFailed); 517 ShutdownHost(kInitializationFailed);
518 return; 518 return;
519 } 519 }
520 520
521 scoped_ptr<protocol::AuthenticatorFactory> factory( 521 scoped_ptr<protocol::AuthenticatorFactory> factory(
522 new protocol::Me2MeHostAuthenticatorFactory( 522 new protocol::Me2MeHostAuthenticatorFactory(
523 local_certificate, *key_pair_.private_key(), host_secret_hash_)); 523 local_certificate, key_pair_, host_secret_hash_));
524 #if defined(OS_POSIX) 524 #if defined(OS_POSIX)
525 // On Linux and Mac, perform a PAM authorization step after authentication. 525 // On Linux and Mac, perform a PAM authorization step after authentication.
526 factory.reset(new PamAuthorizationFactory(factory.Pass())); 526 factory.reset(new PamAuthorizationFactory(factory.Pass()));
527 #endif 527 #endif
528 host_->SetAuthenticatorFactory(factory.Pass()); 528 host_->SetAuthenticatorFactory(factory.Pass());
529 } 529 }
530 530
531 // IPC::Listener implementation. 531 // IPC::Listener implementation.
532 bool HostProcess::OnMessageReceived(const IPC::Message& message) { 532 bool HostProcess::OnMessageReceived(const IPC::Message& message) {
533 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 533 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 681
682 // Applies the host config, returning true if successful. 682 // Applies the host config, returning true if successful.
683 bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) { 683 bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) {
684 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 684 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
685 685
686 if (!config->GetString(kHostIdConfigPath, &host_id_)) { 686 if (!config->GetString(kHostIdConfigPath, &host_id_)) {
687 LOG(ERROR) << "host_id is not defined in the config."; 687 LOG(ERROR) << "host_id is not defined in the config.";
688 return false; 688 return false;
689 } 689 }
690 690
691 if (!key_pair_.Load(*config)) { 691 std::string key_base64;
692 if (!config->GetString(kPrivateKeyConfigPath, &key_base64)) {
693 LOG(ERROR) << "Private key couldn't be read from the config file.";
692 return false; 694 return false;
693 } 695 }
694 696
697 key_pair_ = RsaKeyPair::FromString(key_base64);
698 if (!key_pair_) {
699 LOG(ERROR) << "Invalid private key in the config file.";
700 return false;
701 }
702
695 std::string host_secret_hash_string; 703 std::string host_secret_hash_string;
696 if (!config->GetString(kHostSecretHashConfigPath, 704 if (!config->GetString(kHostSecretHashConfigPath,
697 &host_secret_hash_string)) { 705 &host_secret_hash_string)) {
698 host_secret_hash_string = "plain:"; 706 host_secret_hash_string = "plain:";
699 } 707 }
700 708
701 if (!host_secret_hash_.Parse(host_secret_hash_string)) { 709 if (!host_secret_hash_.Parse(host_secret_hash_string)) {
702 LOG(ERROR) << "Invalid host_secret_hash."; 710 LOG(ERROR) << "Invalid host_secret_hash.";
703 return false; 711 return false;
704 } 712 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 context_->video_encode_task_runner(), 943 context_->video_encode_task_runner(),
936 context_->network_task_runner(), 944 context_->network_task_runner(),
937 context_->ui_task_runner()); 945 context_->ui_task_runner());
938 946
939 // TODO(simonmorris): Get the maximum session duration from a policy. 947 // TODO(simonmorris): Get the maximum session duration from a policy.
940 #if defined(OS_LINUX) 948 #if defined(OS_LINUX)
941 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); 949 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
942 #endif 950 #endif
943 951
944 heartbeat_sender_.reset(new HeartbeatSender( 952 heartbeat_sender_.reset(new HeartbeatSender(
945 this, host_id_, signal_strategy_.get(), &key_pair_, directory_bot_jid_)); 953 this, host_id_, signal_strategy_.get(), key_pair_,
954 directory_bot_jid_));
946 955
947 host_change_notification_listener_.reset(new HostChangeNotificationListener( 956 host_change_notification_listener_.reset(new HostChangeNotificationListener(
948 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); 957 this, host_id_, signal_strategy_.get(), directory_bot_jid_));
949 958
950 log_to_server_.reset( 959 log_to_server_.reset(
951 new LogToServer(host_->AsWeakPtr(), ServerLogEntry::ME2ME, 960 new LogToServer(host_->AsWeakPtr(), ServerLogEntry::ME2ME,
952 signal_strategy_.get(), directory_bot_jid_)); 961 signal_strategy_.get(), directory_bot_jid_));
953 962
954 // Set up repoting the host status notifications. 963 // Set up repoting the host status notifications.
955 #if defined(REMOTING_MULTI_PROCESS) 964 #if defined(REMOTING_MULTI_PROCESS)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 return exit_code; 1138 return exit_code;
1130 } 1139 }
1131 1140
1132 } // namespace remoting 1141 } // namespace remoting
1133 1142
1134 #if !defined(OS_WIN) 1143 #if !defined(OS_WIN)
1135 int main(int argc, char** argv) { 1144 int main(int argc, char** argv) {
1136 return remoting::HostMain(argc, argv); 1145 return remoting::HostMain(argc, argv);
1137 } 1146 }
1138 #endif // !defined(OS_WIN) 1147 #endif // !defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request_unittest.cc ('k') | remoting/host/setup/host_starter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698