OLD | NEW |
(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 "base/bind.h" |
| 8 #include "crypto/nss_util_internal.h" |
| 9 |
| 10 namespace net { |
| 11 |
| 12 ClientCertStoreChromeOS::ClientCertStoreChromeOS( |
| 13 const std::string& username_hash) |
| 14 : username_hash_(username_hash) {} |
| 15 |
| 16 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} |
| 17 |
| 18 void ClientCertStoreChromeOS::GetClientCerts( |
| 19 const SSLCertRequestInfo& cert_request_info, |
| 20 CertificateList* selected_certs, |
| 21 const base::Closure& callback) { |
| 22 cert_request_info_ = &cert_request_info; |
| 23 selected_certs_ = selected_certs; |
| 24 callback_ = callback; |
| 25 |
| 26 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser( |
| 27 username_hash_, |
| 28 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot, |
| 29 base::Unretained(this)))); |
| 30 if (private_slot) |
| 31 DidGetPrivateSlot(private_slot.Pass()); |
| 32 } |
| 33 |
| 34 void ClientCertStoreChromeOS::DidGetPrivateSlot( |
| 35 crypto::ScopedPK11Slot private_slot) { |
| 36 DVLOG(1) << __func__; |
| 37 profile_filter_.Init(crypto::GetPublicSlotForChromeOSUser(username_hash_), |
| 38 private_slot.Pass()); |
| 39 ClientCertStoreImpl::GetClientCerts( |
| 40 *cert_request_info_, |
| 41 selected_certs_, |
| 42 base::Bind(&ClientCertStoreChromeOS::GotClientCerts, |
| 43 base::Unretained(this))); |
| 44 } |
| 45 |
| 46 void ClientCertStoreChromeOS::GotClientCerts() { |
| 47 size_t pre_size = selected_certs_->size(); |
| 48 selected_certs_->erase( |
| 49 std::remove_if(selected_certs_->begin(), |
| 50 selected_certs_->end(), |
| 51 NSSProfileFilterChromeOS::Predicate(profile_filter_)), |
| 52 selected_certs_->end()); |
| 53 DVLOG(1) << "filtered " << pre_size - selected_certs_->size() << " of " |
| 54 << pre_size << " certs"; |
| 55 |
| 56 callback_.Run(); |
| 57 } |
| 58 |
| 59 } // namespace net |
OLD | NEW |