[email protected] | f786717 | 2012-07-11 07:04:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
6 | #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 7 | |
8 | #include "base/basictypes.h" | ||||
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 9 | #include "base/callback.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 11 | #include "base/memory/weak_ptr.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 12 | #include "content/public/browser/browser_thread.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 13 | #include "net/ssl/ssl_cert_request_info.h" |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 14 | |
15 | namespace net { | ||||
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame] | 16 | class ClientCertStore; |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 17 | class URLRequest; |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 18 | class X509Certificate; |
19 | } // namespace net | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 20 | |
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 21 | namespace content { |
22 | |||||
mattm | e18bf1d | 2014-11-25 22:33:28 | [diff] [blame] | 23 | // This class handles the approval and selection of a certificate for SSL client |
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 24 | // authentication by the user. Should only be used on the IO thread. If the |
25 | // SSLClientAuthHandler is destroyed before the certificate is selected, the | ||||
26 | // selection is canceled and the callback never called. | ||||
27 | class SSLClientAuthHandler { | ||||
mattm | e18bf1d | 2014-11-25 22:33:28 | [diff] [blame] | 28 | public: |
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 29 | typedef base::Callback<void(net::X509Certificate*)> CertificateCallback; |
30 | |||||
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame] | 31 | SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, |
32 | net::URLRequest* request, | ||||
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 33 | net::SSLCertRequestInfo* cert_request_info, |
34 | const CertificateCallback& callback); | ||||
35 | ~SSLClientAuthHandler(); | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 36 | |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 37 | // Selects a certificate and resumes the URL request with that certificate. |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 38 | void SelectCertificate(); |
39 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 40 | private: |
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame] | 41 | // Called when ClientCertStore is done retrieving the cert list. |
42 | void DidGetClientCerts(); | ||||
43 | |||||
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 44 | // Called when the user has selected a cert. |
45 | void CertificateSelected(net::X509Certificate* cert); | ||||
[email protected] | c6176905 | 2011-05-18 18:38:35 | [diff] [blame] | 46 | |
[email protected] | 6981d963 | 2010-11-30 21:34:02 | [diff] [blame] | 47 | // The net::URLRequest that triggered this client auth. |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 48 | net::URLRequest* request_; |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 49 | |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 50 | // The certs to choose from. |
51 | scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | ||||
52 | |||||
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame] | 53 | scoped_ptr<net::ClientCertStore> client_cert_store_; |
54 | |||||
robliao | e9651b35 | 2014-11-26 18:01:50 | [diff] [blame^] | 55 | // The callback to call when the certificate is selected. |
56 | CertificateCallback callback_; | ||||
57 | |||||
58 | base::WeakPtrFactory<SSLClientAuthHandler> weak_factory_; | ||||
59 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 60 | DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
61 | }; | ||||
62 | |||||
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 63 | } // namespace content |
64 | |||||
[email protected] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 65 | #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |