diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 00:19:53 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 00:19:53 +0000 |
commit | 21109574d203fea7e3f4490beadcb76eb62645b6 (patch) | |
tree | b903119dadd5c28985c532d1db6547649a1835e0 /remoting | |
parent | 8e9e6d194ac2037ec1b75076d6e037a0e28692a2 (diff) | |
download | chromium_src-21109574d203fea7e3f4490beadcb76eb62645b6.zip chromium_src-21109574d203fea7e3f4490beadcb76eb62645b6.tar.gz chromium_src-21109574d203fea7e3f4490beadcb76eb62645b6.tar.bz2 |
Added Me2Me-specific authenticator factory.
BUG=105214
Review URL: http://codereview.chromium.org/9158003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 15 | ||||
-rw-r--r-- | remoting/host/simple_host_process.cc | 14 | ||||
-rw-r--r-- | remoting/protocol/me2me_host_authenticator_factory.cc | 63 | ||||
-rw-r--r-- | remoting/protocol/me2me_host_authenticator_factory.h | 48 | ||||
-rw-r--r-- | remoting/protocol/v2_authenticator.h | 12 | ||||
-rw-r--r-- | remoting/remoting.gyp | 2 |
6 files changed, 135 insertions, 19 deletions
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 21a4f40..3a3192b 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -30,7 +30,7 @@ #include "remoting/host/json_host_config.h" #include "remoting/host/signaling_connector.h" #include "remoting/jingle_glue/xmpp_signal_strategy.h" -#include "remoting/protocol/v1_authenticator.h" +#include "remoting/protocol/me2me_host_authenticator_factory.h" #if defined(TOOLKIT_USES_GTK) #include "ui/gfx/gtk_util.h" @@ -161,13 +161,14 @@ class HostProcess { host_->Start(); - // Set an empty shared-secret for Me2Me. - - // TODO(sergeyu): This is a temporary hack pending us adding a way - // to set a PIN. crbug.com/105214 . + // Create authenticator factory. + // + // TODO(sergeyu): Currently empty PIN is used. This is a temporary + // hack pending us adding a way to set a PIN. crbug.com/105214 . scoped_ptr<protocol::AuthenticatorFactory> factory( - new protocol::V1HostAuthenticatorFactory( - key_pair_.GenerateCertificate(), key_pair_.private_key(), "")); + new protocol::Me2MeHostAuthenticatorFactory( + xmpp_login_, key_pair_.GenerateCertificate(), + key_pair_.private_key(), "")); host_->SetAuthenticatorFactory(factory.Pass()); } diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index f7fbbe0..b34c1b8 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -47,7 +47,7 @@ #include "remoting/jingle_glue/xmpp_signal_strategy.h" #include "remoting/proto/video.pb.h" #include "remoting/protocol/it2me_host_authenticator_factory.h" -#include "remoting/protocol/v1_authenticator.h" +#include "remoting/protocol/me2me_host_authenticator_factory.h" #if defined(TOOLKIT_USES_GTK) #include "ui/gfx/gtk_util.h" @@ -235,13 +235,15 @@ class SimpleHost { host_->Start(); - // Set an empty shared-secret for Me2Me. - // TODO(sergeyu): This is a temporary hack pending us adding a way - // to set a PIN. crbug.com/105214 . + // Create a Me2Me authenticator factory. + // + // TODO(sergeyu): Currently empty PIN is used. This is a temporary + // hack pending us adding a way to set a PIN. crbug.com/105214 . if (!is_it2me_) { scoped_ptr<protocol::AuthenticatorFactory> factory( - new protocol::V1HostAuthenticatorFactory( - key_pair_.GenerateCertificate(), key_pair_.private_key(), "")); + new protocol::Me2MeHostAuthenticatorFactory( + xmpp_login_, key_pair_.GenerateCertificate(), + key_pair_.private_key(), "")); host_->SetAuthenticatorFactory(factory.Pass()); } } diff --git a/remoting/protocol/me2me_host_authenticator_factory.cc b/remoting/protocol/me2me_host_authenticator_factory.cc new file mode 100644 index 0000000..1b3bf90 --- /dev/null +++ b/remoting/protocol/me2me_host_authenticator_factory.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2012 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. + +#include "remoting/protocol/me2me_host_authenticator_factory.h" + +#include "base/string_util.h" +#include "crypto/rsa_private_key.h" +#include "remoting/protocol/v1_authenticator.h" +#include "remoting/protocol/v2_authenticator.h" + +namespace remoting { +namespace protocol { + +Me2MeHostAuthenticatorFactory::Me2MeHostAuthenticatorFactory( + const std::string& local_jid, + const std::string& local_cert, + const crypto::RSAPrivateKey* local_private_key, + const std::string& shared_secret) + : local_cert_(local_cert), + local_private_key_(local_private_key->Copy()), + shared_secret_(shared_secret) { + // Verify that |local_jid| is bare. + DCHECK_EQ(local_jid.find('/'), std::string::npos); + local_jid_prefix_ = local_jid + '/'; +} + +Me2MeHostAuthenticatorFactory::~Me2MeHostAuthenticatorFactory() { +} + +Authenticator* Me2MeHostAuthenticatorFactory::CreateAuthenticator( + const std::string& remote_jid, + const buzz::XmlElement* first_message) { + // Reject incoming connection if the client's jid is not an ASCII string. + if (!IsStringASCII(remote_jid)) { + LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; + return NULL; + } + + // Check that the client has the same bare jid as the host, i.e. + // client's full JID starts with host's bare jid. Comparison is case + // insensitive. + if (!StartsWithASCII(remote_jid, local_jid_prefix_, false)) { + LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; + return NULL; + } + + // TODO(sergeyu): V2 authenticator is not finished yet. Enable it + // here when it is finished. crbug.com/105214 + // + // if (V2Authenticator::IsEkeMessage(first_message)) { + // return V2Authenticator::CreateForHost( + // local_cert_, local_private_key_.get(), shared_secret_); + // } + + // TODO(sergeyu): Old clients still use V1 auth protocol. Remove + // this once we are done migrating to V2. + return new V1HostAuthenticator(local_cert_, local_private_key_.get(), + shared_secret_, remote_jid); +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/me2me_host_authenticator_factory.h b/remoting/protocol/me2me_host_authenticator_factory.h new file mode 100644 index 0000000..0a5114b --- /dev/null +++ b/remoting/protocol/me2me_host_authenticator_factory.h @@ -0,0 +1,48 @@ +// Copyright (c) 2012 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. + +#ifndef REMOTING_PROTOCOL_ME2ME_HOST_AUTHENTICATOR_FACTORY_H_ +#define REMOTING_PROTOCOL_ME2ME_HOST_AUTHENTICATOR_FACTORY_H_ + +#include <string> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "remoting/protocol/authenticator.h" + +namespace crypto { +class RSAPrivateKey; +} // namespace crypto + +namespace remoting { +namespace protocol { + +class Me2MeHostAuthenticatorFactory : public AuthenticatorFactory { + public: + // Doesn't take ownership of |local_private_key|. + Me2MeHostAuthenticatorFactory(const std::string& local_jid, + const std::string& local_cert, + const crypto::RSAPrivateKey* local_private_key, + const std::string& shared_secret); + virtual ~Me2MeHostAuthenticatorFactory(); + + // AuthenticatorFactory interface. + virtual Authenticator* CreateAuthenticator( + const std::string& remote_jid, + const buzz::XmlElement* first_message) OVERRIDE; + + private: + std::string local_jid_prefix_; + std::string local_cert_; + scoped_ptr<crypto::RSAPrivateKey> local_private_key_; + std::string shared_secret_; + + DISALLOW_COPY_AND_ASSIGN(Me2MeHostAuthenticatorFactory); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_ME2ME_HOST_AUTHENTICATOR_FACTORY_H_ diff --git a/remoting/protocol/v2_authenticator.h b/remoting/protocol/v2_authenticator.h index 7c4a530..3dc1cde 100644 --- a/remoting/protocol/v2_authenticator.h +++ b/remoting/protocol/v2_authenticator.h @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. -#ifndef REMOTING_PROTOCOL_EKE_AUTHENTICATOR_H_ -#define REMOTING_PROTOCOL_EKE_AUTHENTICATOR_H_ +#ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ +#define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ #include <string> #include <queue> @@ -70,8 +70,8 @@ class V2HostAuthenticatorFactory : public AuthenticatorFactory { public: // Doesn't take ownership of |local_private_key|. V2HostAuthenticatorFactory(const std::string& local_cert, - const crypto::RSAPrivateKey* local_private_key, - const std::string& shared_secret); + const crypto::RSAPrivateKey* local_private_key, + const std::string& shared_secret); virtual ~V2HostAuthenticatorFactory(); // AuthenticatorFactory interface. @@ -90,4 +90,4 @@ class V2HostAuthenticatorFactory : public AuthenticatorFactory { } // namespace protocol } // namespace remoting -#endif // REMOTING_PROTOCOL_EKE_AUTHENTICATOR_H_ +#endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 891f61c..56ce7b4 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -785,6 +785,8 @@ 'protocol/jingle_stream_connector.h', 'protocol/key_event_tracker.cc', 'protocol/key_event_tracker.h', + 'protocol/me2me_host_authenticator_factory.cc', + 'protocol/me2me_host_authenticator_factory.h', 'protocol/message_decoder.cc', 'protocol/message_decoder.h', 'protocol/message_reader.cc', |