Commit 21109574 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

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
parent 8e9e6d19
......@@ -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());
}
......
......@@ -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());
}
}
......
// 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
// 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_
// 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_
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment