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 "net/ssl/client_cert_store_chromeos.h" | 5 #include "net/ssl/client_cert_store_chromeos.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "crypto/nss_crypto_module_delegate.h" | 10 #include "crypto/nss_crypto_module_delegate.h" |
11 #include "crypto/nss_util_internal.h" | 11 #include "crypto/nss_util_internal.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 ClientCertStoreChromeOS::ClientCertStoreChromeOS( | 15 ClientCertStoreChromeOS::ClientCertStoreChromeOS( |
16 const std::string& username_hash, | 16 const std::string& username_hash, |
17 const PasswordDelegateFactory& password_delegate_factory) | 17 const PasswordDelegateFactory& password_delegate_factory) |
18 : ClientCertStoreNSS(password_delegate_factory), | 18 : ClientCertStoreNSS(password_delegate_factory), |
19 username_hash_(username_hash) {} | 19 username_hash_(username_hash) { |
| 20 } |
20 | 21 |
21 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} | 22 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() { |
| 23 } |
22 | 24 |
23 void ClientCertStoreChromeOS::GetClientCerts( | 25 void ClientCertStoreChromeOS::GetClientCerts( |
24 const SSLCertRequestInfo& cert_request_info, | 26 const SSLCertRequestInfo& cert_request_info, |
25 CertificateList* selected_certs, | 27 CertificateList* selected_certs, |
26 const base::Closure& callback) { | 28 const base::Closure& callback) { |
27 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser( | 29 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser( |
28 username_hash_, | 30 username_hash_, |
29 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot, | 31 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot, |
30 // Caller is responsible for keeping the ClientCertStore alive | 32 // Caller is responsible for keeping the ClientCertStore alive |
31 // until the callback is run. | 33 // until the callback is run. |
32 base::Unretained(this), | 34 base::Unretained(this), |
33 &cert_request_info, | 35 &cert_request_info, |
34 selected_certs, | 36 selected_certs, |
35 callback))); | 37 callback))); |
36 if (private_slot) | 38 if (private_slot) |
37 DidGetPrivateSlot( | 39 DidGetPrivateSlot( |
38 &cert_request_info, selected_certs, callback, private_slot.Pass()); | 40 &cert_request_info, selected_certs, callback, private_slot.Pass()); |
39 } | 41 } |
40 | 42 |
41 void ClientCertStoreChromeOS::GetClientCertsImpl(CERTCertList* cert_list, | 43 void ClientCertStoreChromeOS::GetClientCertsImpl( |
42 const SSLCertRequestInfo& request, | 44 CERTCertList* cert_list, |
43 bool query_nssdb, | 45 const SSLCertRequestInfo& request, |
44 CertificateList* selected_certs) { | 46 bool query_nssdb, |
| 47 CertificateList* selected_certs) { |
45 ClientCertStoreNSS::GetClientCertsImpl( | 48 ClientCertStoreNSS::GetClientCertsImpl( |
46 cert_list, request, query_nssdb, selected_certs); | 49 cert_list, request, query_nssdb, selected_certs); |
47 | 50 |
48 size_t pre_size = selected_certs->size(); | 51 size_t pre_size = selected_certs->size(); |
49 selected_certs->erase( | 52 selected_certs->erase( |
50 std::remove_if( | 53 std::remove_if( |
51 selected_certs->begin(), | 54 selected_certs->begin(), |
52 selected_certs->end(), | 55 selected_certs->end(), |
53 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate( | 56 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate( |
54 profile_filter_)), | 57 profile_filter_)), |
(...skipping 28 matching lines...) Expand all Loading... |
83 for (size_t i = 0; i < input_certs.size(); ++i) { | 86 for (size_t i = 0; i < input_certs.size(); ++i) { |
84 CERT_AddCertToListTail( | 87 CERT_AddCertToListTail( |
85 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle())); | 88 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle())); |
86 } | 89 } |
87 | 90 |
88 GetClientCertsImpl(cert_list, request, false, selected_certs); | 91 GetClientCertsImpl(cert_list, request, false, selected_certs); |
89 CERT_DestroyCertList(cert_list); | 92 CERT_DestroyCertList(cert_list); |
90 return true; | 93 return true; |
91 } | 94 } |
92 | 95 |
93 | |
94 } // namespace net | 96 } // namespace net |
OLD | NEW |