blob: de90e5ac89dd64461d5356c50e2b3d81169bc74e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
#define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
#pragma once
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "chrome/browser/chrome_thread.h"
#include "net/base/ssl_cert_request_info.h"
namespace net {
class X509Certificate;
}
class URLRequest;
// This class handles the approval and selection of a certificate for SSL client
// authentication by the user.
// It is self-owned and deletes itself when the UI reports the user selection or
// when the URLRequest is cancelled.
class SSLClientAuthHandler
: public base::RefCountedThreadSafe<SSLClientAuthHandler,
ChromeThread::DeleteOnIOThread> {
public:
SSLClientAuthHandler(URLRequest* request,
net::SSLCertRequestInfo* cert_request_info);
// Asks the user to select a certificate and resumes the URL request with that
// certificate.
// Should only be called on the IO thread.
void SelectCertificate();
// Invoked when the request associated with this handler is cancelled.
// Should only be called on the IO thread.
void OnRequestCancelled();
// Calls DoCertificateSelected on the I/O thread.
// Called on the UI thread after the user has made a selection (which may
// be long after DoSelectCertificate returns, if the UI is modeless/async.)
void CertificateSelected(net::X509Certificate* cert);
// Returns the SSLCertRequestInfo for this handler.
net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; }
private:
friend class ChromeThread;
friend class DeleteTask<SSLClientAuthHandler>;
~SSLClientAuthHandler();
// Notifies that the user has selected a cert.
// Called on the IO thread.
void DoCertificateSelected(net::X509Certificate* cert);
// The URLRequest that triggered this client auth.
URLRequest* request_;
// The certs to choose from.
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
};
#endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
|