diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-29 05:47:30 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-29 05:47:30 +0000 |
commit | 15e344eef7cb9c490b62360570eb2109d982bdc9 (patch) | |
tree | 1c967c0bb02eb2fd938b4c1ae635ceb95cbaf06b /remoting | |
parent | b94c47c1bb627694227f0fac56eb3b36fa19933b (diff) | |
download | chromium_src-15e344eef7cb9c490b62360570eb2109d982bdc9.zip chromium_src-15e344eef7cb9c490b62360570eb2109d982bdc9.tar.gz chromium_src-15e344eef7cb9c490b62360570eb2109d982bdc9.tar.bz2 |
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
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/protocol/it2me_host_authenticator_factory.cc | 40 | ||||
-rw-r--r-- | remoting/protocol/it2me_host_authenticator_factory.h | 48 | ||||
-rw-r--r-- | remoting/remoting.gyp | 2 |
3 files changed, 90 insertions, 0 deletions
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 <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 { + +// 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<crypto::RSAPrivateKey> 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', |