From 15e344eef7cb9c490b62360570eb2109d982bdc9 Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Thu, 29 Dec 2011 05:47:30 +0000 Subject: Add HybridAuthenticatorFactory. BUG=105214 Review URL: http://codereview.chromium.org/8974019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115953 0039d316-1c4b-4281-b951-d872f2087c98 --- .../protocol/it2me_host_authenticator_factory.cc | 40 ++++++++++++++++++ .../protocol/it2me_host_authenticator_factory.h | 48 ++++++++++++++++++++++ remoting/remoting.gyp | 2 + 3 files changed, 90 insertions(+) create mode 100644 remoting/protocol/it2me_host_authenticator_factory.cc create mode 100644 remoting/protocol/it2me_host_authenticator_factory.h (limited to 'remoting') diff --git a/remoting/protocol/it2me_host_authenticator_factory.cc b/remoting/protocol/it2me_host_authenticator_factory.cc new file mode 100644 index 0000000..e3e74e7 --- /dev/null +++ b/remoting/protocol/it2me_host_authenticator_factory.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2011 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/it2me_host_authenticator_factory.h" + +#include "base/logging.h" +#include "crypto/rsa_private_key.h" +#include "remoting/protocol/v1_authenticator.h" +#include "remoting/protocol/v2_authenticator.h" + +namespace remoting { +namespace protocol { + +It2MeHostAuthenticatorFactory::It2MeHostAuthenticatorFactory( + 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) { +} + +It2MeHostAuthenticatorFactory::~It2MeHostAuthenticatorFactory() { +} + +Authenticator* It2MeHostAuthenticatorFactory::CreateAuthenticator( + const std::string& remote_jid, + const buzz::XmlElement* first_message) { + if (V2Authenticator::IsEkeMessage(first_message)) { + return V2Authenticator::CreateForHost( + local_cert_, local_private_key_.get(), shared_secret_); + } + + return new V1HostAuthenticator(local_cert_, local_private_key_.get(), + shared_secret_, remote_jid); +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/it2me_host_authenticator_factory.h b/remoting/protocol/it2me_host_authenticator_factory.h new file mode 100644 index 0000000..19266e8 --- /dev/null +++ b/remoting/protocol/it2me_host_authenticator_factory.h @@ -0,0 +1,48 @@ +// Copyright (c) 2011 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_IT2ME_HOST_AUTHENTICATOR_FACTORY_H_ +#define REMOTING_PROTOCOL_IT2ME_HOST_AUTHENTICATOR_FACTORY_H_ + +#include + +#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 { + +// It2MeHostAuthenticatorFactory implements AuthenticatorFactory and +// understands both the V2 and legacy V1 authentication mechanisms. +class It2MeHostAuthenticatorFactory : public AuthenticatorFactory { + public: + It2MeHostAuthenticatorFactory( + const std::string& local_cert, + const crypto::RSAPrivateKey* local_private_key, + const std::string& shared_secret); + virtual ~It2MeHostAuthenticatorFactory(); + + // AuthenticatorFactory interface. + virtual Authenticator* CreateAuthenticator( + const std::string& remote_jid, + const buzz::XmlElement* first_message) OVERRIDE; + + private: + std::string local_cert_; + scoped_ptr local_private_key_; + std::string shared_secret_; + + DISALLOW_COPY_AND_ASSIGN(It2MeHostAuthenticatorFactory); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_IT2ME_HOST_AUTHENTICATOR_FACTORY_H_ diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 2735e64..5edadf1 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -768,6 +768,8 @@ 'protocol/host_event_dispatcher.h', 'protocol/host_stub.h', 'protocol/input_stub.h', + 'protocol/it2me_host_authenticator_factory.cc', + 'protocol/it2me_host_authenticator_factory.h', 'protocol/jingle_channel_connector.h', 'protocol/jingle_datagram_connector.cc', 'protocol/jingle_datagram_connector.h', -- cgit v1.1