diff options
author | sergeyu <sergeyu@chromium.org> | 2016-03-12 01:12:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-12 09:13:50 +0000 |
commit | 64adc27d798830194401562945398dd396e652db (patch) | |
tree | d2ed336be3327744e57bb132bdcb07d4167e6beb /remoting | |
parent | a15e4f0ac7ec67afd93957fa56f1ef027ec3775a (diff) | |
download | chromium_src-64adc27d798830194401562945398dd396e652db.zip chromium_src-64adc27d798830194401562945398dd396e652db.tar.gz chromium_src-64adc27d798830194401562945398dd396e652db.tar.bz2 |
Use ClientAuthenticationConfig in PairingClientAuthenticator
Moved ClientAuthenticationConfig to a separate file and now it's used
in PairingClientAuthenticator.
BUG=593123
Review URL: https://codereview.chromium.org/1794433002
Cr-Commit-Position: refs/heads/master@{#380872}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/chromoting_client.cc | 1 | ||||
-rw-r--r-- | remoting/client/chromoting_client.h | 2 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.cc | 2 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.h | 3 | ||||
-rw-r--r-- | remoting/protocol/authenticator.h | 28 | ||||
-rw-r--r-- | remoting/protocol/client_authentication_config.cc | 14 | ||||
-rw-r--r-- | remoting/protocol/client_authentication_config.h | 62 | ||||
-rw-r--r-- | remoting/protocol/negotiating_client_authenticator.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/negotiating_client_authenticator.h | 19 | ||||
-rw-r--r-- | remoting/protocol/pairing_client_authenticator.cc | 23 | ||||
-rw-r--r-- | remoting/protocol/pairing_client_authenticator.h | 19 | ||||
-rw-r--r-- | remoting/protocol/rejecting_authenticator.cc | 1 | ||||
-rw-r--r-- | remoting/protocol/spake2_authenticator.h | 1 | ||||
-rw-r--r-- | remoting/protocol/third_party_client_authenticator.h | 1 | ||||
-rw-r--r-- | remoting/protocol/v2_authenticator.h | 1 | ||||
-rw-r--r-- | remoting/remoting_srcs.gypi | 2 | ||||
-rw-r--r-- | remoting/test/protocol_perftest.cc | 2 |
17 files changed, 107 insertions, 81 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 7e51042..1f7165a 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -16,6 +16,7 @@ #include "remoting/protocol/host_stub.h" #include "remoting/protocol/ice_connection_to_host.h" #include "remoting/protocol/jingle_session_manager.h" +#include "remoting/protocol/negotiating_client_authenticator.h" #include "remoting/protocol/session_config.h" #include "remoting/protocol/transport_context.h" #include "remoting/protocol/video_renderer.h" diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h index 6563720..467b0e1 100644 --- a/remoting/client/chromoting_client.h +++ b/remoting/client/chromoting_client.h @@ -12,11 +12,11 @@ #include "base/callback.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/client_stub.h" #include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/connection_to_host.h" #include "remoting/protocol/input_stub.h" -#include "remoting/protocol/negotiating_client_authenticator.h" #include "remoting/protocol/performance_tracker.h" #include "remoting/protocol/session_config.h" #include "remoting/protocol/video_stub.h" diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc index 00066ed..8430afc 100644 --- a/remoting/client/jni/chromoting_jni_instance.cc +++ b/remoting/client/jni/chromoting_jni_instance.cc @@ -24,8 +24,8 @@ #include "remoting/client/software_video_renderer.h" #include "remoting/protocol/chromium_port_allocator_factory.h" #include "remoting/protocol/chromium_socket_factory.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/host_stub.h" -#include "remoting/protocol/negotiating_client_authenticator.h" #include "remoting/protocol/network_settings.h" #include "remoting/protocol/performance_tracker.h" #include "remoting/protocol/transport_context.h" diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h index 7b91854..49c92c4 100644 --- a/remoting/client/plugin/chromoting_instance.h +++ b/remoting/client/plugin/chromoting_instance.h @@ -29,15 +29,14 @@ #include "remoting/client/plugin/pepper_video_renderer.h" #include "remoting/client/touch_input_scaler.h" #include "remoting/proto/event.pb.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/client_stub.h" #include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/connection_to_host.h" #include "remoting/protocol/cursor_shape_stub.h" #include "remoting/protocol/input_event_tracker.h" #include "remoting/protocol/mouse_input_filter.h" -#include "remoting/protocol/negotiating_client_authenticator.h" #include "remoting/protocol/performance_tracker.h" -#include "remoting/protocol/third_party_client_authenticator.h" namespace base { class DictionaryValue; diff --git a/remoting/protocol/authenticator.h b/remoting/protocol/authenticator.h index 8b89111..f897101 100644 --- a/remoting/protocol/authenticator.h +++ b/remoting/protocol/authenticator.h @@ -7,7 +7,7 @@ #include <string> -#include "base/callback.h" +#include "base/callback_forward.h" #include "base/memory/scoped_ptr.h" namespace buzz { @@ -20,32 +20,6 @@ namespace protocol { class Authenticator; class ChannelAuthenticator; -typedef base::Callback<void(const std::string& secret)> SecretFetchedCallback; -typedef base::Callback<void( - bool pairing_supported, - const SecretFetchedCallback& secret_fetched_callback)> FetchSecretCallback; - -// Callback passed to |FetchTokenCallback|, and called once the client -// authentication finishes. |token| is an opaque string that should be sent -// directly to the host. |shared_secret| should be used by the client to -// create a V2Authenticator. In case of failure, the callback is called with -// an empty |token| and |shared_secret|. -typedef base::Callback<void(const std::string& token, - const std::string& shared_secret)> - ThirdPartyTokenFetchedCallback; - -// Fetches a third party token from |token_url|. |host_public_key| is sent to -// the server so it can later authenticate the host. |scope| is a string with a -// space-separated list of attributes for this connection (e.g. -// "hostjid:abc@example.com/123 clientjid:def@example.org/456". -// |token_fetched_callback| is called when the client authentication ends, on -// the same thread on which FetchThirdPartyTokenCallback was originally called. -typedef base::Callback<void( - const std::string& token_url, - const std::string& scope, - const ThirdPartyTokenFetchedCallback& token_fetched_callback)> - FetchThirdPartyTokenCallback; - // Authenticator is an abstract interface for authentication protocol // implementations. Different implementations of this interface may be used on // each side of the connection depending of type of the auth protocol. Client diff --git a/remoting/protocol/client_authentication_config.cc b/remoting/protocol/client_authentication_config.cc new file mode 100644 index 0000000..eec3c40 --- /dev/null +++ b/remoting/protocol/client_authentication_config.cc @@ -0,0 +1,14 @@ +// Copyright 2016 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/client_authentication_config.h" + +namespace remoting { +namespace protocol { + +ClientAuthenticationConfig::ClientAuthenticationConfig() {} +ClientAuthenticationConfig::~ClientAuthenticationConfig() {} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/client_authentication_config.h b/remoting/protocol/client_authentication_config.h new file mode 100644 index 0000000..92a1cb7 --- /dev/null +++ b/remoting/protocol/client_authentication_config.h @@ -0,0 +1,62 @@ +// Copyright 2016 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_CLIENT_AUTHENTICATION_CONFIG_H_ +#define REMOTING_PROTOCOL_CLIENT_AUTHENTICATION_CONFIG_H_ + +#include <string> + +#include "base/callback.h" + +namespace remoting { +namespace protocol { + +typedef base::Callback<void(const std::string& secret)> SecretFetchedCallback; +typedef base::Callback<void( + bool pairing_supported, + const SecretFetchedCallback& secret_fetched_callback)> FetchSecretCallback; + +// Callback passed to |FetchTokenCallback|, and called once the client +// authentication finishes. |token| is an opaque string that should be sent +// directly to the host. |shared_secret| should be used by the client to +// create a V2Authenticator. In case of failure, the callback is called with +// an empty |token| and |shared_secret|. +typedef base::Callback<void(const std::string& token, + const std::string& shared_secret)> + ThirdPartyTokenFetchedCallback; + +// Fetches a third party token from |token_url|. |host_public_key| is sent to +// the server so it can later authenticate the host. |scope| is a string with a +// space-separated list of attributes for this connection (e.g. +// "hostjid:abc@example.com/123 clientjid:def@example.org/456". +// |token_fetched_callback| is called when the client authentication ends, on +// the same thread on which FetchThirdPartyTokenCallback was originally called. +typedef base::Callback<void( + const std::string& token_url, + const std::string& scope, + const ThirdPartyTokenFetchedCallback& token_fetched_callback)> + FetchThirdPartyTokenCallback; + +struct ClientAuthenticationConfig { + ClientAuthenticationConfig(); + ~ClientAuthenticationConfig(); + + // Used for all authenticators. + std::string host_id; + + // Used for pairing authenticators + std::string pairing_client_id; + std::string pairing_secret; + + // Used for shared secret authenticators. + FetchSecretCallback fetch_secret_callback; + + // Used for third party authenticators. + FetchThirdPartyTokenCallback fetch_third_party_token_callback; +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_CLIENT_AUTHENTICATION_CONFIG_H_ diff --git a/remoting/protocol/negotiating_client_authenticator.cc b/remoting/protocol/negotiating_client_authenticator.cc index f26b6ef..d243f86 100644 --- a/remoting/protocol/negotiating_client_authenticator.cc +++ b/remoting/protocol/negotiating_client_authenticator.cc @@ -22,9 +22,6 @@ namespace remoting { namespace protocol { -ClientAuthenticationConfig::ClientAuthenticationConfig() {} -ClientAuthenticationConfig::~ClientAuthenticationConfig() {} - NegotiatingClientAuthenticator::NegotiatingClientAuthenticator( const std::string& local_id, const std::string& remote_id, @@ -151,9 +148,7 @@ void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() { // If the client specified a pairing id and shared secret, then create a // PairingAuthenticator. current_authenticator_.reset(new PairingClientAuthenticator( - config_.pairing_client_id, config_.pairing_secret, - base::Bind(&V2Authenticator::CreateForClient), - config_.fetch_secret_callback, config_.host_id)); + config_, base::Bind(&V2Authenticator::CreateForClient))); current_method_ = Method::PAIRED_SPAKE2_P224; } } diff --git a/remoting/protocol/negotiating_client_authenticator.h b/remoting/protocol/negotiating_client_authenticator.h index 9a1fe1e..855e64a 100644 --- a/remoting/protocol/negotiating_client_authenticator.h +++ b/remoting/protocol/negotiating_client_authenticator.h @@ -12,30 +12,13 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "remoting/protocol/authenticator.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/negotiating_authenticator_base.h" #include "remoting/protocol/third_party_client_authenticator.h" namespace remoting { namespace protocol { -struct ClientAuthenticationConfig { - ClientAuthenticationConfig(); - ~ClientAuthenticationConfig(); - - // Used for all authenticators. - std::string host_id; - - // Used for pairing authenticators - std::string pairing_client_id; - std::string pairing_secret; - - // Used for shared secret authenticators. - FetchSecretCallback fetch_secret_callback; - - // Used for third party authenticators. - FetchThirdPartyTokenCallback fetch_third_party_token_callback; -}; - // Client-side implementation of NegotiatingAuthenticatorBase. // See comments in negotiating_authenticator_base.h for a general explanation. class NegotiatingClientAuthenticator : public NegotiatingAuthenticatorBase { diff --git a/remoting/protocol/pairing_client_authenticator.cc b/remoting/protocol/pairing_client_authenticator.cc index c4e0b29..b70e0c6 100644 --- a/remoting/protocol/pairing_client_authenticator.cc +++ b/remoting/protocol/pairing_client_authenticator.cc @@ -15,19 +15,13 @@ namespace remoting { namespace protocol { PairingClientAuthenticator::PairingClientAuthenticator( - const std::string& client_id, - const std::string& paired_secret, - const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, - const FetchSecretCallback& fetch_pin_callback, - const std::string& host_id) - : client_id_(client_id), - paired_secret_(paired_secret), + const ClientAuthenticationConfig& client_auth_config, + const CreateBaseAuthenticatorCallback& create_base_authenticator_callback) + : client_auth_config_(client_auth_config), create_base_authenticator_callback_(create_base_authenticator_callback), - fetch_pin_callback_(fetch_pin_callback), - host_id_(host_id), weak_factory_(this) { - spake2_authenticator_ = - create_base_authenticator_callback_.Run(paired_secret_, MESSAGE_READY); + spake2_authenticator_ = create_base_authenticator_callback_.Run( + client_auth_config.pairing_secret, MESSAGE_READY); using_paired_secret_ = true; } @@ -44,7 +38,7 @@ void PairingClientAuthenticator::CreateSpakeAuthenticatorWithPin( const base::Closure& resume_callback) { DCHECK(!waiting_for_pin_); waiting_for_pin_ = true; - fetch_pin_callback_.Run( + client_auth_config_.fetch_secret_callback.Run( true, base::Bind(&PairingClientAuthenticator::OnPinFetched, weak_factory_.GetWeakPtr(), initial_state, resume_callback)); @@ -57,7 +51,8 @@ void PairingClientAuthenticator::AddPairingElements(buzz::XmlElement* message) { // the host will accept the client id or request that we fall back to the PIN. if (!sent_client_id_) { buzz::XmlElement* pairing_tag = new buzz::XmlElement(kPairingInfoTag); - pairing_tag->AddAttr(kClientIdAttribute, client_id_); + pairing_tag->AddAttr(kClientIdAttribute, + client_auth_config_.pairing_client_id); message->AddElement(pairing_tag); sent_client_id_ = true; } @@ -71,7 +66,7 @@ void PairingClientAuthenticator::OnPinFetched( DCHECK(!spake2_authenticator_); waiting_for_pin_ = false; spake2_authenticator_ = create_base_authenticator_callback_.Run( - GetSharedSecretHash(host_id_, pin), initial_state); + GetSharedSecretHash(client_auth_config_.host_id, pin), initial_state); resume_callback.Run(); } diff --git a/remoting/protocol/pairing_client_authenticator.h b/remoting/protocol/pairing_client_authenticator.h index ad93877..1404e35 100644 --- a/remoting/protocol/pairing_client_authenticator.h +++ b/remoting/protocol/pairing_client_authenticator.h @@ -7,6 +7,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/pairing_authenticator_base.h" namespace remoting { @@ -15,11 +16,9 @@ namespace protocol { class PairingClientAuthenticator : public PairingAuthenticatorBase { public: PairingClientAuthenticator( - const std::string& client_id, - const std::string& paired_secret, - const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, - const FetchSecretCallback& fetch_pin_callback, - const std::string& host_id); + const ClientAuthenticationConfig& client_auth_config, + const CreateBaseAuthenticatorCallback& + create_base_authenticator_callback); ~PairingClientAuthenticator() override; // Authenticator interface. @@ -36,13 +35,11 @@ class PairingClientAuthenticator : public PairingAuthenticatorBase { const base::Closure& resume_callback, const std::string& pin); - // Protocol state. - bool sent_client_id_ = false; - std::string client_id_; - std::string paired_secret_; + ClientAuthenticationConfig client_auth_config_; CreateBaseAuthenticatorCallback create_base_authenticator_callback_; - FetchSecretCallback fetch_pin_callback_; - std::string host_id_; + + // Set to true after client_id is sent to the host. + bool sent_client_id_ = false; // Set to true if a PIN-based authenticator has been requested but has not // yet been set. diff --git a/remoting/protocol/rejecting_authenticator.cc b/remoting/protocol/rejecting_authenticator.cc index b82cfc4..80a07a0 100644 --- a/remoting/protocol/rejecting_authenticator.cc +++ b/remoting/protocol/rejecting_authenticator.cc @@ -4,6 +4,7 @@ #include "remoting/protocol/rejecting_authenticator.h" +#include "base/callback.h" #include "base/logging.h" #include "remoting/protocol/channel_authenticator.h" #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" diff --git a/remoting/protocol/spake2_authenticator.h b/remoting/protocol/spake2_authenticator.h index 15456e0..50cdef0 100644 --- a/remoting/protocol/spake2_authenticator.h +++ b/remoting/protocol/spake2_authenticator.h @@ -11,6 +11,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" +#include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "remoting/protocol/authenticator.h" diff --git a/remoting/protocol/third_party_client_authenticator.h b/remoting/protocol/third_party_client_authenticator.h index ea94887..fa8b883 100644 --- a/remoting/protocol/third_party_client_authenticator.h +++ b/remoting/protocol/third_party_client_authenticator.h @@ -11,6 +11,7 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/third_party_authenticator_base.h" namespace remoting { diff --git a/remoting/protocol/v2_authenticator.h b/remoting/protocol/v2_authenticator.h index 77a72a5..770d86f 100644 --- a/remoting/protocol/v2_authenticator.h +++ b/remoting/protocol/v2_authenticator.h @@ -11,6 +11,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" +#include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "crypto/p224_spake.h" #include "remoting/protocol/authenticator.h" diff --git a/remoting/remoting_srcs.gypi b/remoting/remoting_srcs.gypi index 59a0559..7bc0682 100644 --- a/remoting/remoting_srcs.gypi +++ b/remoting/remoting_srcs.gypi @@ -80,6 +80,8 @@ 'protocol/authenticator.cc', 'protocol/authenticator.h', 'protocol/capability_names.h', + 'protocol/client_authentication_config.cc', + 'protocol/client_authentication_config.h', 'protocol/channel_authenticator.h', 'protocol/channel_dispatcher_base.cc', 'protocol/channel_dispatcher_base.h', diff --git a/remoting/test/protocol_perftest.cc b/remoting/test/protocol_perftest.cc index d8a9643..355a5af 100644 --- a/remoting/test/protocol_perftest.cc +++ b/remoting/test/protocol_perftest.cc @@ -29,10 +29,10 @@ #include "remoting/host/chromoting_host_context.h" #include "remoting/host/fake_desktop_environment.h" #include "remoting/protocol/auth_util.h" +#include "remoting/protocol/client_authentication_config.h" #include "remoting/protocol/frame_consumer.h" #include "remoting/protocol/jingle_session_manager.h" #include "remoting/protocol/me2me_host_authenticator_factory.h" -#include "remoting/protocol/negotiating_client_authenticator.h" #include "remoting/protocol/session_config.h" #include "remoting/protocol/transport_context.h" #include "remoting/protocol/video_frame_pump.h" |