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

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

Issue 15685008: Show a 'remember me' checkbox in the web-app when connecting to a host that supports pairing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 7 years, 7 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 | Annotate | Revision Log
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 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // |ThirdPartyClientAuthenticator| takes ownership of |token_fetcher_|. 118 // |ThirdPartyClientAuthenticator| takes ownership of |token_fetcher_|.
119 // The authentication method negotiation logic should guarantee that only 119 // The authentication method negotiation logic should guarantee that only
120 // one |ThirdPartyClientAuthenticator| will need to be created per session. 120 // one |ThirdPartyClientAuthenticator| will need to be created per session.
121 DCHECK(token_fetcher_); 121 DCHECK(token_fetcher_);
122 current_authenticator_.reset(new ThirdPartyClientAuthenticator( 122 current_authenticator_.reset(new ThirdPartyClientAuthenticator(
123 token_fetcher_.Pass())); 123 token_fetcher_.Pass()));
124 resume_callback.Run(); 124 resume_callback.Run();
125 } else { 125 } else {
126 DCHECK(current_method_.type() == AuthenticationMethod::SPAKE2 || 126 DCHECK(current_method_.type() == AuthenticationMethod::SPAKE2 ||
127 current_method_.type() == AuthenticationMethod::SPAKE2_PAIR); 127 current_method_.type() == AuthenticationMethod::SPAKE2_PAIR);
128 // TODO(jamiewalch): Add a bool parameter to the fetch secret callback to 128 bool pairing_supported =
129 // indicate whether or not to show the "remember me" checkbox. Set it to 129 (current_method_.type() == AuthenticationMethod::SPAKE2_PAIR);
130 // (current_method_.type() == AuthenticationMethod::SPAKE2_PAIR). 130 SecretFetchedCallback callback = base::Bind(
131 fetch_secret_callback_.Run(base::Bind(
132 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret, 131 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret,
133 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback)); 132 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback);
133 fetch_secret_callback_.Run(pairing_supported, callback);
134 } 134 }
135 } 135 }
136 136
137 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() { 137 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() {
138 if (!client_pairing_id_.empty() && !shared_secret_.empty() && 138 if (!client_pairing_id_.empty() && !shared_secret_.empty() &&
139 std::find(methods_.begin(), methods_.end(), 139 std::find(methods_.begin(), methods_.end(),
140 AuthenticationMethod::Spake2Pair()) != methods_.end()) { 140 AuthenticationMethod::Spake2Pair()) != methods_.end()) {
141 // If the client specified a pairing id and shared secret, then create a 141 // If the client specified a pairing id and shared secret, then create a
142 // PairingAuthenticator. 142 // PairingAuthenticator.
143 current_authenticator_.reset(new PairingClientAuthenticator( 143 current_authenticator_.reset(new PairingClientAuthenticator(
144 client_pairing_id_, shared_secret_, fetch_secret_callback_, 144 client_pairing_id_, shared_secret_, fetch_secret_callback_,
145 authentication_tag_)); 145 authentication_tag_));
146 current_method_ = AuthenticationMethod::Spake2Pair(); 146 current_method_ = AuthenticationMethod::Spake2Pair();
147 } 147 }
148 } 148 }
149 149
150 void NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret( 150 void NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret(
151 Authenticator::State initial_state, 151 Authenticator::State initial_state,
152 const base::Closure& resume_callback, 152 const base::Closure& resume_callback,
153 const std::string& shared_secret) { 153 const std::string& shared_secret) {
154 current_authenticator_ = V2Authenticator::CreateForClient( 154 current_authenticator_ = V2Authenticator::CreateForClient(
155 AuthenticationMethod::ApplyHashFunction( 155 AuthenticationMethod::ApplyHashFunction(
156 current_method_.hash_function(), authentication_tag_, shared_secret), 156 current_method_.hash_function(), authentication_tag_, shared_secret),
157 initial_state); 157 initial_state);
158 resume_callback.Run(); 158 resume_callback.Run();
159 } 159 }
160 160
161 } // namespace protocol 161 } // namespace protocol
162 } // namespace remoting 162 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_authenticator_unittest.cc ('k') | remoting/protocol/pairing_client_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698