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

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

Issue 1781173005: Handle pairing_client_id in the negotiating authenticators. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@config
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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_authenticator_base.h" 5 #include "remoting/protocol/negotiating_authenticator_base.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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "remoting/base/constants.h"
14 #include "remoting/base/rsa_key_pair.h" 15 #include "remoting/base/rsa_key_pair.h"
15 #include "remoting/protocol/channel_authenticator.h" 16 #include "remoting/protocol/channel_authenticator.h"
16 #include "remoting/protocol/name_value_map.h" 17 #include "remoting/protocol/name_value_map.h"
17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 18 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
18 19
19 namespace remoting { 20 namespace remoting {
20 namespace protocol { 21 namespace protocol {
21 22
22 namespace { 23 namespace {
23 24
(...skipping 11 matching lines...) Expand all
35 "spake2_pair"}, 36 "spake2_pair"},
36 37
37 {NegotiatingAuthenticatorBase::Method::THIRD_PARTY_SPAKE2_P224, 38 {NegotiatingAuthenticatorBase::Method::THIRD_PARTY_SPAKE2_P224,
38 "third_party"}, 39 "third_party"},
39 {NegotiatingAuthenticatorBase::Method::THIRD_PARTY_SPAKE2_CURVE25519, 40 {NegotiatingAuthenticatorBase::Method::THIRD_PARTY_SPAKE2_CURVE25519,
40 "third_party_spake2_curve25519"}, 41 "third_party_spake2_curve25519"},
41 }; 42 };
42 43
43 } // namespace 44 } // namespace
44 45
45 const buzz::StaticQName NegotiatingAuthenticatorBase::kMethodAttributeQName = 46 const buzz::StaticQName NegotiatingAuthenticatorBase::kMethodAttributeQName = {
46 { "", "method" }; 47 "", "method"};
47 const buzz::StaticQName 48 const buzz::StaticQName
48 NegotiatingAuthenticatorBase::kSupportedMethodsAttributeQName = 49 NegotiatingAuthenticatorBase::kSupportedMethodsAttributeQName = {
49 { "", "supported-methods" }; 50 "", "supported-methods"};
50 const char NegotiatingAuthenticatorBase::kSupportedMethodsSeparator = ','; 51 const char NegotiatingAuthenticatorBase::kSupportedMethodsSeparator = ',';
51 52
53 const buzz::StaticQName NegotiatingAuthenticatorBase::kPairingInfoTag = {
54 kChromotingXmlNamespace, "pairing-info"};
55 const buzz::StaticQName NegotiatingAuthenticatorBase::kClientIdAttribute = {
56 "", "client-id"};
57
52 NegotiatingAuthenticatorBase::NegotiatingAuthenticatorBase( 58 NegotiatingAuthenticatorBase::NegotiatingAuthenticatorBase(
53 Authenticator::State initial_state) 59 Authenticator::State initial_state)
54 : state_(initial_state) {} 60 : state_(initial_state) {}
55 61
56 NegotiatingAuthenticatorBase::~NegotiatingAuthenticatorBase() {} 62 NegotiatingAuthenticatorBase::~NegotiatingAuthenticatorBase() {}
57 63
58 Authenticator::State NegotiatingAuthenticatorBase::state() const { 64 Authenticator::State NegotiatingAuthenticatorBase::state() const {
59 return state_; 65 return state_;
60 } 66 }
61 67
(...skipping 19 matching lines...) Expand all
81 } 87 }
82 88
83 // static 89 // static
84 std::string NegotiatingAuthenticatorBase::MethodToString(Method method) { 90 std::string NegotiatingAuthenticatorBase::MethodToString(Method method) {
85 return ValueToName(kAuthenticationMethodStrings, method); 91 return ValueToName(kAuthenticationMethodStrings, method);
86 } 92 }
87 93
88 void NegotiatingAuthenticatorBase::ProcessMessageInternal( 94 void NegotiatingAuthenticatorBase::ProcessMessageInternal(
89 const buzz::XmlElement* message, 95 const buzz::XmlElement* message,
90 const base::Closure& resume_callback) { 96 const base::Closure& resume_callback) {
97 DCHECK_EQ(state_, PROCESSING_MESSAGE);
98
91 if (current_authenticator_->state() == WAITING_MESSAGE) { 99 if (current_authenticator_->state() == WAITING_MESSAGE) {
92 // If the message was not discarded and the authenticator is waiting for it, 100 // If the message was not discarded and the authenticator is waiting for it,
93 // give it to the underlying authenticator to process. 101 // give it to the underlying authenticator to process.
94 // |current_authenticator_| is owned, so Unretained() is safe here. 102 // |current_authenticator_| is owned, so Unretained() is safe here.
95 state_ = PROCESSING_MESSAGE; 103 current_authenticator_->ProcessMessage(
96 current_authenticator_->ProcessMessage(message, base::Bind( 104 message, base::Bind(&NegotiatingAuthenticatorBase::UpdateState,
97 &NegotiatingAuthenticatorBase::UpdateState, 105 base::Unretained(this), resume_callback));
98 base::Unretained(this), resume_callback));
99 } else { 106 } else {
100 // Otherwise, just discard the message and run the callback. 107 // Otherwise, just discard the message.
101 resume_callback.Run(); 108 UpdateState(resume_callback);
102 } 109 }
103 } 110 }
104 111
105 void NegotiatingAuthenticatorBase::UpdateState( 112 void NegotiatingAuthenticatorBase::UpdateState(
106 const base::Closure& resume_callback) { 113 const base::Closure& resume_callback) {
114 DCHECK_EQ(state_, PROCESSING_MESSAGE);
115
107 // After the underlying authenticator finishes processing the message, the 116 // After the underlying authenticator finishes processing the message, the
108 // NegotiatingAuthenticatorBase must update its own state before running the 117 // NegotiatingAuthenticatorBase must update its own state before running the
109 // |resume_callback| to resume the session negotiation. 118 // |resume_callback| to resume the session negotiation.
110 state_ = current_authenticator_->state(); 119 state_ = current_authenticator_->state();
120
121 // Verify that this is a valid state transition.
122 DCHECK(state_ == MESSAGE_READY || state_ == ACCEPTED || state_ == REJECTED)
123 << "State: " << state_;
124
111 if (state_ == REJECTED) 125 if (state_ == REJECTED)
112 rejection_reason_ = current_authenticator_->rejection_reason(); 126 rejection_reason_ = current_authenticator_->rejection_reason();
127
113 resume_callback.Run(); 128 resume_callback.Run();
114 } 129 }
115 130
116 scoped_ptr<buzz::XmlElement> 131 scoped_ptr<buzz::XmlElement>
117 NegotiatingAuthenticatorBase::GetNextMessageInternal() { 132 NegotiatingAuthenticatorBase::GetNextMessageInternal() {
118 DCHECK_EQ(state(), MESSAGE_READY); 133 DCHECK_EQ(state(), MESSAGE_READY);
119 DCHECK(current_method_ != Method::INVALID); 134 DCHECK(current_method_ != Method::INVALID);
120 135
121 scoped_ptr<buzz::XmlElement> result; 136 scoped_ptr<buzz::XmlElement> result;
122 if (current_authenticator_->state() == MESSAGE_READY) { 137 if (current_authenticator_->state() == MESSAGE_READY) {
(...skipping 18 matching lines...) Expand all
141 } 156 }
142 157
143 scoped_ptr<ChannelAuthenticator> 158 scoped_ptr<ChannelAuthenticator>
144 NegotiatingAuthenticatorBase::CreateChannelAuthenticator() const { 159 NegotiatingAuthenticatorBase::CreateChannelAuthenticator() const {
145 DCHECK_EQ(state(), ACCEPTED); 160 DCHECK_EQ(state(), ACCEPTED);
146 return current_authenticator_->CreateChannelAuthenticator(); 161 return current_authenticator_->CreateChannelAuthenticator();
147 } 162 }
148 163
149 } // namespace protocol 164 } // namespace protocol
150 } // namespace remoting 165 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_authenticator_base.h ('k') | remoting/protocol/negotiating_client_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698