OLD | NEW |
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/pairing_authenticator_base.h" | 5 #include "remoting/protocol/pairing_authenticator_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "remoting/base/constants.h" | 8 #include "remoting/base/constants.h" |
9 #include "remoting/protocol/channel_authenticator.h" | 9 #include "remoting/protocol/channel_authenticator.h" |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 bool PairingAuthenticatorBase::HasErrorMessage( | 112 bool PairingAuthenticatorBase::HasErrorMessage( |
113 const buzz::XmlElement* message) const { | 113 const buzz::XmlElement* message) const { |
114 const buzz::XmlElement* pairing_failed_tag = | 114 const buzz::XmlElement* pairing_failed_tag = |
115 message->FirstNamed(kPairingFailedTag); | 115 message->FirstNamed(kPairingFailedTag); |
116 if (pairing_failed_tag) { | 116 if (pairing_failed_tag) { |
117 std::string error = pairing_failed_tag->Attr(kPairingErrorAttribute); | 117 std::string error = pairing_failed_tag->Attr(kPairingErrorAttribute); |
118 LOG(ERROR) << "Pairing failed: " << error; | 118 LOG(ERROR) << "Pairing failed: " << error; |
119 } | 119 } |
120 return pairing_failed_tag != NULL; | 120 return pairing_failed_tag != nullptr; |
121 } | 121 } |
122 | 122 |
123 void PairingAuthenticatorBase::CheckForFailedSpakeExchange( | 123 void PairingAuthenticatorBase::CheckForFailedSpakeExchange( |
124 const base::Closure& resume_callback) { | 124 const base::Closure& resume_callback) { |
125 // If the SPAKE exchange failed due to invalid credentials, and those | 125 // If the SPAKE exchange failed due to invalid credentials, and those |
126 // credentials were the paired secret, then notify the peer that the | 126 // credentials were the paired secret, then notify the peer that the |
127 // PIN-less connection failed and retry using the PIN. | 127 // PIN-less connection failed and retry using the PIN. |
128 if (v2_authenticator_->state() == REJECTED && | 128 if (v2_authenticator_->state() == REJECTED && |
129 v2_authenticator_->rejection_reason() == INVALID_CREDENTIALS && | 129 v2_authenticator_->rejection_reason() == INVALID_CREDENTIALS && |
130 using_paired_secret_) { | 130 using_paired_secret_) { |
131 using_paired_secret_ = false; | 131 using_paired_secret_ = false; |
132 error_message_ = "invalid-shared-secret"; | 132 error_message_ = "invalid-shared-secret"; |
133 v2_authenticator_.reset(); | 133 v2_authenticator_.reset(); |
134 buzz::XmlElement* no_message = NULL; | 134 buzz::XmlElement* no_message = nullptr; |
135 SetAuthenticatorCallback set_authenticator = base::Bind( | 135 SetAuthenticatorCallback set_authenticator = base::Bind( |
136 &PairingAuthenticatorBase::SetAuthenticatorAndProcessMessage, | 136 &PairingAuthenticatorBase::SetAuthenticatorAndProcessMessage, |
137 weak_factory_.GetWeakPtr(), no_message, resume_callback); | 137 weak_factory_.GetWeakPtr(), no_message, resume_callback); |
138 CreateV2AuthenticatorWithPIN(MESSAGE_READY, set_authenticator); | 138 CreateV2AuthenticatorWithPIN(MESSAGE_READY, set_authenticator); |
139 return; | 139 return; |
140 } | 140 } |
141 | 141 |
142 resume_callback.Run(); | 142 resume_callback.Run(); |
143 } | 143 } |
144 | 144 |
145 void PairingAuthenticatorBase::SetAuthenticatorAndProcessMessage( | 145 void PairingAuthenticatorBase::SetAuthenticatorAndProcessMessage( |
146 const buzz::XmlElement* message, | 146 const buzz::XmlElement* message, |
147 const base::Closure& resume_callback, | 147 const base::Closure& resume_callback, |
148 scoped_ptr<Authenticator> authenticator) { | 148 scoped_ptr<Authenticator> authenticator) { |
149 DCHECK(!v2_authenticator_); | 149 DCHECK(!v2_authenticator_); |
150 DCHECK(authenticator); | 150 DCHECK(authenticator); |
151 waiting_for_authenticator_ = false; | 151 waiting_for_authenticator_ = false; |
152 v2_authenticator_ = authenticator.Pass(); | 152 v2_authenticator_ = authenticator.Pass(); |
153 if (message) { | 153 if (message) { |
154 ProcessMessage(message, resume_callback); | 154 ProcessMessage(message, resume_callback); |
155 } else { | 155 } else { |
156 resume_callback.Run(); | 156 resume_callback.Run(); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 } // namespace protocol | 160 } // namespace protocol |
161 } // namespace remoting | 161 } // namespace remoting |
OLD | NEW |