OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/chromeos/platform_keys/key_permissions.h" | 5 #include "chrome/browser/chromeos/platform_keys/key_permissions.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void KeyPermissions::PermissionsForExtension::KeyEntriesFromState( | 240 void KeyPermissions::PermissionsForExtension::KeyEntriesFromState( |
241 const base::Value& state) { | 241 const base::Value& state) { |
242 state_store_entries_.clear(); | 242 state_store_entries_.clear(); |
243 | 243 |
244 const base::ListValue* entries = nullptr; | 244 const base::ListValue* entries = nullptr; |
245 if (!state.GetAsList(&entries)) { | 245 if (!state.GetAsList(&entries)) { |
246 LOG(ERROR) << "Found a state store of wrong type."; | 246 LOG(ERROR) << "Found a state store of wrong type."; |
247 return; | 247 return; |
248 } | 248 } |
249 for (const auto& entry : *entries) { | 249 for (const auto& entry : *entries) { |
250 if (!entry) { | |
251 LOG(ERROR) << "Found invalid NULL entry in PlatformKeys state store."; | |
252 continue; | |
253 } | |
254 | |
255 std::string spki_b64; | 250 std::string spki_b64; |
256 const base::DictionaryValue* dict_entry = nullptr; | 251 const base::DictionaryValue* dict_entry = nullptr; |
257 if (entry->GetAsString(&spki_b64)) { | 252 if (entry.GetAsString(&spki_b64)) { |
258 // This handles the case that the store contained a plain list of base64 | 253 // This handles the case that the store contained a plain list of base64 |
259 // and DER-encoded SPKIs from an older version of ChromeOS. | 254 // and DER-encoded SPKIs from an older version of ChromeOS. |
260 KeyEntry new_entry(spki_b64); | 255 KeyEntry new_entry(spki_b64); |
261 new_entry.sign_once = true; | 256 new_entry.sign_once = true; |
262 state_store_entries_.push_back(new_entry); | 257 state_store_entries_.push_back(new_entry); |
263 } else if (entry->GetAsDictionary(&dict_entry)) { | 258 } else if (entry.GetAsDictionary(&dict_entry)) { |
264 dict_entry->GetStringWithoutPathExpansion(kStateStoreSPKI, &spki_b64); | 259 dict_entry->GetStringWithoutPathExpansion(kStateStoreSPKI, &spki_b64); |
265 KeyEntry new_entry(spki_b64); | 260 KeyEntry new_entry(spki_b64); |
266 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignOnce, | 261 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignOnce, |
267 &new_entry.sign_once); | 262 &new_entry.sign_once); |
268 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignUnlimited, | 263 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignUnlimited, |
269 &new_entry.sign_unlimited); | 264 &new_entry.sign_unlimited); |
270 state_store_entries_.push_back(new_entry); | 265 state_store_entries_.push_back(new_entry); |
271 } else { | 266 } else { |
272 LOG(ERROR) << "Found invalid entry of type " << entry->GetType() | 267 LOG(ERROR) << "Found invalid entry of type " << entry.GetType() |
273 << " in PlatformKeys state store."; | 268 << " in PlatformKeys state store."; |
274 continue; | 269 continue; |
275 } | 270 } |
276 } | 271 } |
277 } | 272 } |
278 | 273 |
279 std::unique_ptr<base::Value> | 274 std::unique_ptr<base::Value> |
280 KeyPermissions::PermissionsForExtension::KeyEntriesToState() { | 275 KeyPermissions::PermissionsForExtension::KeyEntriesToState() { |
281 std::unique_ptr<base::ListValue> new_state(new base::ListValue); | 276 std::unique_ptr<base::ListValue> new_state(new base::ListValue); |
282 for (const KeyEntry& entry : state_store_entries_) { | 277 for (const KeyEntry& entry : state_store_entries_) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 const base::DictionaryValue* platform_keys = | 388 const base::DictionaryValue* platform_keys = |
394 profile_prefs_->GetDictionary(prefs::kPlatformKeys); | 389 profile_prefs_->GetDictionary(prefs::kPlatformKeys); |
395 | 390 |
396 const base::DictionaryValue* key_entry = nullptr; | 391 const base::DictionaryValue* key_entry = nullptr; |
397 platform_keys->GetDictionaryWithoutPathExpansion(public_key_spki_der_b64, | 392 platform_keys->GetDictionaryWithoutPathExpansion(public_key_spki_der_b64, |
398 &key_entry); | 393 &key_entry); |
399 return key_entry; | 394 return key_entry; |
400 } | 395 } |
401 | 396 |
402 } // namespace chromeos | 397 } // namespace chromeos |
OLD | NEW |