blob: 0a07d79c7fb00c477d555ec676a6a98156293fc2 [file] [log] [blame]
[email protected]ce2b62262009-06-27 05:11:411// 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]11f4857282009-11-13 19:56:175#ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
6#define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
[email protected]ce2b62262009-06-27 05:11:417
8#include "base/basictypes.h"
9#include "base/ref_counted.h"
10#include "net/base/ssl_cert_request_info.h"
11
12namespace net {
13class X509Certificate;
14}
[email protected]ce2b62262009-06-27 05:11:4115class 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]11f4857282009-11-13 19:56:1721class SSLClientAuthHandler
22 : public base::RefCountedThreadSafe<SSLClientAuthHandler> {
[email protected]ce2b62262009-06-27 05:11:4123 public:
24 SSLClientAuthHandler(URLRequest* request,
[email protected]0d3dc8e22009-11-03 02:27:0125 net::SSLCertRequestInfo* cert_request_info);
[email protected]ce2b62262009-06-27 05:11:4126
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]e6e6ba42009-11-07 01:56:1937 friend class base::RefCountedThreadSafe<SSLClientAuthHandler>;
38
39 ~SSLClientAuthHandler();
40
[email protected]ce2b62262009-06-27 05:11:4141 // 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]ce2b62262009-06-27 05:11:4155 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
56};
57
[email protected]11f4857282009-11-13 19:56:1758#endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_