OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/host/token_validator_base.h" | 5 #include "remoting/host/token_validator_base.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 int response = request_->GetResponseCode(); | 204 int response = request_->GetResponseCode(); |
205 if (response != 200) { | 205 if (response != 200) { |
206 LOG(ERROR) | 206 LOG(ERROR) |
207 << "Error " << response << " validating token: '" << data_ << "'"; | 207 << "Error " << response << " validating token: '" << data_ << "'"; |
208 return std::string(); | 208 return std::string(); |
209 } | 209 } |
210 | 210 |
211 // Decode the JSON data from the response. | 211 // Decode the JSON data from the response. |
212 scoped_ptr<base::Value> value = base::JSONReader::Read(data_); | 212 std::unique_ptr<base::Value> value = base::JSONReader::Read(data_); |
213 base::DictionaryValue* dict; | 213 base::DictionaryValue* dict; |
214 if (!value || !value->GetAsDictionary(&dict)) { | 214 if (!value || !value->GetAsDictionary(&dict)) { |
215 LOG(ERROR) << "Invalid token validation response: '" << data_ << "'"; | 215 LOG(ERROR) << "Invalid token validation response: '" << data_ << "'"; |
216 return std::string(); | 216 return std::string(); |
217 } | 217 } |
218 | 218 |
219 std::string token_scope; | 219 std::string token_scope; |
220 dict->GetStringWithoutPathExpansion("scope", &token_scope); | 220 dict->GetStringWithoutPathExpansion("scope", &token_scope); |
221 if (!IsValidScope(token_scope)) { | 221 if (!IsValidScope(token_scope)) { |
222 LOG(ERROR) << "Invalid scope: '" << token_scope | 222 LOG(ERROR) << "Invalid scope: '" << token_scope |
223 << "', expected: '" << token_scope_ <<"'."; | 223 << "', expected: '" << token_scope_ <<"'."; |
224 return std::string(); | 224 return std::string(); |
225 } | 225 } |
226 | 226 |
227 std::string shared_secret; | 227 std::string shared_secret; |
228 // Everything is valid, so return the shared secret to the caller. | 228 // Everything is valid, so return the shared secret to the caller. |
229 dict->GetStringWithoutPathExpansion("access_token", &shared_secret); | 229 dict->GetStringWithoutPathExpansion("access_token", &shared_secret); |
230 return shared_secret; | 230 return shared_secret; |
231 } | 231 } |
232 | 232 |
233 } // namespace remoting | 233 } // namespace remoting |
OLD | NEW |