| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 host_context_->ui_task_runner()->PostTask( | 476 host_context_->ui_task_runner()->PostTask( |
| 477 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, observer_, | 477 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, observer_, |
| 478 access_code, lifetime)); | 478 access_code, lifetime)); |
| 479 | 479 |
| 480 SetState(kReceivedAccessCode, ""); | 480 SetState(kReceivedAccessCode, ""); |
| 481 } | 481 } |
| 482 | 482 |
| 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()); |
| 487 |
| 486 // First ensure the JID we received is valid. | 488 // First ensure the JID we received is valid. |
| 487 std::string client_username; | 489 std::string client_username; |
| 488 if (!SplitJidResource(remote_jid, &client_username, /*resource=*/nullptr)) { | 490 if (!SplitJidResource(remote_jid, &client_username, /*resource=*/nullptr)) { |
| 489 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid | 491 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid |
| 490 << ": Invalid JID."; | 492 << ": Invalid JID."; |
| 491 result_callback.Run( | 493 result_callback.Run( |
| 492 protocol::ValidatingAuthenticator::Result::ERROR_INVALID_ACCOUNT); | 494 protocol::ValidatingAuthenticator::Result::ERROR_INVALID_ACCOUNT); |
| 495 DisconnectOnNetworkThread(); |
| 493 return; | 496 return; |
| 494 } | 497 } |
| 495 | 498 |
| 496 if (client_username.empty()) { | 499 if (client_username.empty()) { |
| 497 LOG(ERROR) << "Invalid user name passed in: " << remote_jid; | 500 LOG(ERROR) << "Invalid user name passed in: " << remote_jid; |
| 498 result_callback.Run( | 501 result_callback.Run( |
| 499 protocol::ValidatingAuthenticator::Result::ERROR_INVALID_ACCOUNT); | 502 protocol::ValidatingAuthenticator::Result::ERROR_INVALID_ACCOUNT); |
| 503 DisconnectOnNetworkThread(); |
| 500 return; | 504 return; |
| 501 } | 505 } |
| 502 | 506 |
| 503 // Check the client domain policy. | 507 // Check the client domain policy. |
| 504 if (!required_client_domain_.empty()) { | 508 if (!required_client_domain_.empty()) { |
| 505 if (!base::EndsWith(client_username, | 509 if (!base::EndsWith(client_username, |
| 506 std::string("@") + required_client_domain_, | 510 std::string("@") + required_client_domain_, |
| 507 base::CompareCase::INSENSITIVE_ASCII)) { | 511 base::CompareCase::INSENSITIVE_ASCII)) { |
| 508 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid | 512 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid |
| 509 << ": Domain mismatch."; | 513 << ": Domain mismatch."; |
| 510 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); | 514 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); |
| 515 DisconnectOnNetworkThread(); |
| 511 return; | 516 return; |
| 512 } | 517 } |
| 513 } | 518 } |
| 514 | 519 |
| 515 // Show a confirmation dialog to the user to allow them to confirm/reject it. | 520 // Show a confirmation dialog to the user to allow them to confirm/reject it. |
| 516 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( | 521 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( |
| 517 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); | 522 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); |
| 518 | 523 |
| 519 confirmation_dialog_proxy_->Show( | 524 confirmation_dialog_proxy_->Show( |
| 520 client_username, base::Bind(&It2MeHost::OnConfirmationResult, | 525 client_username, base::Bind(&It2MeHost::OnConfirmationResult, |
| 521 base::Unretained(this), result_callback)); | 526 base::Unretained(this), result_callback)); |
| 522 } | 527 } |
| 523 | 528 |
| 524 void It2MeHost::OnConfirmationResult( | 529 void It2MeHost::OnConfirmationResult( |
| 525 const protocol::ValidatingAuthenticator::ResultCallback& result_callback, | 530 const protocol::ValidatingAuthenticator::ResultCallback& result_callback, |
| 526 It2MeConfirmationDialog::Result result) { | 531 It2MeConfirmationDialog::Result result) { |
| 532 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 533 |
| 527 switch (result) { | 534 switch (result) { |
| 528 case It2MeConfirmationDialog::Result::OK: | 535 case It2MeConfirmationDialog::Result::OK: |
| 529 result_callback.Run(ValidationResult::SUCCESS); | 536 result_callback.Run(ValidationResult::SUCCESS); |
| 530 break; | 537 break; |
| 531 | 538 |
| 532 case It2MeConfirmationDialog::Result::CANCEL: | 539 case It2MeConfirmationDialog::Result::CANCEL: |
| 533 result_callback.Run(ValidationResult::ERROR_REJECTED_BY_USER); | 540 result_callback.Run(ValidationResult::ERROR_REJECTED_BY_USER); |
| 541 DisconnectOnNetworkThread(); |
| 534 break; | 542 break; |
| 535 } | 543 } |
| 536 } | 544 } |
| 537 | 545 |
| 538 It2MeHostFactory::It2MeHostFactory() {} | 546 It2MeHostFactory::It2MeHostFactory() {} |
| 539 | 547 |
| 540 It2MeHostFactory::~It2MeHostFactory() {} | 548 It2MeHostFactory::~It2MeHostFactory() {} |
| 541 | 549 |
| 542 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( | 550 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( |
| 543 std::unique_ptr<ChromotingHostContext> context, | 551 std::unique_ptr<ChromotingHostContext> context, |
| 544 policy::PolicyService* policy_service, | 552 policy::PolicyService* policy_service, |
| 545 base::WeakPtr<It2MeHost::Observer> observer, | 553 base::WeakPtr<It2MeHost::Observer> observer, |
| 546 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 554 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 547 const std::string& directory_bot_jid) { | 555 const std::string& directory_bot_jid) { |
| 548 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); | 556 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); |
| 549 | 557 |
| 550 std::unique_ptr<PolicyWatcher> policy_watcher = | 558 std::unique_ptr<PolicyWatcher> policy_watcher = |
| 551 PolicyWatcher::Create(policy_service, context->file_task_runner()); | 559 PolicyWatcher::Create(policy_service, context->file_task_runner()); |
| 552 return new It2MeHost(std::move(context), std::move(policy_watcher), | 560 return new It2MeHost(std::move(context), std::move(policy_watcher), |
| 553 It2MeConfirmationDialog::Create(), observer, | 561 It2MeConfirmationDialog::Create(), observer, |
| 554 xmpp_server_config, directory_bot_jid); | 562 xmpp_server_config, directory_bot_jid); |
| 555 } | 563 } |
| 556 | 564 |
| 557 } // namespace remoting | 565 } // namespace remoting |
| OLD | NEW |