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