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

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: Rename key_pair_ to local_key_pair_ 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 "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
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 scoped_refptr<RsaKeyPair> 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ShutdownHost(kSuccessExitCode); 507 ShutdownHost(kSuccessExitCode);
508 } 508 }
509 #endif // OS_POSIX 509 #endif // OS_POSIX
510 510
511 void HostProcess::CreateAuthenticatorFactory() { 511 void HostProcess::CreateAuthenticatorFactory() {
512 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 512 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
513 513
514 if (state_ != HOST_STARTED) 514 if (state_ != HOST_STARTED)
515 return; 515 return;
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_, 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
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 key_pair_ = new RsaKeyPair();
689 std::string key_base64;
690 if (!config->GetString(kPrivateKeyConfigPath, &key_base64) ||
691 !key_pair_->LoadFromString(key_base64)) {
692 LOG(ERROR) << "Private key couldn't be read from the config file.";
689 return false; 693 return false;
690 } 694 }
691 695
692 std::string host_secret_hash_string; 696 std::string host_secret_hash_string;
693 if (!config->GetString(kHostSecretHashConfigPath, 697 if (!config->GetString(kHostSecretHashConfigPath,
694 &host_secret_hash_string)) { 698 &host_secret_hash_string)) {
695 host_secret_hash_string = "plain:"; 699 host_secret_hash_string = "plain:";
696 } 700 }
697 701
698 if (!host_secret_hash_.Parse(host_secret_hash_string)) { 702 if (!host_secret_hash_.Parse(host_secret_hash_string)) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 context_->video_encode_task_runner(), 927 context_->video_encode_task_runner(),
924 context_->network_task_runner(), 928 context_->network_task_runner(),
925 context_->ui_task_runner()); 929 context_->ui_task_runner());
926 930
927 // TODO(simonmorris): Get the maximum session duration from a policy. 931 // TODO(simonmorris): Get the maximum session duration from a policy.
928 #if defined(OS_LINUX) 932 #if defined(OS_LINUX)
929 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); 933 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
930 #endif 934 #endif
931 935
932 heartbeat_sender_.reset(new HeartbeatSender( 936 heartbeat_sender_.reset(new HeartbeatSender(
933 this, host_id_, signal_strategy_.get(), &key_pair_, directory_bot_jid_)); 937 this, host_id_, signal_strategy_.get(), key_pair_,
938 directory_bot_jid_));
934 939
935 host_change_notification_listener_.reset(new HostChangeNotificationListener( 940 host_change_notification_listener_.reset(new HostChangeNotificationListener(
936 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); 941 this, host_id_, signal_strategy_.get(), directory_bot_jid_));
937 942
938 log_to_server_.reset( 943 log_to_server_.reset(
939 new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get(), 944 new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get(),
940 directory_bot_jid_)); 945 directory_bot_jid_));
941 host_event_logger_ = HostEventLogger::Create(host_, kApplicationName); 946 host_event_logger_ = HostEventLogger::Create(host_, kApplicationName);
942 947
943 resizing_host_observer_.reset( 948 resizing_host_observer_.reset(
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 return exit_code; 1156 return exit_code;
1152 } 1157 }
1153 1158
1154 } // namespace remoting 1159 } // namespace remoting
1155 1160
1156 #if !defined(OS_WIN) 1161 #if !defined(OS_WIN)
1157 int main(int argc, char** argv) { 1162 int main(int argc, char** argv) {
1158 return remoting::HostProcessMain(argc, argv); 1163 return remoting::HostProcessMain(argc, argv);
1159 } 1164 }
1160 #endif // !defined(OS_WIN) 1165 #endif // !defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698