| 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 "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| 11 #include "net/ssl/client_cert_store.h" | 11 #include "net/ssl/client_cert_store.h" |
| 12 #include "net/ssl/ssl_cert_request_info.h" | 12 #include "net/ssl/ssl_cert_request_info.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 class NET_EXPORT ClientCertStoreImpl : public ClientCertStore { | 16 class NET_EXPORT ClientCertStoreImpl : public ClientCertStore { |
| 17 public: | 17 public: |
| 18 ClientCertStoreImpl() {} | 18 ClientCertStoreImpl() {} |
| 19 | |
| 20 virtual ~ClientCertStoreImpl() {} | 19 virtual ~ClientCertStoreImpl() {} |
| 21 | 20 |
| 22 // ClientCertStore: | 21 // ClientCertStore: |
| 23 virtual bool GetClientCerts(const SSLCertRequestInfo& cert_request_info, | 22 virtual bool GetClientCerts(const SSLCertRequestInfo& cert_request_info, |
| 24 CertificateList* selected_certs) OVERRIDE; | 23 CertificateList* selected_certs) OVERRIDE; |
| 25 | 24 |
| 26 private: | 25 private: |
| 27 FRIEND_TEST_ALL_PREFIXES(ClientCertStoreImplTest, EmptyQuery); | 26 friend class ClientCertStoreImplTest; |
| 28 FRIEND_TEST_ALL_PREFIXES(ClientCertStoreImplTest, AllIssuersAllowed); | |
| 29 FRIEND_TEST_ALL_PREFIXES(ClientCertStoreImplTest, CertAuthorityFiltering); | |
| 30 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 31 FRIEND_TEST_ALL_PREFIXES(ClientCertStoreImplTest, FilterOutThePreferredCert); | |
| 32 FRIEND_TEST_ALL_PREFIXES(ClientCertStoreImplTest, PreferredCertGoesFirst); | |
| 33 #endif | |
| 34 | 27 |
| 35 // A hook for testing. Filters |input_certs| using the logic being used to | 28 // A hook for testing. Filters |input_certs| using the logic being used to |
| 36 // filter the system store when GetClientCerts() is called. Depending on the | 29 // filter the system store when GetClientCerts() is called. Depending on the |
| 37 // implementation, this might be: | 30 // implementation, this might be: |
| 38 // - Implemented by creating a temporary in-memory store and filtering it | 31 // - Implemented by creating a temporary in-memory store and filtering it |
| 39 // using the common logic (preferable, currently on Windows). | 32 // using the common logic (preferable, currently on Windows). |
| 40 // - Implemented by creating a list of certificates that otherwise would be | 33 // - Implemented by creating a list of certificates that otherwise would be |
| 41 // extracted from the system store and filtering it using the common logic | 34 // extracted from the system store and filtering it using the common logic |
| 42 // (less adequate, currently on NSS and Mac). | 35 // (less adequate, currently on NSS and Mac). |
| 43 bool SelectClientCerts(const CertificateList& input_certs, | 36 bool SelectClientCertsForTesting(const CertificateList& input_certs, |
| 44 const SSLCertRequestInfo& cert_request_info, | 37 const SSLCertRequestInfo& cert_request_info, |
| 45 CertificateList* selected_certs); | 38 CertificateList* selected_certs); |
| 46 | 39 |
| 47 #if defined(OS_MACOSX) && !defined(OS_IOS) | 40 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 48 // Testing hook specific to Mac, where the internal logic recognizes preferred | 41 // Testing hook specific to Mac, where the internal logic recognizes preferred |
| 49 // certificates for particular domains. If the preferred certificate is | 42 // certificates for particular domains. If the preferred certificate is |
| 50 // present in the output list (i.e. it doesn't get filtered out), it should | 43 // present in the output list (i.e. it doesn't get filtered out), it should |
| 51 // always come first. | 44 // always come first. |
| 52 bool SelectClientCertsGivenPreferred( | 45 bool SelectClientCertsGivenPreferredForTesting( |
| 53 const scoped_refptr<X509Certificate>& preferred_cert, | 46 const scoped_refptr<X509Certificate>& preferred_cert, |
| 54 const CertificateList& regular_certs, | 47 const CertificateList& regular_certs, |
| 55 const SSLCertRequestInfo& request, | 48 const SSLCertRequestInfo& request, |
| 56 CertificateList* selected_certs); | 49 CertificateList* selected_certs); |
| 57 #endif | 50 #endif |
| 58 | 51 |
| 59 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl); | 52 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl); |
| 60 }; | 53 }; |
| 61 | 54 |
| 62 } // namespace net | 55 } // namespace net |
| 63 | 56 |
| 64 #endif // NET_SSL_CLIENT_CERT_STORE_IMPL_H_ | 57 #endif // NET_SSL_CLIENT_CERT_STORE_IMPL_H_ |
| OLD | NEW |