diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 19:09:11 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 19:09:11 +0000 |
commit | 6f5ec4a51a4cfc6023c094801f2f180c6739a89b (patch) | |
tree | 256f64b843183e4c1c0b525ac84b84797e038848 /remoting | |
parent | c78559eabd562359ef23585df9268eeb5119b718 (diff) | |
download | chromium_src-6f5ec4a51a4cfc6023c094801f2f180c6739a89b.zip chromium_src-6f5ec4a51a4cfc6023c094801f2f180c6739a89b.tar.gz chromium_src-6f5ec4a51a4cfc6023c094801f2f180c6739a89b.tar.bz2 |
Revert 49298 - Broke compile - Token-based authentication for chromoting.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2749004
TBR=sergeyu@chromium.org
Review URL: http://codereview.chromium.org/2724010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/base/constants.cc | 3 | ||||
-rw-r--r-- | remoting/base/constants.h | 3 | ||||
-rw-r--r-- | remoting/chromoting.gyp | 3 | ||||
-rw-r--r-- | remoting/client/host_connection.cc | 6 | ||||
-rw-r--r-- | remoting/client/host_connection.h | 2 | ||||
-rw-r--r-- | remoting/client/simple_client.cc | 13 | ||||
-rw-r--r-- | remoting/host/simple_host.cc | 8 | ||||
-rw-r--r-- | remoting/host/simple_host.h | 4 | ||||
-rw-r--r-- | remoting/host/simple_host_process.cc | 21 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.cc | 49 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.h | 19 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_test_client.cc | 17 | ||||
-rwxr-xr-x | remoting/tools/gettoken.py | 23 |
13 files changed, 63 insertions, 108 deletions
diff --git a/remoting/base/constants.cc b/remoting/base/constants.cc index 6618eb7..7d42110 100644 --- a/remoting/base/constants.cc +++ b/remoting/base/constants.cc @@ -8,7 +8,4 @@ namespace remoting { const std::string kChromotingBotJid("chromoting@bot.talk.google.com"); -// TODO(sergeyu): Use chromoting's own service name here instead of sync. -const std::string kChromotingTokenServiceName("chromiumsync"); - } // namespace remoting diff --git a/remoting/base/constants.h b/remoting/base/constants.h index 6c2bb17..190559e 100644 --- a/remoting/base/constants.h +++ b/remoting/base/constants.h @@ -11,9 +11,6 @@ namespace remoting { extern const std::string kChromotingBotJid; -// Service name used for authentication. -extern const std::string kChromotingTokenServiceName; - } // namespace remoting #endif // REMOTING_BASE_CONSTANTS_H diff --git a/remoting/chromoting.gyp b/remoting/chromoting.gyp index 1b13059..7951abe 100644 --- a/remoting/chromoting.gyp +++ b/remoting/chromoting.gyp @@ -238,8 +238,6 @@ 'target_name': 'chromoting_jingle_glue', 'type': '<(library)', 'dependencies': [ - # TODO(sergeyu): move all code that is shared between notifier and - # jingle_glue to a separate library and use it here. '../chrome/chrome.gyp:notifier', '../third_party/libjingle/libjingle.gyp:libjingle', '../third_party/libjingle/libjingle.gyp:libjingle_p2p', @@ -268,7 +266,6 @@ 'target_name': 'chromoting_jingle_test_client', 'type': 'executable', 'dependencies': [ - 'chromoting_base', 'chromoting_jingle_glue', '../media/media.gyp:media', ], diff --git a/remoting/client/host_connection.cc b/remoting/client/host_connection.cc index 00c542e..f858af6 100644 --- a/remoting/client/host_connection.cc +++ b/remoting/client/host_connection.cc @@ -4,8 +4,6 @@ #include "remoting/client/host_connection.h" -#include "remoting/base/constants.h" - namespace remoting { HostConnection::HostConnection(ProtocolDecoder* decoder, @@ -18,10 +16,10 @@ HostConnection::~HostConnection() { } void HostConnection::Connect(const std::string& username, - const std::string& auth_token, + const std::string& password, const std::string& host_jid) { jingle_client_ = new JingleClient(); - jingle_client_->Init(username, auth_token, kChromotingTokenServiceName, this); + jingle_client_->Init(username, password, this); jingle_channel_ = jingle_client_->Connect(host_jid, this); } diff --git a/remoting/client/host_connection.h b/remoting/client/host_connection.h index 8cd2a76..af1fda7 100644 --- a/remoting/client/host_connection.h +++ b/remoting/client/host_connection.h @@ -47,7 +47,7 @@ class HostConnection : public JingleChannel::Callback, virtual ~HostConnection(); - void Connect(const std::string& username, const std::string& auth_token, + void Connect(const std::string& username, const std::string& password, const std::string& host_jid); void Disconnect(); diff --git a/remoting/client/simple_client.cc b/remoting/client/simple_client.cc index da65b2a..ff74312 100644 --- a/remoting/client/simple_client.cc +++ b/remoting/client/simple_client.cc @@ -176,16 +176,19 @@ int main(int argc, char** argv) { return 1; } - // Get auth token. - std::string auth_token; - std::cout << "Auth Token: "; - getline(std::cin, auth_token); + // Get password (with console echo turned off). + std::string password; + SetConsoleEcho(false); + std::cout << "Password: "; + getline(std::cin, password); + SetConsoleEcho(true); + std::cout << std::endl; // The message loop that everything runs on. MessageLoop main_loop; SimpleHostEventHandler handler(&main_loop); HostConnection connection(new ProtocolDecoder(), &handler); - connection.Connect(username, auth_token, host_jid); + connection.Connect(username, password, host_jid); // Run the message. main_loop.Run(); diff --git a/remoting/host/simple_host.cc b/remoting/host/simple_host.cc index 8455ff5..945b663 100644 --- a/remoting/host/simple_host.cc +++ b/remoting/host/simple_host.cc @@ -6,7 +6,6 @@ #include "base/stl_util-inl.h" #include "build/build_config.h" -#include "remoting/base/constants.h" #include "remoting/base/protocol_decoder.h" #include "remoting/host/session_manager.h" #include "remoting/jingle_glue/jingle_channel.h" @@ -14,14 +13,14 @@ namespace remoting { SimpleHost::SimpleHost(const std::string& username, - const std::string& auth_token, + const std::string& password, Capturer* capturer, Encoder* encoder, EventExecutor* executor) : capture_thread_("CaptureThread"), encode_thread_("EncodeThread"), username_(username), - auth_token_(auth_token), + password_(password), capturer_(capturer), encoder_(encoder), executor_(executor) { @@ -60,8 +59,7 @@ void SimpleHost::RegisterHost() { // Connect to the talk network with a JingleClient. jingle_client_ = new JingleClient(); - jingle_client_->Init(username_, auth_token_, - kChromotingTokenServiceName, this); + jingle_client_->Init(username_, password_, this); } // This method is called if a client is connected to this object. diff --git a/remoting/host/simple_host.h b/remoting/host/simple_host.h index 7f9227a..760256a 100644 --- a/remoting/host/simple_host.h +++ b/remoting/host/simple_host.h @@ -47,7 +47,7 @@ class SimpleHost : public base::RefCountedThreadSafe<SimpleHost>, public ClientConnection::EventHandler, public JingleClient::Callback { public: - SimpleHost(const std::string& username, const std::string& auth_token, + SimpleHost(const std::string& username, const std::string& password, Capturer* capturer, Encoder* encoder, EventExecutor* executor); // Run the host porcess. This method returns only after the message loop @@ -96,7 +96,7 @@ class SimpleHost : public base::RefCountedThreadSafe<SimpleHost>, base::Thread encode_thread_; std::string username_; - std::string auth_token_; + std::string password_; // Capturer to be used by SessionManager. Once the SessionManager is // constructed this is set to NULL. diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index d4abc40..e3ed694 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -75,13 +75,16 @@ int main(int argc, char** argv) { fake = true; } - // Prompt user for username and auth token. + // Prompt user for username and password. std::string username; std::cout << "JID: "; std::cin >> username; - std::string auth_token; - std::cout << "Auth Token: "; - std::cin >> auth_token; + std::string password; + SetConsoleEcho(false); + std::cout << "Password: "; + std::cin >> password; + SetConsoleEcho(true); + std::cout << std::endl; scoped_ptr<remoting::Capturer> capturer; scoped_ptr<remoting::Encoder> encoder; @@ -103,13 +106,13 @@ int main(int argc, char** argv) { capturer.reset(new remoting::CapturerFake()); } - // Construct a simple host with username and auth_token. + // Construct a simple host with username and password. // TODO(hclam): Allow the host to load saved credentials. scoped_refptr<remoting::SimpleHost> host - = new remoting::SimpleHost(username, auth_token, - capturer.release(), - encoder.release(), - executor.release()); + = new remoting::SimpleHost(username, password, + capturer.release(), + encoder.release(), + executor.release()); host->Run(); return 0; } diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index bf6baee..66867f5 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "base/waitable_event.h" #include "base/message_loop.h" -#include "chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h" #include "chrome/common/net/notifier/communicator/xmpp_socket_adapter.h" #include "remoting/jingle_glue/jingle_thread.h" #include "remoting/jingle_glue/relay_port_allocator.h" @@ -19,8 +18,6 @@ #include "talk/session/tunnel/securetunnelsessionclient.h" #endif #include "talk/session/tunnel/tunnelsessionclient.h" -#include "talk/xmpp/prexmppauth.h" -#include "talk/xmpp/saslcookiemechanism.h" namespace remoting { @@ -33,20 +30,22 @@ JingleClient::~JingleClient() { DCHECK(state_ == CLOSED); } -void JingleClient::Init( - const std::string& username, const std::string& auth_token, - const std::string& auth_token_service, Callback* callback) { +void JingleClient::Init(const std::string& username, + const std::string& password, + Callback* callback) { DCHECK(username != ""); DCHECK(callback != NULL); DCHECK(thread_ == NULL); // Init() can be called only once. callback_ = callback; + username_ = username; + password_ = password; + thread_.reset(new JingleThread()); thread_->Start(); thread_->message_loop()->PostTask( - FROM_HERE, NewRunnableMethod(this, &JingleClient::DoInitialize, - username, auth_token, auth_token_service)); + FROM_HERE, NewRunnableMethod(this, &JingleClient::DoInitialize)); } class JingleClient::ConnectRequest { @@ -109,28 +108,27 @@ void JingleClient::DoClose() { UpdateState(CLOSED); } -void JingleClient::DoInitialize(const std::string& username, - const std::string& auth_token, - const std::string& auth_token_service) { - buzz::Jid login_jid(username); +void JingleClient::DoInitialize() { + buzz::Jid login_jid(username_); + talk_base::InsecureCryptStringImpl password; + password.password() = password_; - buzz::XmppClientSettings settings; - settings.set_user(login_jid.node()); - settings.set_host(login_jid.domain()); - settings.set_resource("chromoting"); - settings.set_use_tls(true); - settings.set_token_service(auth_token_service); - settings.set_auth_cookie(auth_token); - settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); + buzz::XmppClientSettings xcs; + xcs.set_user(login_jid.node()); + xcs.set_host(login_jid.domain()); + xcs.set_resource("chromoting"); + xcs.set_use_tls(true); + xcs.set_pass(talk_base::CryptString(password)); + xcs.set_server(talk_base::SocketAddress("talk.google.com", 5222)); client_ = new buzz::XmppClient(thread_->task_pump()); client_->SignalStateChange.connect( this, &JingleClient::OnConnectionStateChanged); buzz::AsyncSocket* socket = - new notifier::XmppSocketAdapter(settings, false); + new notifier::XmppSocketAdapter(xcs, false); - client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); + client_->Connect(xcs, "", socket, NULL); client_->Start(); network_manager_.reset(new talk_base::NetworkManager()); @@ -226,11 +224,4 @@ void JingleClient::UpdateState(State new_state) { } } -buzz::PreXmppAuth* JingleClient::CreatePreXmppAuth( - const buzz::XmppClientSettings& settings) { - buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); - return new notifier::GaiaTokenPreXmppAuth(jid.Str(), settings.auth_cookie(), - settings.token_service()); -} - } // namespace remoting diff --git a/remoting/jingle_glue/jingle_client.h b/remoting/jingle_glue/jingle_client.h index 2a68042..56d97e1 100644 --- a/remoting/jingle_glue/jingle_client.h +++ b/remoting/jingle_glue/jingle_client.h @@ -16,10 +16,6 @@ namespace talk_base { class NetworkManager; } // namespace talk_base -namespace buzz { -class PreXmppAuth; -} // namespace buzz - namespace cricket { class BasicPortAllocator; class SessionManager; @@ -67,8 +63,9 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>, // only once. message_loop() is guaranteed to exist after this method returns, // but the connection may not be open yet. |callback| specifies callback // object for the client and must not be NULL. - void Init(const std::string& username, const std::string& auth_token, - const std::string& auth_token_service, Callback* callback); + // TODO(sergeyu): Replace password with a token. + void Init(const std::string& username, const std::string& password, + Callback* callback); // Creates new JingleChannel connected to the host with the specified jid. // The result is returned immediately but the channel fails if the host @@ -104,9 +101,7 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>, void OnIncomingTunnel(cricket::TunnelSessionClient* client, buzz::Jid jid, std::string description, cricket::Session* session); - void DoInitialize(const std::string& username, - const std::string& auth_token, - const std::string& auth_token_service); + void DoInitialize(); // Used by Connect(). void DoConnect(ConnectRequest* request, @@ -120,15 +115,13 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>, // the jingle thread. void UpdateState(State new_state); - buzz::PreXmppAuth* CreatePreXmppAuth( - const buzz::XmppClientSettings& settings); - - buzz::XmppClient* client_; scoped_ptr<JingleThread> thread_; State state_; Callback* callback_; + std::string username_; + std::string password_; Lock full_jid_lock_; std::string full_jid_; diff --git a/remoting/jingle_glue/jingle_test_client.cc b/remoting/jingle_glue/jingle_test_client.cc index 7bf33c0..38677fe 100644 --- a/remoting/jingle_glue/jingle_test_client.cc +++ b/remoting/jingle_glue/jingle_test_client.cc @@ -15,13 +15,11 @@ extern "C" { #include "base/at_exit.h" #include "media/base/data_buffer.h" -#include "remoting/base/constants.h" #include "remoting/jingle_glue/jingle_channel.h" #include "remoting/jingle_glue/jingle_client.h" using remoting::JingleClient; using remoting::JingleChannel; -using remoting::kChromotingTokenServiceName; void SetConsoleEcho(bool on) { #if defined(OS_WIN) @@ -53,10 +51,10 @@ class JingleTestClient : public JingleChannel::Callback, public: virtual ~JingleTestClient() {} - void Run(const std::string& username, const std::string& auth_token, + void Run(const std::string& username, const std::string& password, const std::string& host_jid) { client_ = new JingleClient(); - client_->Init(username, auth_token, kChromotingTokenServiceName, this); + client_->Init(username, password, this); if (host_jid != "") { scoped_refptr<JingleChannel> channel = client_->Connect(host_jid, this); @@ -146,13 +144,16 @@ int main(int argc, char** argv) { std::cout << "JID: "; std::cin >> username; - std::string auth_token; - std::cout << "Auth token: "; - std::cin >> auth_token; + std::string password; + SetConsoleEcho(false); + std::cout << "Password: "; + std::cin >> password; + SetConsoleEcho(true); + std::cout << std::endl; JingleTestClient client; - client.Run(username, auth_token, host_jid); + client.Run(username, password, host_jid); return 0; } diff --git a/remoting/tools/gettoken.py b/remoting/tools/gettoken.py deleted file mode 100755 index 853d09b..0000000 --- a/remoting/tools/gettoken.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2010 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# gettoken.py can be used to get auth token from Gaia. It asks username and -# password and then prints token on the screen. - -import urllib -import getpass -url = "https://www.google.com:443/accounts/ClientLogin" - -print "Email:", -email = raw_input() - -passwd = getpass.getpass("Password: ") - -params = urllib.urlencode({'Email': email, 'Passwd': passwd, - 'source': 'chromoting', 'service': 'chromiumsync', - 'PersistentCookie': 'true', 'accountType': 'GOOGLE'}) -f = urllib.urlopen(url, params); -print f.read() |