Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: remoting/protocol/negotiating_client_authenticator.cc

Issue 1794433002: Use ClientAuthenticationConfig in PairingClientAuthenticator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/negotiating_client_authenticator.h" 5 #include "remoting/protocol/negotiating_client_authenticator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <sstream> 8 #include <sstream>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "remoting/protocol/auth_util.h" 15 #include "remoting/protocol/auth_util.h"
16 #include "remoting/protocol/channel_authenticator.h" 16 #include "remoting/protocol/channel_authenticator.h"
17 #include "remoting/protocol/pairing_client_authenticator.h" 17 #include "remoting/protocol/pairing_client_authenticator.h"
18 #include "remoting/protocol/spake2_authenticator.h" 18 #include "remoting/protocol/spake2_authenticator.h"
19 #include "remoting/protocol/v2_authenticator.h" 19 #include "remoting/protocol/v2_authenticator.h"
20 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 20 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
21 21
22 namespace remoting { 22 namespace remoting {
23 namespace protocol { 23 namespace protocol {
24 24
25 ClientAuthenticationConfig::ClientAuthenticationConfig() {}
26 ClientAuthenticationConfig::~ClientAuthenticationConfig() {}
27
28 NegotiatingClientAuthenticator::NegotiatingClientAuthenticator( 25 NegotiatingClientAuthenticator::NegotiatingClientAuthenticator(
29 const std::string& local_id, 26 const std::string& local_id,
30 const std::string& remote_id, 27 const std::string& remote_id,
31 const ClientAuthenticationConfig& config) 28 const ClientAuthenticationConfig& config)
32 : NegotiatingAuthenticatorBase(MESSAGE_READY), 29 : NegotiatingAuthenticatorBase(MESSAGE_READY),
33 local_id_(local_id), 30 local_id_(local_id),
34 remote_id_(remote_id), 31 remote_id_(remote_id),
35 config_(config), 32 config_(config),
36 weak_factory_(this) { 33 weak_factory_(this) {
37 if (!config_.fetch_third_party_token_callback.is_null()) { 34 if (!config_.fetch_third_party_token_callback.is_null()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 141 }
145 } 142 }
146 143
147 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() { 144 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() {
148 if (!config_.pairing_client_id.empty() && !config_.pairing_secret.empty() && 145 if (!config_.pairing_client_id.empty() && !config_.pairing_secret.empty() &&
149 std::find(methods_.begin(), methods_.end(), Method::PAIRED_SPAKE2_P224) != 146 std::find(methods_.begin(), methods_.end(), Method::PAIRED_SPAKE2_P224) !=
150 methods_.end()) { 147 methods_.end()) {
151 // If the client specified a pairing id and shared secret, then create a 148 // If the client specified a pairing id and shared secret, then create a
152 // PairingAuthenticator. 149 // PairingAuthenticator.
153 current_authenticator_.reset(new PairingClientAuthenticator( 150 current_authenticator_.reset(new PairingClientAuthenticator(
154 config_.pairing_client_id, config_.pairing_secret, 151 config_, base::Bind(&V2Authenticator::CreateForClient)));
155 base::Bind(&V2Authenticator::CreateForClient),
156 config_.fetch_secret_callback, config_.host_id));
157 current_method_ = Method::PAIRED_SPAKE2_P224; 152 current_method_ = Method::PAIRED_SPAKE2_P224;
158 } 153 }
159 } 154 }
160 155
161 void NegotiatingClientAuthenticator::CreateSharedSecretAuthenticator( 156 void NegotiatingClientAuthenticator::CreateSharedSecretAuthenticator(
162 Authenticator::State initial_state, 157 Authenticator::State initial_state,
163 const base::Closure& resume_callback, 158 const base::Closure& resume_callback,
164 const std::string& shared_secret) { 159 const std::string& shared_secret) {
165 std::string shared_secret_hash = 160 std::string shared_secret_hash =
166 (current_method_ == Method::SHARED_SECRET_PLAIN_SPAKE2_P224) 161 (current_method_ == Method::SHARED_SECRET_PLAIN_SPAKE2_P224)
167 ? shared_secret 162 ? shared_secret
168 : GetSharedSecretHash(config_.host_id, shared_secret); 163 : GetSharedSecretHash(config_.host_id, shared_secret);
169 164
170 if (current_method_ == Method::SHARED_SECRET_SPAKE2_CURVE25519) { 165 if (current_method_ == Method::SHARED_SECRET_SPAKE2_CURVE25519) {
171 current_authenticator_ = Spake2Authenticator::CreateForClient( 166 current_authenticator_ = Spake2Authenticator::CreateForClient(
172 local_id_, remote_id_, shared_secret_hash, initial_state); 167 local_id_, remote_id_, shared_secret_hash, initial_state);
173 } else { 168 } else {
174 current_authenticator_ = 169 current_authenticator_ =
175 V2Authenticator::CreateForClient(shared_secret_hash, initial_state); 170 V2Authenticator::CreateForClient(shared_secret_hash, initial_state);
176 } 171 }
177 resume_callback.Run(); 172 resume_callback.Run();
178 } 173 }
179 174
180 } // namespace protocol 175 } // namespace protocol
181 } // namespace remoting 176 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_client_authenticator.h ('k') | remoting/protocol/pairing_client_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698