diff options
author | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-16 16:30:05 +0000 |
---|---|---|
committer | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-16 16:30:05 +0000 |
commit | 066e4710edc8ca309fe7328212ad6cb4c64b6347 (patch) | |
tree | 4879c0ac87c8707d97c398f53634171e92cc1460 | |
parent | 357284ba336a2fe71a84bc9456c71a169bad4c6e (diff) | |
download | chromium_src-066e4710edc8ca309fe7328212ad6cb4c64b6347.zip chromium_src-066e4710edc8ca309fe7328212ad6cb4c64b6347.tar.gz chromium_src-066e4710edc8ca309fe7328212ad6cb4c64b6347.tar.bz2 |
Store (and check) support id in SupportAccessVerifier.
BUG=None
TEST=Manual
Review URL: http://codereview.chromium.org/7013065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85492 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/host/simple_host_process.cc | 20 | ||||
-rw-r--r-- | remoting/host/support_access_verifier.cc | 19 | ||||
-rw-r--r-- | remoting/host/support_access_verifier.h | 3 |
3 files changed, 30 insertions, 12 deletions
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index d4e8b4c..691e5b8 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -108,7 +108,12 @@ class SimpleHost { } // Initialize AccessVerifier. + // TODO(jamiewalch): For the Me2Mom case, the access verifier is passed to + // RegisterSupportHostRequest::Init, so transferring ownership of it to the + // ChromotingHost could cause a crash condition at shut-down. Fix this. scoped_ptr<remoting::AccessVerifier> access_verifier; + remoting::RegisterSupportHostRequest::RegisterCallback* + register_callback = NULL; if (me2mom_) { scoped_ptr<remoting::SupportAccessVerifier> support_access_verifier( new remoting::SupportAccessVerifier()); @@ -116,6 +121,9 @@ class SimpleHost { return 1; std::cout << "Host secret: " << support_access_verifier->host_secret() << std::endl; + register_callback = NewCallback( + support_access_verifier.get(), + &remoting::SupportAccessVerifier::OnMe2MomHostRegistered); access_verifier.reset(support_access_verifier.release()); } else { scoped_ptr<remoting::SelfAccessVerifier> self_access_verifier( @@ -149,8 +157,7 @@ class SimpleHost { if (me2mom_) { scoped_refptr<remoting::RegisterSupportHostRequest> register_request = new remoting::RegisterSupportHostRequest(); - if (!register_request->Init( - config, NewCallback(this, &SimpleHost::OnMe2MomHostRegistered))) { + if (!register_request->Init(config, register_callback)) { return 1; } host->AddStatusObserver(register_request); @@ -197,15 +204,6 @@ class SimpleHost { return FilePath(home_path).Append(kDefaultConfigPath); } - void OnMe2MomHostRegistered(bool successful, const std::string& support_id) { - if (successful) { - std::cout << "Support id: " - << support_id << std::endl; - } else { - LOG(ERROR) << "Failed to register support host"; - } - } - FilePath config_path_; bool fake_; bool me2mom_; diff --git a/remoting/host/support_access_verifier.cc b/remoting/host/support_access_verifier.cc index e38911b..30ad662 100644 --- a/remoting/host/support_access_verifier.cc +++ b/remoting/host/support_access_verifier.cc @@ -6,6 +6,7 @@ #include <stdlib.h> #include <vector> +#include <iostream> #include "base/logging.h" #include "base/rand_util.h" @@ -60,10 +61,26 @@ bool SupportAccessVerifier::VerifyPermissions( const std::string& client_jid, const std::string& encoded_access_token) { CHECK(initialized_); + if (support_id_.empty()) + return false; // TODO(jamiewalch): This needs to compose the support id with the host // secret before verification. + std::string access_code = support_id_ + "-" + host_secret_; return protocol::VerifySupportAuthToken( - client_jid, host_secret_, encoded_access_token); + client_jid, access_code, encoded_access_token); +} + +void SupportAccessVerifier::OnMe2MomHostRegistered( + bool successful, const std::string& support_id) { + if (successful) { + // TODO(jamiewalch): cout is only needed so that remoting_simple_host can + // report the support id to the user. Find a better way (issue 82651). + std::cout << "Support id: " + << support_id << std::endl; + support_id_ = support_id; + } else { + LOG(ERROR) << "Failed to register support host"; + } } } // namespace remoting diff --git a/remoting/host/support_access_verifier.h b/remoting/host/support_access_verifier.h index f3967e9..755700a 100644 --- a/remoting/host/support_access_verifier.h +++ b/remoting/host/support_access_verifier.h @@ -30,9 +30,12 @@ class SupportAccessVerifier : public AccessVerifier { const std::string& client_jid, const std::string& encoded_client_token) OVERRIDE; + void OnMe2MomHostRegistered(bool successful, const std::string& support_id); + private: bool initialized_; std::string host_secret_; + std::string support_id_; DISALLOW_COPY_AND_ASSIGN(SupportAccessVerifier); }; |