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

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

Issue 1788943002: Revert of Move NegotiatingClientAuthentication creation to ChromotingClient. (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/v2_authenticator.h" 18 #include "remoting/protocol/v2_authenticator.h"
19 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 19 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
20 20
21 namespace remoting { 21 namespace remoting {
22 namespace protocol { 22 namespace protocol {
23 23
24 ClientAuthenticationConfig::ClientAuthenticationConfig() {}
25 ClientAuthenticationConfig::~ClientAuthenticationConfig() {}
26
27 NegotiatingClientAuthenticator::NegotiatingClientAuthenticator( 24 NegotiatingClientAuthenticator::NegotiatingClientAuthenticator(
28 const ClientAuthenticationConfig& config) 25 const std::string& client_pairing_id,
26 const std::string& shared_secret,
27 const std::string& authentication_tag,
28 const FetchSecretCallback& fetch_secret_callback,
29 const FetchThirdPartyTokenCallback& fetch_third_party_token_callback)
29 : NegotiatingAuthenticatorBase(MESSAGE_READY), 30 : NegotiatingAuthenticatorBase(MESSAGE_READY),
30 config_(config), 31 client_pairing_id_(client_pairing_id),
32 shared_secret_(shared_secret),
33 authentication_tag_(authentication_tag),
34 fetch_secret_callback_(fetch_secret_callback),
35 fetch_third_party_token_callback_(fetch_third_party_token_callback),
31 weak_factory_(this) { 36 weak_factory_(this) {
32 if (!config_.fetch_third_party_token_callback.is_null()) 37 if (!fetch_third_party_token_callback.is_null())
33 AddMethod(Method::THIRD_PARTY); 38 AddMethod(Method::THIRD_PARTY);
34 AddMethod(Method::SPAKE2_PAIR); 39 AddMethod(Method::SPAKE2_PAIR);
35 AddMethod(Method::SPAKE2_SHARED_SECRET_HMAC); 40 AddMethod(Method::SPAKE2_SHARED_SECRET_HMAC);
36 AddMethod(Method::SPAKE2_SHARED_SECRET_PLAIN); 41 AddMethod(Method::SPAKE2_SHARED_SECRET_PLAIN);
37 } 42 }
38 43
39 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() {} 44 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() {}
40 45
41 void NegotiatingClientAuthenticator::ProcessMessage( 46 void NegotiatingClientAuthenticator::ProcessMessage(
42 const buzz::XmlElement* message, 47 const buzz::XmlElement* message,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return GetNextMessageInternal(); 108 return GetNextMessageInternal();
104 } 109 }
105 110
106 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod( 111 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod(
107 Authenticator::State preferred_initial_state, 112 Authenticator::State preferred_initial_state,
108 const base::Closure& resume_callback) { 113 const base::Closure& resume_callback) {
109 DCHECK(current_method_ != Method::INVALID); 114 DCHECK(current_method_ != Method::INVALID);
110 if (current_method_ == Method::THIRD_PARTY) { 115 if (current_method_ == Method::THIRD_PARTY) {
111 current_authenticator_.reset(new ThirdPartyClientAuthenticator( 116 current_authenticator_.reset(new ThirdPartyClientAuthenticator(
112 base::Bind(&V2Authenticator::CreateForClient), 117 base::Bind(&V2Authenticator::CreateForClient),
113 config_.fetch_third_party_token_callback)); 118 fetch_third_party_token_callback_));
114 resume_callback.Run(); 119 resume_callback.Run();
115 } else { 120 } else {
116 DCHECK(current_method_ == Method::SPAKE2_SHARED_SECRET_PLAIN || 121 DCHECK(current_method_ == Method::SPAKE2_SHARED_SECRET_PLAIN ||
117 current_method_ == Method::SPAKE2_PAIR || 122 current_method_ == Method::SPAKE2_PAIR ||
118 current_method_ == Method::SPAKE2_SHARED_SECRET_HMAC); 123 current_method_ == Method::SPAKE2_SHARED_SECRET_HMAC);
119 bool pairing_supported = (current_method_ == Method::SPAKE2_PAIR); 124 bool pairing_supported = (current_method_ == Method::SPAKE2_PAIR);
120 SecretFetchedCallback callback = base::Bind( 125 SecretFetchedCallback callback = base::Bind(
121 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret, 126 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret,
122 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback); 127 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback);
123 config_.fetch_secret_callback.Run(pairing_supported, callback); 128 fetch_secret_callback_.Run(pairing_supported, callback);
124 } 129 }
125 } 130 }
126 131
127 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() { 132 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() {
128 if (!config_.pairing_client_id.empty() && !config_.pairing_secret.empty() && 133 if (!client_pairing_id_.empty() && !shared_secret_.empty() &&
129 std::find(methods_.begin(), methods_.end(), Method::SPAKE2_PAIR) != 134 std::find(methods_.begin(), methods_.end(), Method::SPAKE2_PAIR) !=
130 methods_.end()) { 135 methods_.end()) {
131 // If the client specified a pairing id and shared secret, then create a 136 // If the client specified a pairing id and shared secret, then create a
132 // PairingAuthenticator. 137 // PairingAuthenticator.
133 current_authenticator_.reset(new PairingClientAuthenticator( 138 current_authenticator_.reset(new PairingClientAuthenticator(
134 config_.pairing_client_id, config_.pairing_secret, 139 client_pairing_id_, shared_secret_,
135 base::Bind(&V2Authenticator::CreateForClient), 140 base::Bind(&V2Authenticator::CreateForClient), fetch_secret_callback_,
136 config_.fetch_secret_callback, config_.host_id)); 141 authentication_tag_));
137 current_method_ = Method::SPAKE2_PAIR; 142 current_method_ = Method::SPAKE2_PAIR;
138 } 143 }
139 } 144 }
140 145
141 void NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret( 146 void NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret(
142 Authenticator::State initial_state, 147 Authenticator::State initial_state,
143 const base::Closure& resume_callback, 148 const base::Closure& resume_callback,
144 const std::string& shared_secret) { 149 const std::string& shared_secret) {
145 current_authenticator_ = V2Authenticator::CreateForClient( 150 current_authenticator_ = V2Authenticator::CreateForClient(
146 (current_method_ == Method::SPAKE2_SHARED_SECRET_PLAIN) 151 (current_method_ == Method::SPAKE2_SHARED_SECRET_PLAIN)
147 ? shared_secret 152 ? shared_secret
148 : GetSharedSecretHash(config_.host_id, shared_secret), 153 : GetSharedSecretHash(authentication_tag_, shared_secret),
149 initial_state); 154 initial_state);
150 resume_callback.Run(); 155 resume_callback.Run();
151 } 156 }
152 157
153 } // namespace protocol 158 } // namespace protocol
154 } // namespace remoting 159 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_client_authenticator.h ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698