Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/browser/ui/android/ssl_client_certificate_request.h

Issue 12374020: Add Android support for SSL client authentication to the browser layer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@client-cert-test
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 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
5 #ifndef CHROME_BROWSER_UI_ANDROID_SSL_CLIENT_CERTIFICATE_REQUEST_H_
6 #define CHROME_BROWSER_UI_ANDROID_SSL_CLIENT_CERTIFICATE_REQUEST_H_
7
8 #include <jni.h>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/ssl/ssl_client_certificate_selector.h"
14 #include "net/base/openssl_client_key_store.h"
15
16 namespace net {
17 class SSLCertRequestInfo;
18 class X509Certificate;
19 } // namespace net
20
21 namespace browser {
22 namespace android {
23
24 // This class is the C++ equivalent for the Java class of the same
25 // name defined in org.chromium.browser.SSLClientCertificateRequest.java.
26 // See the comments in ssl_client_certificate_selector.cc for more details
27 // on how this is used.
28 class SSLClientCertificateRequest
29 : public base::RefCountedThreadSafe<SSLClientCertificateRequest> {
30 public:
31 SSLClientCertificateRequest(
32 net::SSLCertRequestInfo* cert_request_info,
33 const chrome::SelectCertificateCallback& callback);
Ryan Sleevi 2013/02/28 19:42:42 nit: indent to 4 spaces
digit1 2013/03/04 19:03:20 Done.
34
35 // Start an asynchronous request for a client certificate.
36 //
37 // This launches a system UI dialog to let the user select
38 // an appropriate client certificate, if any, or even install one.
39 // Once the user chooses a certificate (or cancels the dialog),
40 // OnRequestCompletion() will later be called on the UI thread.
41 //
42 // Returns true on success. Note that failure only means that there
43 // were problems to launch the system UI dialog, and isn't related
44 // to user choice.
45 bool Start();
46
47 // Called from Java through JNI when the request completes or was
48 // cancelled by the user. The only reason this is public is to ensure
49 // it can be called from Java through the auto-generated JNI wrapper.
50 // |env| is the current threads' JNIEnv handle.
51 // |obj| is a JNI reference to the Java object instance associated
52 // with this request.
53 // |private_key_alias| is a JNI string reference to the private key
54 // unique name.
55 // |encoded_chain_ref| is a JNI reference to an array of byte arrays
56 // modelling the encoded client certificate chain. Will be null if
57 // the request was cancelled or an error occured.
58 // |private_key_ref| is a JNI reference to the PrivateKey object for
59 // the client certificate. Will be null if the request was cancelled
60 // or an error occured.
61 // Note that this always destroys the C++ request object.
62 void OnRequestCompletion(JNIEnv* env,
63 jobject obj,
64 jstring private_key_alias_ref,
65 jobjectArray encoded_chain_ref,
66 jobject private_key_ref);
67
68 private:
69 friend class base::RefCountedThreadSafe<SSLClientCertificateRequest>;
70
71 ~SSLClientCertificateRequest();
72
73 // Must be called on the IO thread before DoSendClientCertificate
74 // to ensure the private key is properly recorded in memory before
75 // sending it to the request's initiator.
76 void DoRecordClientCertificateKey();
77
78 // Must be called on the UI thread after DoRecordClientCertificate to
79 // send the final client certificate.
80 void DoSendClientCertificate();
81
82 net::SSLCertRequestInfo* cert_request_info_;
83 scoped_refptr<net::X509Certificate> client_cert_;
84 net::OpenSSLClientKeyStore::ScopedEVP_PKEY private_key_;
85 chrome::SelectCertificateCallback callback_;
86
87 DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateRequest);
88 };
89
90 } // namespace android
91 } // namespace browser
92
93 #endif // CHROME_BROWSER_UI_ANDROID_SSL_CLIENT_CERTIFICATE_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698