| 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/cert/nss_cert_database_chromeos.h" | 5 #include "net/cert/nss_cert_database_chromeos.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
| 9 | 9 |
| 10 #include "net/base/crypto_module.h" | 10 #include "net/base/crypto_module.h" |
| 11 #include "net/cert/x509_certificate.h" | 11 #include "net/cert/x509_certificate.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 NSSCertDatabaseChromeOS::NSSCertDatabaseChromeOS( | 15 NSSCertDatabaseChromeOS::NSSCertDatabaseChromeOS( |
| 16 crypto::ScopedPK11Slot public_slot, | 16 crypto::ScopedPK11Slot public_slot, |
| 17 crypto::ScopedPK11Slot private_slot) | 17 crypto::ScopedPK11Slot private_slot) |
| 18 : public_slot_(public_slot.Pass()), | 18 : public_slot_(public_slot.Pass()), |
| 19 private_slot_(private_slot.Pass()) { | 19 private_slot_(private_slot.Pass()), |
| 20 profile_filter_.Init(GetPublicSlot(), GetPrivateSlot()); | 20 profile_filter_(new NSSProfileFilterChromeOS) { |
| 21 profile_filter_->Init(GetPublicSlot(), GetPrivateSlot()); |
| 21 } | 22 } |
| 22 | 23 |
| 23 NSSCertDatabaseChromeOS::~NSSCertDatabaseChromeOS() {} | 24 NSSCertDatabaseChromeOS::~NSSCertDatabaseChromeOS() {} |
| 24 | 25 |
| 25 void NSSCertDatabaseChromeOS::ListCerts(CertificateList* certs) { | 26 void NSSCertDatabaseChromeOS::ListCertsSync(CertificateList* certs) { |
| 26 NSSCertDatabase::ListCerts(certs); | 27 NSSCertDatabase::ListCertsSync(certs); |
| 27 | 28 |
| 28 size_t pre_size = certs->size(); | 29 size_t pre_size = certs->size(); |
| 29 certs->erase(std::remove_if( | 30 certs->erase(std::remove_if( |
| 30 certs->begin(), | 31 certs->begin(), |
| 31 certs->end(), | 32 certs->end(), |
| 32 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate( | 33 NSSDatabaseFilter::CertNotAllowedPredicate(profile_filter_)), |
| 33 profile_filter_)), | |
| 34 certs->end()); | 34 certs->end()); |
| 35 DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size | 35 DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size |
| 36 << " certs"; | 36 << " certs"; |
| 37 } | 37 } |
| 38 | 38 |
| 39 scoped_refptr<NSSDatabaseFilter> |
| 40 NSSCertDatabaseChromeOS::GetDatabaseFilter() const { |
| 41 return profile_filter_; |
| 42 } |
| 43 |
| 39 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPublicSlot() const { | 44 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPublicSlot() const { |
| 40 return crypto::ScopedPK11Slot( | 45 return crypto::ScopedPK11Slot( |
| 41 public_slot_ ? PK11_ReferenceSlot(public_slot_.get()) : NULL); | 46 public_slot_ ? PK11_ReferenceSlot(public_slot_.get()) : NULL); |
| 42 } | 47 } |
| 43 | 48 |
| 44 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPrivateSlot() const { | 49 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPrivateSlot() const { |
| 45 return crypto::ScopedPK11Slot( | 50 return crypto::ScopedPK11Slot( |
| 46 private_slot_ ? PK11_ReferenceSlot(private_slot_.get()) : NULL); | 51 private_slot_ ? PK11_ReferenceSlot(private_slot_.get()) : NULL); |
| 47 } | 52 } |
| 48 | 53 |
| 49 void NSSCertDatabaseChromeOS::ListModules(CryptoModuleList* modules, | 54 void NSSCertDatabaseChromeOS::ListModulesSync(CryptoModuleList* modules, |
| 50 bool need_rw) const { | 55 bool need_rw) const { |
| 51 NSSCertDatabase::ListModules(modules, need_rw); | 56 NSSCertDatabase::ListModulesSync(modules, need_rw); |
| 52 | 57 |
| 53 size_t pre_size = modules->size(); | 58 size_t pre_size = modules->size(); |
| 54 modules->erase( | 59 modules->erase( |
| 55 std::remove_if( | 60 std::remove_if( |
| 56 modules->begin(), | 61 modules->begin(), |
| 57 modules->end(), | 62 modules->end(), |
| 58 NSSProfileFilterChromeOS::ModuleNotAllowedForProfilePredicate( | 63 NSSDatabaseFilter::ModuleNotAllowedPredicate(profile_filter_)), |
| 59 profile_filter_)), | |
| 60 modules->end()); | 64 modules->end()); |
| 61 DVLOG(1) << "filtered " << pre_size - modules->size() << " of " << pre_size | 65 DVLOG(1) << "filtered " << pre_size - modules->size() << " of " << pre_size |
| 62 << " modules"; | 66 << " modules"; |
| 63 } | 67 } |
| 64 | 68 |
| 65 } // namespace net | 69 } // namespace net |
| OLD | NEW |