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

Side by Side Diff: net/ssl/client_cert_store_chromeos.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 | « net/ssl/client_cert_store_chromeos.h ('k') | net/ssl/client_cert_store_chromeos_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/ssl/client_cert_store_chromeos.h"
6
7 #include <cert.h>
8
9 #include "base/bind.h"
10 #include "crypto/nss_crypto_module_delegate.h"
11 #include "crypto/nss_util_internal.h"
12
13 namespace net {
14
15 ClientCertStoreChromeOS::ClientCertStoreChromeOS(
16 const std::string& username_hash,
17 const PasswordDelegateFactory& password_delegate_factory)
18 : ClientCertStoreNSS(password_delegate_factory),
19 username_hash_(username_hash) {}
20
21 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {}
22
23 void ClientCertStoreChromeOS::GetClientCerts(
24 const SSLCertRequestInfo& cert_request_info,
25 CertificateList* selected_certs,
26 const base::Closure& callback) {
27 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser(
28 username_hash_,
29 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot,
30 // Caller is responsible for keeping the ClientCertStore alive
31 // until the callback is run.
32 base::Unretained(this),
33 &cert_request_info,
34 selected_certs,
35 callback)));
36 if (private_slot)
37 DidGetPrivateSlot(
38 &cert_request_info, selected_certs, callback, private_slot.Pass());
39 }
40
41 void ClientCertStoreChromeOS::GetClientCertsImpl(CERTCertList* cert_list,
42 const SSLCertRequestInfo& request,
43 bool query_nssdb,
44 CertificateList* selected_certs) {
45 ClientCertStoreNSS::GetClientCertsImpl(
46 cert_list, request, query_nssdb, selected_certs);
47
48 size_t pre_size = selected_certs->size();
49 selected_certs->erase(
50 std::remove_if(
51 selected_certs->begin(),
52 selected_certs->end(),
53 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate(
54 profile_filter_)),
55 selected_certs->end());
56 DVLOG(1) << "filtered " << pre_size - selected_certs->size() << " of "
57 << pre_size << " certs";
58 }
59
60 void ClientCertStoreChromeOS::DidGetPrivateSlot(
61 const SSLCertRequestInfo* request,
62 CertificateList* selected_certs,
63 const base::Closure& callback,
64 crypto::ScopedPK11Slot private_slot) {
65 profile_filter_.Init(crypto::GetPublicSlotForChromeOSUser(username_hash_),
66 private_slot.Pass());
67 ClientCertStoreNSS::GetClientCerts(*request, selected_certs, callback);
68 }
69
70 void ClientCertStoreChromeOS::InitForTesting(
71 crypto::ScopedPK11Slot public_slot,
72 crypto::ScopedPK11Slot private_slot) {
73 profile_filter_.Init(public_slot.Pass(), private_slot.Pass());
74 }
75
76 bool ClientCertStoreChromeOS::SelectClientCertsForTesting(
77 const CertificateList& input_certs,
78 const SSLCertRequestInfo& request,
79 CertificateList* selected_certs) {
80 CERTCertList* cert_list = CERT_NewCertList();
81 if (!cert_list)
82 return false;
83 for (size_t i = 0; i < input_certs.size(); ++i) {
84 CERT_AddCertToListTail(
85 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle()));
86 }
87
88 GetClientCertsImpl(cert_list, request, false, selected_certs);
89 CERT_DestroyCertList(cert_list);
90 return true;
91 }
92
93
94 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/client_cert_store_chromeos.h ('k') | net/ssl/client_cert_store_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698