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/callback.h" |
9 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.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 typedef base::Callback<crypto::CryptoModuleBlockingPasswordDelegate*( |
| 33 const std::string& /* server */)> PasswordDelegateFactory; |
| 34 // Set a factory that will be used to create a delegate for unlocking PKCS #11 |
| 35 // tokens. The host:port string of the server requesting client auth will be |
| 36 // passed to the factory. |
| 37 void set_password_delegate_factory( |
| 38 const PasswordDelegateFactory& password_delegate_factory); |
| 39 #endif |
| 40 |
26 private: | 41 private: |
27 friend class ClientCertStoreImplTest; | 42 friend class ClientCertStoreImplTest; |
28 | 43 |
29 // A hook for testing. Filters |input_certs| using the logic being used to | 44 // 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 | 45 // filter the system store when GetClientCerts() is called. Depending on the |
31 // implementation, this might be: | 46 // implementation, this might be: |
32 // - Implemented by creating a temporary in-memory store and filtering it | 47 // - Implemented by creating a temporary in-memory store and filtering it |
33 // using the common logic (preferable, currently on Windows). | 48 // using the common logic (preferable, currently on Windows). |
34 // - Implemented by creating a list of certificates that otherwise would be | 49 // - Implemented by creating a list of certificates that otherwise would be |
35 // extracted from the system store and filtering it using the common logic | 50 // extracted from the system store and filtering it using the common logic |
36 // (less adequate, currently on NSS and Mac). | 51 // (less adequate, currently on NSS and Mac). |
37 bool SelectClientCertsForTesting(const CertificateList& input_certs, | 52 bool SelectClientCertsForTesting(const CertificateList& input_certs, |
38 const SSLCertRequestInfo& cert_request_info, | 53 const SSLCertRequestInfo& cert_request_info, |
39 CertificateList* selected_certs); | 54 CertificateList* selected_certs); |
40 | 55 |
41 #if defined(OS_MACOSX) && !defined(OS_IOS) | 56 #if defined(OS_MACOSX) && !defined(OS_IOS) |
42 // Testing hook specific to Mac, where the internal logic recognizes preferred | 57 // Testing hook specific to Mac, where the internal logic recognizes preferred |
43 // certificates for particular domains. If the preferred certificate is | 58 // 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 | 59 // present in the output list (i.e. it doesn't get filtered out), it should |
45 // always come first. | 60 // always come first. |
46 bool SelectClientCertsGivenPreferredForTesting( | 61 bool SelectClientCertsGivenPreferredForTesting( |
47 const scoped_refptr<X509Certificate>& preferred_cert, | 62 const scoped_refptr<X509Certificate>& preferred_cert, |
48 const CertificateList& regular_certs, | 63 const CertificateList& regular_certs, |
49 const SSLCertRequestInfo& request, | 64 const SSLCertRequestInfo& request, |
50 CertificateList* selected_certs); | 65 CertificateList* selected_certs); |
51 #endif | 66 #endif |
52 | 67 |
| 68 #if defined(USE_NSS) |
| 69 // The factory for creating the delegate for requesting a password to a |
| 70 // PKCS #11 token. May be null. |
| 71 PasswordDelegateFactory password_delegate_factory_; |
| 72 #endif // defined(USE_NSS) |
| 73 |
53 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl); | 74 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl); |
54 }; | 75 }; |
55 | 76 |
56 } // namespace net | 77 } // namespace net |
57 | 78 |
58 #endif // NET_SSL_CLIENT_CERT_STORE_IMPL_H_ | 79 #endif // NET_SSL_CLIENT_CERT_STORE_IMPL_H_ |
OLD | NEW |