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

Side by Side Diff: crypto/nss_util.cc

Issue 112533002: Add ClientCertStoreChromeOS which only returns the certs for a given user. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: explicits Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « crypto/nss_util.h ('k') | net/cert/nss_profile_filter_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "crypto/nss_util.h" 5 #include "crypto/nss_util.h"
6 #include "crypto/nss_util_internal.h" 6 #include "crypto/nss_util_internal.h"
7 7
8 #include <nss.h> 8 #include <nss.h>
9 #include <pk11pub.h> 9 #include <pk11pub.h>
10 #include <plarena.h> 10 #include <plarena.h>
(...skipping 13 matching lines...) Expand all
24 #include <map> 24 #include <map>
25 #include <vector> 25 #include <vector>
26 26
27 #include "base/callback.h" 27 #include "base/callback.h"
28 #include "base/cpu.h" 28 #include "base/cpu.h"
29 #include "base/debug/alias.h" 29 #include "base/debug/alias.h"
30 #include "base/debug/stack_trace.h" 30 #include "base/debug/stack_trace.h"
31 #include "base/environment.h" 31 #include "base/environment.h"
32 #include "base/file_util.h" 32 #include "base/file_util.h"
33 #include "base/files/file_path.h" 33 #include "base/files/file_path.h"
34 #include "base/files/scoped_temp_dir.h"
35 #include "base/lazy_instance.h" 34 #include "base/lazy_instance.h"
36 #include "base/logging.h" 35 #include "base/logging.h"
37 #include "base/memory/scoped_ptr.h" 36 #include "base/memory/scoped_ptr.h"
38 #include "base/metrics/histogram.h" 37 #include "base/metrics/histogram.h"
39 #include "base/native_library.h" 38 #include "base/native_library.h"
40 #include "base/stl_util.h" 39 #include "base/stl_util.h"
41 #include "base/strings/stringprintf.h" 40 #include "base/strings/stringprintf.h"
42 #include "base/threading/thread_checker.h" 41 #include "base/threading/thread_checker.h"
43 #include "base/threading/thread_restrictions.h" 42 #include "base/threading/thread_restrictions.h"
44 #include "build/build_config.h" 43 #include "build/build_config.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 DCHECK(thread_checker_.CalledOnValidThread()); 462 DCHECK(thread_checker_.CalledOnValidThread());
464 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end()); 463 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end());
465 464
466 if (test_slot_) { 465 if (test_slot_) {
467 DVLOG(2) << "returning test_slot_ for " << username_hash; 466 DVLOG(2) << "returning test_slot_ for " << username_hash;
468 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_)); 467 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_));
469 } 468 }
470 469
471 return chromeos_user_map_[username_hash]->GetPrivateSlot(callback); 470 return chromeos_user_map_[username_hash]->GetPrivateSlot(callback);
472 } 471 }
472
473 void CloseTestChromeOSUser(const std::string& username_hash) {
474 DCHECK(thread_checker_.CalledOnValidThread());
475 ChromeOSUserMap::iterator i = chromeos_user_map_.find(username_hash);
476 DCHECK(i != chromeos_user_map_.end());
477 delete i->second;
478 chromeos_user_map_.erase(i);
479 }
473 #endif // defined(OS_CHROMEOS) 480 #endif // defined(OS_CHROMEOS)
474 481
475 482
476 bool OpenTestNSSDB() { 483 bool OpenTestNSSDB() {
477 DCHECK(thread_checker_.CalledOnValidThread()); 484 DCHECK(thread_checker_.CalledOnValidThread());
478 // NSS is allowed to do IO on the current thread since dispatching 485 // NSS is allowed to do IO on the current thread since dispatching
479 // to a dedicated thread would still have the affect of blocking 486 // to a dedicated thread would still have the affect of blocking
480 // the current thread, due to NSS's internal locking requirements 487 // the current thread, due to NSS's internal locking requirements
481 base::ThreadRestrictions::ScopedAllowIO allow_io; 488 base::ThreadRestrictions::ScopedAllowIO allow_io;
482 489
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 } 983 }
977 984
978 bool IsTPMTokenReady(const base::Closure& callback) { 985 bool IsTPMTokenReady(const base::Closure& callback) {
979 return g_nss_singleton.Get().IsTPMTokenReady(callback); 986 return g_nss_singleton.Get().IsTPMTokenReady(callback);
980 } 987 }
981 988
982 bool InitializeTPMToken(int token_slot_id) { 989 bool InitializeTPMToken(int token_slot_id) {
983 return g_nss_singleton.Get().InitializeTPMToken(token_slot_id); 990 return g_nss_singleton.Get().InitializeTPMToken(token_slot_id);
984 } 991 }
985 992
993 ScopedTestNSSChromeOSUser::ScopedTestNSSChromeOSUser(
994 const std::string& username_hash)
995 : username_hash_(username_hash), constructed_successfully_(false) {
996 if (!temp_dir_.CreateUniqueTempDir())
997 return;
998 constructed_successfully_ =
999 InitializeNSSForChromeOSUser(username_hash,
1000 username_hash,
1001 false /* is_primary_user */,
1002 temp_dir_.path());
1003 }
1004
1005 ScopedTestNSSChromeOSUser::~ScopedTestNSSChromeOSUser() {
1006 if (constructed_successfully_)
1007 g_nss_singleton.Get().CloseTestChromeOSUser(username_hash_);
1008 }
1009
1010 void ScopedTestNSSChromeOSUser::FinishInit() {
1011 InitializePrivateSoftwareSlotForChromeOSUser(username_hash_);
1012 }
1013
986 bool InitializeNSSForChromeOSUser( 1014 bool InitializeNSSForChromeOSUser(
987 const std::string& email, 1015 const std::string& email,
988 const std::string& username_hash, 1016 const std::string& username_hash,
989 bool is_primary_user, 1017 bool is_primary_user,
990 const base::FilePath& path) { 1018 const base::FilePath& path) {
991 return g_nss_singleton.Get().InitializeNSSForChromeOSUser( 1019 return g_nss_singleton.Get().InitializeNSSForChromeOSUser(
992 email, username_hash, is_primary_user, path); 1020 email, username_hash, is_primary_user, path);
993 } 1021 }
994 void InitializeTPMForChromeOSUser( 1022 void InitializeTPMForChromeOSUser(
995 const std::string& username_hash, 1023 const std::string& username_hash,
(...skipping 27 matching lines...) Expand all
1023 1051
1024 PK11SlotInfo* GetPublicNSSKeySlot() { 1052 PK11SlotInfo* GetPublicNSSKeySlot() {
1025 return g_nss_singleton.Get().GetPublicNSSKeySlot(); 1053 return g_nss_singleton.Get().GetPublicNSSKeySlot();
1026 } 1054 }
1027 1055
1028 PK11SlotInfo* GetPrivateNSSKeySlot() { 1056 PK11SlotInfo* GetPrivateNSSKeySlot() {
1029 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); 1057 return g_nss_singleton.Get().GetPrivateNSSKeySlot();
1030 } 1058 }
1031 1059
1032 } // namespace crypto 1060 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/nss_util.h ('k') | net/cert/nss_profile_filter_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698