summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/base/constants.cc3
-rw-r--r--remoting/base/constants.h3
-rw-r--r--remoting/chromoting.gyp3
-rw-r--r--remoting/client/host_connection.cc6
-rw-r--r--remoting/client/host_connection.h2
-rw-r--r--remoting/client/simple_client.cc13
-rw-r--r--remoting/host/simple_host.cc8
-rw-r--r--remoting/host/simple_host.h4
-rw-r--r--remoting/host/simple_host_process.cc21
-rw-r--r--remoting/jingle_glue/jingle_client.cc49
-rw-r--r--remoting/jingle_glue/jingle_client.h19
-rw-r--r--remoting/jingle_glue/jingle_test_client.cc17
-rwxr-xr-xremoting/tools/gettoken.py23
13 files changed, 108 insertions, 63 deletions
diff --git a/remoting/base/constants.cc b/remoting/base/constants.cc
index 7d42110..6618eb7 100644
--- a/remoting/base/constants.cc
+++ b/remoting/base/constants.cc
@@ -8,4 +8,7 @@ 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 190559e..6c2bb17 100644
--- a/remoting/base/constants.h
+++ b/remoting/base/constants.h
@@ -11,6 +11,9 @@ 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 7951abe..1b13059 100644
--- a/remoting/chromoting.gyp
+++ b/remoting/chromoting.gyp
@@ -238,6 +238,8 @@
'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',
@@ -266,6 +268,7 @@
'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 f858af6..00c542e 100644
--- a/remoting/client/host_connection.cc
+++ b/remoting/client/host_connection.cc
@@ -4,6 +4,8 @@
#include "remoting/client/host_connection.h"
+#include "remoting/base/constants.h"
+
namespace remoting {
HostConnection::HostConnection(ProtocolDecoder* decoder,
@@ -16,10 +18,10 @@ HostConnection::~HostConnection() {
}
void HostConnection::Connect(const std::string& username,
- const std::string& password,
+ const std::string& auth_token,
const std::string& host_jid) {
jingle_client_ = new JingleClient();
- jingle_client_->Init(username, password, this);
+ jingle_client_->Init(username, auth_token, kChromotingTokenServiceName, this);
jingle_channel_ = jingle_client_->Connect(host_jid, this);
}
diff --git a/remoting/client/host_connection.h b/remoting/client/host_connection.h
index af1fda7..8cd2a76 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& password,
+ void Connect(const std::string& username, const std::string& auth_token,
const std::string& host_jid);
void Disconnect();
diff --git a/remoting/client/simple_client.cc b/remoting/client/simple_client.cc
index ff74312..da65b2a 100644
--- a/remoting/client/simple_client.cc
+++ b/remoting/client/simple_client.cc
@@ -176,19 +176,16 @@ int main(int argc, char** argv) {
return 1;
}
- // 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;
+ // Get auth token.
+ std::string auth_token;
+ std::cout << "Auth Token: ";
+ getline(std::cin, auth_token);
// The message loop that everything runs on.
MessageLoop main_loop;
SimpleHostEventHandler handler(&main_loop);
HostConnection connection(new ProtocolDecoder(), &handler);
- connection.Connect(username, password, host_jid);
+ connection.Connect(username, auth_token, host_jid);
// Run the message.
main_loop.Run();
diff --git a/remoting/host/simple_host.cc b/remoting/host/simple_host.cc
index 945b663..8455ff5 100644
--- a/remoting/host/simple_host.cc
+++ b/remoting/host/simple_host.cc
@@ -6,6 +6,7 @@
#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"
@@ -13,14 +14,14 @@
namespace remoting {
SimpleHost::SimpleHost(const std::string& username,
- const std::string& password,
+ const std::string& auth_token,
Capturer* capturer,
Encoder* encoder,
EventExecutor* executor)
: capture_thread_("CaptureThread"),
encode_thread_("EncodeThread"),
username_(username),
- password_(password),
+ auth_token_(auth_token),
capturer_(capturer),
encoder_(encoder),
executor_(executor) {
@@ -59,7 +60,8 @@ void SimpleHost::RegisterHost() {
// Connect to the talk network with a JingleClient.
jingle_client_ = new JingleClient();
- jingle_client_->Init(username_, password_, this);
+ jingle_client_->Init(username_, auth_token_,
+ kChromotingTokenServiceName, 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 760256a..7f9227a 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& password,
+ SimpleHost(const std::string& username, const std::string& auth_token,
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 password_;
+ std::string auth_token_;
// 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 e3ed694..d4abc40 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -75,16 +75,13 @@ int main(int argc, char** argv) {
fake = true;
}
- // Prompt user for username and password.
+ // Prompt user for username and auth token.
std::string username;
std::cout << "JID: ";
std::cin >> username;
- std::string password;
- SetConsoleEcho(false);
- std::cout << "Password: ";
- std::cin >> password;
- SetConsoleEcho(true);
- std::cout << std::endl;
+ std::string auth_token;
+ std::cout << "Auth Token: ";
+ std::cin >> auth_token;
scoped_ptr<remoting::Capturer> capturer;
scoped_ptr<remoting::Encoder> encoder;
@@ -106,13 +103,13 @@ int main(int argc, char** argv) {
capturer.reset(new remoting::CapturerFake());
}
- // Construct a simple host with username and password.
+ // Construct a simple host with username and auth_token.
// TODO(hclam): Allow the host to load saved credentials.
scoped_refptr<remoting::SimpleHost> host
- = new remoting::SimpleHost(username, password,
- capturer.release(),
- encoder.release(),
- executor.release());
+ = new remoting::SimpleHost(username, auth_token,
+ 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 66867f5..bf6baee 100644
--- a/remoting/jingle_glue/jingle_client.cc
+++ b/remoting/jingle_glue/jingle_client.cc
@@ -7,6 +7,7 @@
#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"
@@ -18,6 +19,8 @@
#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 {
@@ -30,22 +33,20 @@ JingleClient::~JingleClient() {
DCHECK(state_ == CLOSED);
}
-void JingleClient::Init(const std::string& username,
- const std::string& password,
- Callback* callback) {
+void JingleClient::Init(
+ const std::string& username, const std::string& auth_token,
+ const std::string& auth_token_service, 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));
+ FROM_HERE, NewRunnableMethod(this, &JingleClient::DoInitialize,
+ username, auth_token, auth_token_service));
}
class JingleClient::ConnectRequest {
@@ -108,27 +109,28 @@ void JingleClient::DoClose() {
UpdateState(CLOSED);
}
-void JingleClient::DoInitialize() {
- buzz::Jid login_jid(username_);
- talk_base::InsecureCryptStringImpl password;
- password.password() = password_;
+void JingleClient::DoInitialize(const std::string& username,
+ const std::string& auth_token,
+ const std::string& auth_token_service) {
+ buzz::Jid login_jid(username);
- 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));
+ 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));
client_ = new buzz::XmppClient(thread_->task_pump());
client_->SignalStateChange.connect(
this, &JingleClient::OnConnectionStateChanged);
buzz::AsyncSocket* socket =
- new notifier::XmppSocketAdapter(xcs, false);
+ new notifier::XmppSocketAdapter(settings, false);
- client_->Connect(xcs, "", socket, NULL);
+ client_->Connect(settings, "", socket, CreatePreXmppAuth(settings));
client_->Start();
network_manager_.reset(new talk_base::NetworkManager());
@@ -224,4 +226,11 @@ 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 56d97e1..2a68042 100644
--- a/remoting/jingle_glue/jingle_client.h
+++ b/remoting/jingle_glue/jingle_client.h
@@ -16,6 +16,10 @@ namespace talk_base {
class NetworkManager;
} // namespace talk_base
+namespace buzz {
+class PreXmppAuth;
+} // namespace buzz
+
namespace cricket {
class BasicPortAllocator;
class SessionManager;
@@ -63,9 +67,8 @@ 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.
- // TODO(sergeyu): Replace password with a token.
- void Init(const std::string& username, const std::string& password,
- Callback* callback);
+ void Init(const std::string& username, const std::string& auth_token,
+ const std::string& auth_token_service, 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
@@ -101,7 +104,9 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>,
void OnIncomingTunnel(cricket::TunnelSessionClient* client, buzz::Jid jid,
std::string description, cricket::Session* session);
- void DoInitialize();
+ void DoInitialize(const std::string& username,
+ const std::string& auth_token,
+ const std::string& auth_token_service);
// Used by Connect().
void DoConnect(ConnectRequest* request,
@@ -115,13 +120,15 @@ 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 38677fe..7bf33c0 100644
--- a/remoting/jingle_glue/jingle_test_client.cc
+++ b/remoting/jingle_glue/jingle_test_client.cc
@@ -15,11 +15,13 @@ 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)
@@ -51,10 +53,10 @@ class JingleTestClient : public JingleChannel::Callback,
public:
virtual ~JingleTestClient() {}
- void Run(const std::string& username, const std::string& password,
+ void Run(const std::string& username, const std::string& auth_token,
const std::string& host_jid) {
client_ = new JingleClient();
- client_->Init(username, password, this);
+ client_->Init(username, auth_token, kChromotingTokenServiceName, this);
if (host_jid != "") {
scoped_refptr<JingleChannel> channel = client_->Connect(host_jid, this);
@@ -144,16 +146,13 @@ int main(int argc, char** argv) {
std::cout << "JID: ";
std::cin >> username;
- std::string password;
- SetConsoleEcho(false);
- std::cout << "Password: ";
- std::cin >> password;
- SetConsoleEcho(true);
- std::cout << std::endl;
+ std::string auth_token;
+ std::cout << "Auth token: ";
+ std::cin >> auth_token;
JingleTestClient client;
- client.Run(username, password, host_jid);
+ client.Run(username, auth_token, host_jid);
return 0;
}
diff --git a/remoting/tools/gettoken.py b/remoting/tools/gettoken.py
new file mode 100755
index 0000000..853d09b
--- /dev/null
+++ b/remoting/tools/gettoken.py
@@ -0,0 +1,23 @@
+#!/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()