| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_SSL_CLIENT_CERT_STORE_IMPL_H_ | 5 #ifndef NET_SSL_CLIENT_CERT_STORE_IMPL_H_ |
| 6 #define NET_SSL_CLIENT_CERT_STORE_IMPL_H_ | 6 #define NET_SSL_CLIENT_CERT_STORE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 11 #include "net/ssl/client_cert_store.h" | 12 #include "net/ssl/client_cert_store.h" |
| 12 #include "net/ssl/ssl_cert_request_info.h" | 13 #include "net/ssl/ssl_cert_request_info.h" |
| 13 | 14 |
| 15 namespace crypto { |
| 16 class CryptoModuleBlockingPasswordDelegate; |
| 17 } |
| 18 |
| 14 namespace net { | 19 namespace net { |
| 15 | 20 |
| 16 class NET_EXPORT ClientCertStoreImpl : public ClientCertStore { | 21 class NET_EXPORT ClientCertStoreImpl : public ClientCertStore { |
| 17 public: | 22 public: |
| 18 ClientCertStoreImpl() {} | 23 ClientCertStoreImpl(); |
| 19 virtual ~ClientCertStoreImpl() {} | 24 virtual ~ClientCertStoreImpl(); |
| 20 | 25 |
| 21 // ClientCertStore: | 26 // ClientCertStore: |
| 22 virtual void GetClientCerts(const SSLCertRequestInfo& cert_request_info, | 27 virtual void GetClientCerts(const SSLCertRequestInfo& cert_request_info, |
| 23 CertificateList* selected_certs, | 28 CertificateList* selected_certs, |
| 24 const base::Closure& callback) OVERRIDE; | 29 const base::Closure& callback) OVERRIDE; |
| 25 | 30 |
| 31 #if defined(USE_NSS) |
| 32 void set_password_delegate( |
| 33 crypto::CryptoModuleBlockingPasswordDelegate* password_delegate); |
| 34 #endif |
| 35 |
| 26 private: | 36 private: |
| 27 friend class ClientCertStoreImplTest; | 37 friend class ClientCertStoreImplTest; |
| 28 | 38 |
| 29 // A hook for testing. Filters |input_certs| using the logic being used to | 39 // A hook for testing. Filters |input_certs| using the logic being used to |
| 30 // filter the system store when GetClientCerts() is called. Depending on the | 40 // filter the system store when GetClientCerts() is called. Depending on the |
| 31 // implementation, this might be: | 41 // implementation, this might be: |
| 32 // - Implemented by creating a temporary in-memory store and filtering it | 42 // - Implemented by creating a temporary in-memory store and filtering it |
| 33 // using the common logic (preferable, currently on Windows). | 43 // using the common logic (preferable, currently on Windows). |
| 34 // - Implemented by creating a list of certificates that otherwise would be | 44 // - Implemented by creating a list of certificates that otherwise would be |
| 35 // extracted from the system store and filtering it using the common logic | 45 // extracted from the system store and filtering it using the common logic |
| 36 // (less adequate, currently on NSS and Mac). | 46 // (less adequate, currently on NSS and Mac). |
| 37 bool SelectClientCertsForTesting(const CertificateList& input_certs, | 47 bool SelectClientCertsForTesting(const CertificateList& input_certs, |
| 38 const SSLCertRequestInfo& cert_request_info, | 48 const SSLCertRequestInfo& cert_request_info, |
| 39 CertificateList* selected_certs); | 49 CertificateList* selected_certs); |
| 40 | 50 |
| 41 #if defined(OS_MACOSX) && !defined(OS_IOS) | 51 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 42 // Testing hook specific to Mac, where the internal logic recognizes preferred | 52 // Testing hook specific to Mac, where the internal logic recognizes preferred |
| 43 // certificates for particular domains. If the preferred certificate is | 53 // certificates for particular domains. If the preferred certificate is |
| 44 // present in the output list (i.e. it doesn't get filtered out), it should | 54 // present in the output list (i.e. it doesn't get filtered out), it should |
| 45 // always come first. | 55 // always come first. |
| 46 bool SelectClientCertsGivenPreferredForTesting( | 56 bool SelectClientCertsGivenPreferredForTesting( |
| 47 const scoped_refptr<X509Certificate>& preferred_cert, | 57 const scoped_refptr<X509Certificate>& preferred_cert, |
| 48 const CertificateList& regular_certs, | 58 const CertificateList& regular_certs, |
| 49 const SSLCertRequestInfo& request, | 59 const SSLCertRequestInfo& request, |
| 50 CertificateList* selected_certs); | 60 CertificateList* selected_certs); |
| 51 #endif | 61 #endif |
| 52 | 62 |
| 63 #if defined(USE_NSS) |
| 64 // The callback for requesting a password to a PKCS#11 token. |
| 65 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> password_delegate_; |
| 66 #endif // defined(USE_NSS) |
| 67 |
| 53 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl); | 68 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl); |
| 54 }; | 69 }; |
| 55 | 70 |
| 56 } // namespace net | 71 } // namespace net |
| 57 | 72 |
| 58 #endif // NET_SSL_CLIENT_CERT_STORE_IMPL_H_ | 73 #endif // NET_SSL_CLIENT_CERT_STORE_IMPL_H_ |
| OLD | NEW |