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

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

Issue 1770923002: Remove dependency on V2Authenticator from ThirdParty and pairing authenticators. (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
(...skipping 24 matching lines...) Expand all
35 token_fetcher_(std::move(token_fetcher)), 35 token_fetcher_(std::move(token_fetcher)),
36 method_set_by_host_(false), 36 method_set_by_host_(false),
37 weak_factory_(this) { 37 weak_factory_(this) {
38 DCHECK(!methods.empty()); 38 DCHECK(!methods.empty());
39 for (std::vector<AuthenticationMethod>::const_iterator it = methods.begin(); 39 for (std::vector<AuthenticationMethod>::const_iterator it = methods.begin();
40 it != methods.end(); ++it) { 40 it != methods.end(); ++it) {
41 AddMethod(*it); 41 AddMethod(*it);
42 } 42 }
43 } 43 }
44 44
45 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() { 45 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() {}
46 }
47 46
48 void NegotiatingClientAuthenticator::ProcessMessage( 47 void NegotiatingClientAuthenticator::ProcessMessage(
49 const buzz::XmlElement* message, 48 const buzz::XmlElement* message,
50 const base::Closure& resume_callback) { 49 const base::Closure& resume_callback) {
51 DCHECK_EQ(state(), WAITING_MESSAGE); 50 DCHECK_EQ(state(), WAITING_MESSAGE);
52 51
53 std::string method_attr = message->Attr(kMethodAttributeQName); 52 std::string method_attr = message->Attr(kMethodAttributeQName);
54 AuthenticationMethod method = ParseAuthenticationMethodString(method_attr); 53 AuthenticationMethod method = ParseAuthenticationMethodString(method_attr);
55 54
56 // The host picked a method different from the one the client had selected. 55 // The host picked a method different from the one the client had selected.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod( 112 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod(
114 Authenticator::State preferred_initial_state, 113 Authenticator::State preferred_initial_state,
115 const base::Closure& resume_callback) { 114 const base::Closure& resume_callback) {
116 DCHECK(current_method_ != AuthenticationMethod::INVALID); 115 DCHECK(current_method_ != AuthenticationMethod::INVALID);
117 if (current_method_ == AuthenticationMethod::THIRD_PARTY) { 116 if (current_method_ == AuthenticationMethod::THIRD_PARTY) {
118 // |ThirdPartyClientAuthenticator| takes ownership of |token_fetcher_|. 117 // |ThirdPartyClientAuthenticator| takes ownership of |token_fetcher_|.
119 // The authentication method negotiation logic should guarantee that only 118 // The authentication method negotiation logic should guarantee that only
120 // one |ThirdPartyClientAuthenticator| will need to be created per session. 119 // one |ThirdPartyClientAuthenticator| will need to be created per session.
121 DCHECK(token_fetcher_); 120 DCHECK(token_fetcher_);
122 current_authenticator_.reset(new ThirdPartyClientAuthenticator( 121 current_authenticator_.reset(new ThirdPartyClientAuthenticator(
122 base::Bind(&V2Authenticator::CreateForClient),
123 std::move(token_fetcher_))); 123 std::move(token_fetcher_)));
124 resume_callback.Run(); 124 resume_callback.Run();
125 } else { 125 } else {
126 DCHECK(current_method_ == 126 DCHECK(current_method_ ==
127 AuthenticationMethod::SPAKE2_SHARED_SECRET_PLAIN || 127 AuthenticationMethod::SPAKE2_SHARED_SECRET_PLAIN ||
128 current_method_ == AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC || 128 current_method_ == AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC ||
129 current_method_ == AuthenticationMethod::SPAKE2_PAIR); 129 current_method_ == AuthenticationMethod::SPAKE2_PAIR);
130 bool pairing_supported = 130 bool pairing_supported =
131 (current_method_ == AuthenticationMethod::SPAKE2_PAIR); 131 (current_method_ == AuthenticationMethod::SPAKE2_PAIR);
132 SecretFetchedCallback callback = base::Bind( 132 SecretFetchedCallback callback = base::Bind(
133 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret, 133 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret,
134 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback); 134 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback);
135 fetch_secret_callback_.Run(pairing_supported, callback); 135 fetch_secret_callback_.Run(pairing_supported, callback);
136 } 136 }
137 } 137 }
138 138
139 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() { 139 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() {
140 if (!client_pairing_id_.empty() && !shared_secret_.empty() && 140 if (!client_pairing_id_.empty() && !shared_secret_.empty() &&
141 std::find(methods_.begin(), methods_.end(), 141 std::find(methods_.begin(), methods_.end(),
142 AuthenticationMethod::SPAKE2_PAIR) != methods_.end()) { 142 AuthenticationMethod::SPAKE2_PAIR) != methods_.end()) {
143 // If the client specified a pairing id and shared secret, then create a 143 // If the client specified a pairing id and shared secret, then create a
144 // PairingAuthenticator. 144 // PairingAuthenticator.
145 current_authenticator_.reset(new PairingClientAuthenticator( 145 current_authenticator_.reset(new PairingClientAuthenticator(
146 client_pairing_id_, shared_secret_, fetch_secret_callback_, 146 client_pairing_id_, shared_secret_,
147 base::Bind(&V2Authenticator::CreateForClient), fetch_secret_callback_,
147 authentication_tag_)); 148 authentication_tag_));
148 current_method_ = AuthenticationMethod::SPAKE2_PAIR; 149 current_method_ = AuthenticationMethod::SPAKE2_PAIR;
149 } 150 }
150 } 151 }
151 152
152 void NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret( 153 void NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret(
153 Authenticator::State initial_state, 154 Authenticator::State initial_state,
154 const base::Closure& resume_callback, 155 const base::Closure& resume_callback,
155 const std::string& shared_secret) { 156 const std::string& shared_secret) {
156 current_authenticator_ = V2Authenticator::CreateForClient( 157 current_authenticator_ = V2Authenticator::CreateForClient(
157 ApplySharedSecretHashFunction( 158 ApplySharedSecretHashFunction(
158 GetHashFunctionForAuthenticationMethod(current_method_), 159 GetHashFunctionForAuthenticationMethod(current_method_),
159 authentication_tag_, shared_secret), 160 authentication_tag_, shared_secret),
160 initial_state); 161 initial_state);
161 resume_callback.Run(); 162 resume_callback.Run();
162 } 163 }
163 164
164 } // namespace protocol 165 } // namespace protocol
165 } // namespace remoting 166 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_authenticator_base.cc ('k') | remoting/protocol/negotiating_host_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698