| 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 profile_filter_(new NSSProfileFilterChromeOS()) {} |
| 20 | 21 |
| 21 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} | 22 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} |
| 22 | 23 |
| 23 void ClientCertStoreChromeOS::GetClientCerts( | 24 void ClientCertStoreChromeOS::GetClientCerts( |
| 24 const SSLCertRequestInfo& cert_request_info, | 25 const SSLCertRequestInfo& cert_request_info, |
| 25 CertificateList* selected_certs, | 26 CertificateList* selected_certs, |
| 26 const base::Closure& callback) { | 27 const base::Closure& callback) { |
| 27 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser( | 28 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser( |
| 28 username_hash_, | 29 username_hash_, |
| 29 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot, | 30 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 55 selected_certs->end()); | 56 selected_certs->end()); |
| 56 DVLOG(1) << "filtered " << pre_size - selected_certs->size() << " of " | 57 DVLOG(1) << "filtered " << pre_size - selected_certs->size() << " of " |
| 57 << pre_size << " certs"; | 58 << pre_size << " certs"; |
| 58 } | 59 } |
| 59 | 60 |
| 60 void ClientCertStoreChromeOS::DidGetPrivateSlot( | 61 void ClientCertStoreChromeOS::DidGetPrivateSlot( |
| 61 const SSLCertRequestInfo* request, | 62 const SSLCertRequestInfo* request, |
| 62 CertificateList* selected_certs, | 63 CertificateList* selected_certs, |
| 63 const base::Closure& callback, | 64 const base::Closure& callback, |
| 64 crypto::ScopedPK11Slot private_slot) { | 65 crypto::ScopedPK11Slot private_slot) { |
| 65 profile_filter_.Init(crypto::GetPublicSlotForChromeOSUser(username_hash_), | 66 profile_filter_->Init(crypto::GetPublicSlotForChromeOSUser(username_hash_), |
| 66 private_slot.Pass()); | 67 private_slot.Pass()); |
| 67 ClientCertStoreNSS::GetClientCerts(*request, selected_certs, callback); | 68 ClientCertStoreNSS::GetClientCerts(*request, selected_certs, callback); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void ClientCertStoreChromeOS::InitForTesting( | 71 void ClientCertStoreChromeOS::InitForTesting( |
| 71 crypto::ScopedPK11Slot public_slot, | 72 crypto::ScopedPK11Slot public_slot, |
| 72 crypto::ScopedPK11Slot private_slot) { | 73 crypto::ScopedPK11Slot private_slot) { |
| 73 profile_filter_.Init(public_slot.Pass(), private_slot.Pass()); | 74 profile_filter_->Init(public_slot.Pass(), private_slot.Pass()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 bool ClientCertStoreChromeOS::SelectClientCertsForTesting( | 77 bool ClientCertStoreChromeOS::SelectClientCertsForTesting( |
| 77 const CertificateList& input_certs, | 78 const CertificateList& input_certs, |
| 78 const SSLCertRequestInfo& request, | 79 const SSLCertRequestInfo& request, |
| 79 CertificateList* selected_certs) { | 80 CertificateList* selected_certs) { |
| 80 CERTCertList* cert_list = CERT_NewCertList(); | 81 CERTCertList* cert_list = CERT_NewCertList(); |
| 81 if (!cert_list) | 82 if (!cert_list) |
| 82 return false; | 83 return false; |
| 83 for (size_t i = 0; i < input_certs.size(); ++i) { | 84 for (size_t i = 0; i < input_certs.size(); ++i) { |
| 84 CERT_AddCertToListTail( | 85 CERT_AddCertToListTail( |
| 85 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle())); | 86 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle())); |
| 86 } | 87 } |
| 87 | 88 |
| 88 GetClientCertsImpl(cert_list, request, false, selected_certs); | 89 GetClientCertsImpl(cert_list, request, false, selected_certs); |
| 89 CERT_DestroyCertList(cert_list); | 90 CERT_DestroyCertList(cert_list); |
| 90 return true; | 91 return true; |
| 91 } | 92 } |
| 92 | 93 |
| 93 | 94 |
| 94 } // namespace net | 95 } // namespace net |
| OLD | NEW |