Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 6 #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "net/ssl/ssl_cert_request_info.h" | 15 #include "net/ssl/ssl_cert_request_info.h" |
| 16 #include "net/ssl/ssl_private_key.h" | |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 class ClientCertStore; | 19 class ClientCertStore; |
| 19 class URLRequest; | 20 class URLRequest; |
| 20 class X509Certificate; | 21 class X509Certificate; |
| 21 } // namespace net | 22 } // namespace net |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 // This class handles the approval and selection of a certificate for SSL client | 26 // This class handles the approval and selection of a certificate for SSL client |
| 26 // authentication by the user. Should only be used on the IO thread. If the | 27 // authentication by the user. Should only be used on the IO thread. If the |
| 27 // SSLClientAuthHandler is destroyed before the certificate is selected, the | 28 // SSLClientAuthHandler is destroyed before the certificate is selected, the |
| 28 // selection is canceled and the delegate never called. | 29 // selection is canceled and the delegate never called. |
| 29 class SSLClientAuthHandler { | 30 class SSLClientAuthHandler { |
| 30 public: | 31 public: |
| 31 // Delegate interface for SSLClientAuthHandler. Method implementations may | 32 // Delegate interface for SSLClientAuthHandler. Method implementations may |
| 32 // delete the handler when called. | 33 // delete the handler when called. |
| 33 class CONTENT_EXPORT Delegate { | 34 class CONTENT_EXPORT Delegate { |
| 34 public: | 35 public: |
| 35 Delegate() {} | 36 Delegate() {} |
| 36 | 37 |
| 37 // Called to continue the request with |cert|. |cert| may be nullptr. | 38 // Called to continue the request with |cert| and |private_key|. |cert| and |
| 38 virtual void ContinueWithCertificate(net::X509Certificate* cert) = 0; | 39 // |private_key| |
| 40 // may be nullptr. | |
|
davidben
2015/10/13 20:32:15
Nit: wrapping.
svaldez
2015/10/14 15:06:18
Done.
| |
| 41 virtual void ContinueWithCertificate(net::X509Certificate* cert, | |
| 42 net::SSLPrivateKey* private_key) = 0; | |
| 39 | 43 |
| 40 // Called to cancel the certificate selection and abort the request. | 44 // Called to cancel the certificate selection and abort the request. |
| 41 virtual void CancelCertificateSelection() = 0; | 45 virtual void CancelCertificateSelection() = 0; |
| 42 | 46 |
| 43 protected: | 47 protected: |
| 44 virtual ~Delegate() {} | 48 virtual ~Delegate() {} |
| 45 | 49 |
| 46 private: | 50 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(Delegate); | 51 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 48 }; | 52 }; |
| 49 | 53 |
| 50 // Creates a new SSLClientAuthHandler. The caller ensures that the handler | 54 // Creates a new SSLClientAuthHandler. The caller ensures that the handler |
| 51 // does not outlive |request| or |delegate|. | 55 // does not outlive |request| or |delegate|. |
| 52 SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, | 56 SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, |
| 53 net::URLRequest* request, | 57 net::URLRequest* request, |
| 54 net::SSLCertRequestInfo* cert_request_info, | 58 net::SSLCertRequestInfo* cert_request_info, |
| 55 Delegate* delegate); | 59 Delegate* delegate); |
| 56 ~SSLClientAuthHandler(); | 60 ~SSLClientAuthHandler(); |
| 57 | 61 |
| 58 // Selects a certificate and resumes the URL request with that certificate. | 62 // Selects a certificate and resumes the URL request with that certificate. |
| 59 void SelectCertificate(); | 63 void SelectCertificate(); |
| 60 | 64 |
| 61 // Called to continue the request associated with |handler| using |cert|. This | 65 // Called to continue the request associated with |handler| using |cert|. This |
| 62 // is static to avoid deleting |handler| while it is on the stack. | 66 // is static to avoid deleting |handler| while it is on the stack. |
| 63 static void ContinueWithCertificate( | 67 static void ContinueWithCertificate( |
| 64 const base::WeakPtr<SSLClientAuthHandler>& handler, | 68 const base::WeakPtr<SSLClientAuthHandler>& handler, |
| 65 net::X509Certificate* cert); | 69 net::X509Certificate* cert, |
| 70 net::SSLPrivateKey* pkey); | |
| 66 | 71 |
| 67 // Called to abort the request associated with |handler|. This is static to | 72 // Called to abort the request associated with |handler|. This is static to |
| 68 // avoid deleting |handler| while it is on the stack. | 73 // avoid deleting |handler| while it is on the stack. |
| 69 static void CancelCertificateSelection( | 74 static void CancelCertificateSelection( |
| 70 const base::WeakPtr<SSLClientAuthHandler>& handler); | 75 const base::WeakPtr<SSLClientAuthHandler>& handler); |
| 71 | 76 |
| 72 private: | 77 private: |
| 73 class Core; | 78 class Core; |
| 74 | 79 |
| 75 // Called when |core_| is done retrieving the cert list. | 80 // Called when |core_| is done retrieving the cert list. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 90 Delegate* delegate_; | 95 Delegate* delegate_; |
| 91 | 96 |
| 92 base::WeakPtrFactory<SSLClientAuthHandler> weak_factory_; | 97 base::WeakPtrFactory<SSLClientAuthHandler> weak_factory_; |
| 93 | 98 |
| 94 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); | 99 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
| 95 }; | 100 }; |
| 96 | 101 |
| 97 } // namespace content | 102 } // namespace content |
| 98 | 103 |
| 99 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 104 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
| OLD | NEW |