[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
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] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame^] | 5 | #ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
6 | #define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 7 | |
8 | #include "base/basictypes.h" | ||||
9 | #include "base/ref_counted.h" | ||||
10 | #include "net/base/ssl_cert_request_info.h" | ||||
11 | |||||
12 | namespace net { | ||||
13 | class X509Certificate; | ||||
14 | } | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 15 | class URLRequest; |
16 | |||||
17 | // This class handles the approval and selection of a certificate for SSL client | ||||
18 | // authentication by the user. | ||||
19 | // It is self-owned and deletes itself when the UI reports the user selection or | ||||
20 | // when the URLRequest is cancelled. | ||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame^] | 21 | class SSLClientAuthHandler |
22 | : public base::RefCountedThreadSafe<SSLClientAuthHandler> { | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 23 | public: |
24 | SSLClientAuthHandler(URLRequest* request, | ||||
[email protected] | 0d3dc8e2 | 2009-11-03 02:27:01 | [diff] [blame] | 25 | net::SSLCertRequestInfo* cert_request_info); |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 26 | |
27 | // Asks the user to select a certificate and resumes the URL request with that | ||||
28 | // certificate. | ||||
29 | // Should only be called on the IO thread. | ||||
30 | void SelectCertificate(); | ||||
31 | |||||
32 | // Invoked when the request associated with this handler is cancelled. | ||||
33 | // Should only be called on the IO thread. | ||||
34 | void OnRequestCancelled(); | ||||
35 | |||||
36 | private: | ||||
[email protected] | e6e6ba4 | 2009-11-07 01:56:19 | [diff] [blame] | 37 | friend class base::RefCountedThreadSafe<SSLClientAuthHandler>; |
38 | |||||
39 | ~SSLClientAuthHandler(); | ||||
40 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 41 | // Asks the user for a cert. |
42 | // Called on the UI thread. | ||||
43 | void DoSelectCertificate(); | ||||
44 | |||||
45 | // Notifies that the user has selected a cert. | ||||
46 | // Called on the IO thread. | ||||
47 | void CertificateSelected(net::X509Certificate* cert); | ||||
48 | |||||
49 | // The URLRequest that triggered this client auth. | ||||
50 | URLRequest* request_; | ||||
51 | |||||
52 | // The certs to choose from. | ||||
53 | scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | ||||
54 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 55 | DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
56 | }; | ||||
57 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame^] | 58 | #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |