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 #ifndef CHROME_BROWSER_CHROMEOS_NET_CLIENT_CERT_STORE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_CLIENT_CERT_STORE_CHROMEOS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_NET_CLIENT_CERT_STORE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_CLIENT_CERT_STORE_CHROMEOS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
9 | 10 |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "net/ssl/client_cert_store_nss.h" | 14 #include "net/ssl/client_cert_store_nss.h" |
12 | 15 |
13 namespace net { | 16 namespace net { |
14 class X509Certificate; | 17 class X509Certificate; |
18 typedef std::vector<scoped_refptr<X509Certificate>> CertificateList; | |
davidben
2015/08/20 00:40:34
Ditto.
pneubeck (no reviews)
2015/08/20 07:18:23
Done.
| |
15 } | 19 } |
16 | 20 |
17 namespace chromeos { | 21 namespace chromeos { |
18 | 22 |
19 class ClientCertStoreChromeOS : public net::ClientCertStoreNSS { | 23 class CertificateProvider; |
24 | |
25 class ClientCertStoreChromeOS : public net::ClientCertStore { | |
20 public: | 26 public: |
21 class CertFilter { | 27 class CertFilter { |
22 public: | 28 public: |
23 virtual ~CertFilter() {} | 29 virtual ~CertFilter() {} |
24 | 30 |
25 // Initializes this filter. Returns true if it finished initialization, | 31 // Initializes this filter. Returns true if it finished initialization, |
26 // otherwise returns false and calls |callback| once the initialization is | 32 // otherwise returns false and calls |callback| once the initialization is |
27 // completed. | 33 // completed. |
28 // Must be called at most once. | 34 // Must be called at most once. |
29 virtual bool Init(const base::Closure& callback) = 0; | 35 virtual bool Init(const base::Closure& callback) = 0; |
30 | 36 |
31 // Returns true if |cert| is allowed to be used as a client certificate | 37 // Returns true if |cert| is allowed to be used as a client certificate |
32 // (e.g. for a certain browser context or user). | 38 // (e.g. for a certain browser context or user). |
33 // This is only called once initialization is finished, see Init(). | 39 // This is only called once initialization is finished, see Init(). |
34 virtual bool IsCertAllowed( | 40 virtual bool IsCertAllowed( |
35 const scoped_refptr<net::X509Certificate>& cert) const = 0; | 41 const scoped_refptr<net::X509Certificate>& cert) const = 0; |
36 }; | 42 }; |
37 | 43 |
38 // This ClientCertStore will return only client certs that pass the filter | 44 // This ClientCertStore will return client certs from NSS certificate |
39 // |cert_filter|. | 45 // databases that pass the filter |cert_filter| and additionally return |
46 // certificates provided by |cert_provider|. | |
40 ClientCertStoreChromeOS( | 47 ClientCertStoreChromeOS( |
48 scoped_ptr<CertificateProvider> cert_provider, | |
41 scoped_ptr<CertFilter> cert_filter, | 49 scoped_ptr<CertFilter> cert_filter, |
42 const PasswordDelegateFactory& password_delegate_factory); | 50 const net::ClientCertStoreNSS::PasswordDelegateFactory& |
davidben
2015/08/20 00:40:34
ProfileIOData seems to supply one. Whether it's ac
davidben
2015/08/20 00:40:34
Optional: If you want to keep the type inside Clie
pneubeck (no reviews)
2015/08/20 07:18:23
I'm rather sure that we can remove it, but let's d
| |
51 password_delegate_factory); | |
43 ~ClientCertStoreChromeOS() override; | 52 ~ClientCertStoreChromeOS() override; |
44 | 53 |
45 // net::ClientCertStoreNSS: | 54 // net::ClientCertStore: |
46 void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, | 55 void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, |
47 net::CertificateList* selected_certs, | 56 net::CertificateList* selected_certs, |
48 const base::Closure& callback) override; | 57 const base::Closure& callback) override; |
49 | 58 |
50 protected: | 59 private: |
51 // net::ClientCertStoreNSS: | 60 void GotAdditionalCerts(const net::SSLCertRequestInfo* request, |
52 void GetClientCertsImpl(CERTCertList* cert_list, | 61 net::CertificateList* selected_certs, |
53 const net::SSLCertRequestInfo& request, | 62 const base::Closure& callback, |
54 bool query_nssdb, | 63 const net::CertificateList& additional_certs); |
55 net::CertificateList* selected_certs) override; | |
56 | 64 |
57 private: | 65 void GetAndFilterCertsOnWorkerThread( |
58 void CertFilterInitialized(const net::SSLCertRequestInfo* request, | 66 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> |
59 net::CertificateList* selected_certs, | 67 password_delegate, |
60 const base::Closure& callback); | 68 const net::SSLCertRequestInfo* request, |
69 const net::CertificateList& additional_certs, | |
70 net::CertificateList* selected_certs); | |
61 | 71 |
72 scoped_ptr<CertificateProvider> cert_provider_; | |
62 scoped_ptr<CertFilter> cert_filter_; | 73 scoped_ptr<CertFilter> cert_filter_; |
63 | 74 |
75 // The factory for creating the delegate for requesting a password to a | |
76 // PKCS#11 token. May be null. | |
77 net::ClientCertStoreNSS::PasswordDelegateFactory password_delegate_factory_; | |
78 | |
64 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreChromeOS); | 79 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreChromeOS); |
65 }; | 80 }; |
66 | 81 |
67 } // namespace chromeos | 82 } // namespace chromeos |
68 | 83 |
69 #endif // CHROME_BROWSER_CHROMEOS_NET_CLIENT_CERT_STORE_CHROMEOS_H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_NET_CLIENT_CERT_STORE_CHROMEOS_H_ |
OLD | NEW |