Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/it2me/it2me_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 } | 369 } |
| 370 | 370 |
| 371 required_host_domain_ = host_domain; | 371 required_host_domain_ = host_domain; |
| 372 } | 372 } |
| 373 | 373 |
| 374 void It2MeHost::UpdateClientDomainPolicy(const std::string& client_domain) { | 374 void It2MeHost::UpdateClientDomainPolicy(const std::string& client_domain) { |
| 375 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 375 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 376 | 376 |
| 377 VLOG(2) << "UpdateClientDomainPolicy: " << client_domain; | 377 VLOG(2) << "UpdateClientDomainPolicy: " << client_domain; |
| 378 | 378 |
| 379 // When setting a client domain policy, disconnect any existing session. | 379 // When setting a client domain policy, disconnect any existing session. |
| 380 if (!client_domain.empty() && IsRunning()) { | 380 if (!client_domain.empty() && IsRunning()) { |
| 381 DisconnectOnNetworkThread(); | 381 DisconnectOnNetworkThread(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 required_client_domain_ = client_domain; | 384 required_client_domain_ = client_domain; |
| 385 } | 385 } |
| 386 | 386 |
| 387 void It2MeHost::SetState(It2MeHostState state, | 387 void It2MeHost::SetState(It2MeHostState state, |
| 388 const std::string& error_message) { | 388 const std::string& error_message) { |
| 389 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 389 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 void It2MeHost::ValidateConnectionDetails( | 483 void It2MeHost::ValidateConnectionDetails( |
| 484 const std::string& remote_jid, | 484 const std::string& remote_jid, |
| 485 const protocol::ValidatingAuthenticator::ResultCallback& result_callback) { | 485 const protocol::ValidatingAuthenticator::ResultCallback& result_callback) { |
| 486 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 486 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 487 | 487 |
| 488 // First ensure the JID we received is valid. | 488 // First ensure the JID we received is valid. |
| 489 std::string client_username; | 489 std::string client_username; |
| 490 if (!SplitJidResource(remote_jid, &client_username, /*resource=*/nullptr)) { | 490 if (!SplitJidResource(remote_jid, &client_username, /*resource=*/nullptr)) { |
| 491 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid | 491 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid |
| 492 << ": Invalid JID."; | 492 << ": Invalid JID."; |
| 493 result_callback.Run( | 493 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); |
| 494 protocol::ValidatingAuthenticator::Result::ERROR_INVALID_ACCOUNT); | |
| 495 DisconnectOnNetworkThread(); | 494 DisconnectOnNetworkThread(); |
| 496 return; | 495 return; |
| 497 } | 496 } |
| 498 | 497 |
| 499 if (client_username.empty()) { | 498 if (client_username.empty()) { |
| 500 LOG(ERROR) << "Invalid user name passed in: " << remote_jid; | 499 LOG(ERROR) << "Invalid user name passed in: " << remote_jid; |
| 501 result_callback.Run( | 500 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); |
| 502 protocol::ValidatingAuthenticator::Result::ERROR_INVALID_ACCOUNT); | |
| 503 DisconnectOnNetworkThread(); | 501 DisconnectOnNetworkThread(); |
| 504 return; | 502 return; |
| 505 } | 503 } |
| 506 | 504 |
| 507 // Check the client domain policy. | 505 // Check the client domain policy. |
| 508 if (!required_client_domain_.empty()) { | 506 if (!required_client_domain_.empty()) { |
| 509 if (!base::EndsWith(client_username, | 507 if (!base::EndsWith(client_username, |
| 510 std::string("@") + required_client_domain_, | 508 std::string("@") + required_client_domain_, |
| 511 base::CompareCase::INSENSITIVE_ASCII)) { | 509 base::CompareCase::INSENSITIVE_ASCII)) { |
| 512 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid | 510 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid |
| 513 << ": Domain mismatch."; | 511 << ": Domain mismatch."; |
| 514 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); | 512 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); |
| 515 DisconnectOnNetworkThread(); | 513 DisconnectOnNetworkThread(); |
| 516 return; | 514 return; |
| 517 } | 515 } |
| 518 } | 516 } |
| 519 | 517 |
| 518 // If we receive valid connection details multiple times, then we don't know | |
| 519 // which remote user (if either) is valid so disconnect everyone. | |
| 520 if (state_ != kReceivedAccessCode) { | |
|
Sergey Ulanov
2017/03/02 23:07:29
I don't think we want to shutdown the host when th
joedow
2017/03/13 23:26:57
I missed that scenario so thanks for pointing that
| |
| 521 LOG(ERROR) << "Received too many connection requests."; | |
| 522 result_callback.Run(ValidationResult::ERROR_TOO_MANY_CONNECTIONS); | |
| 523 DisconnectOnNetworkThread(); | |
| 524 return; | |
| 525 } | |
| 526 | |
| 520 HOST_LOG << "Client " << client_username << " connecting."; | 527 HOST_LOG << "Client " << client_username << " connecting."; |
| 521 SetState(kConnecting, std::string()); | 528 SetState(kConnecting, std::string()); |
| 522 | 529 |
| 523 // Show a confirmation dialog to the user to allow them to confirm/reject it. | 530 // Show a confirmation dialog to the user to allow them to confirm/reject it. |
| 524 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( | 531 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( |
| 525 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); | 532 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); |
| 526 | 533 |
| 527 confirmation_dialog_proxy_->Show( | 534 confirmation_dialog_proxy_->Show( |
| 528 client_username, base::Bind(&It2MeHost::OnConfirmationResult, | 535 client_username, base::Bind(&It2MeHost::OnConfirmationResult, |
| 529 base::Unretained(this), result_callback)); | 536 base::Unretained(this), result_callback)); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 560 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); | 567 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); |
| 561 | 568 |
| 562 std::unique_ptr<PolicyWatcher> policy_watcher = | 569 std::unique_ptr<PolicyWatcher> policy_watcher = |
| 563 PolicyWatcher::Create(policy_service, context->file_task_runner()); | 570 PolicyWatcher::Create(policy_service, context->file_task_runner()); |
| 564 return new It2MeHost(std::move(context), std::move(policy_watcher), | 571 return new It2MeHost(std::move(context), std::move(policy_watcher), |
| 565 It2MeConfirmationDialog::Create(), observer, | 572 It2MeConfirmationDialog::Create(), observer, |
| 566 std::move(signal_strategy), username, directory_bot_jid); | 573 std::move(signal_strategy), username, directory_bot_jid); |
| 567 } | 574 } |
| 568 | 575 |
| 569 } // namespace remoting | 576 } // namespace remoting |
| OLD | NEW |