OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 CHROMEOS_NETWORK_CERT_LOADER_H_ | 5 #ifndef CHROMEOS_NETWORK_CERT_LOADER_H_ |
6 #define CHROMEOS_NETWORK_CERT_LOADER_H_ | 6 #define CHROMEOS_NETWORK_CERT_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/observer_list_threadsafe.h" | 13 #include "base/observer_list_threadsafe.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
16 #include "chromeos/dbus/dbus_method_call_status.h" | 16 #include "chromeos/dbus/dbus_method_call_status.h" |
17 #include "chromeos/login/login_state.h" | 17 #include "chromeos/login/login_state.h" |
| 18 #include "chromeos/network/network_handler.h" |
18 #include "net/cert/cert_database.h" | 19 #include "net/cert/cert_database.h" |
19 #include "net/cert/x509_certificate.h" | 20 #include "net/cert/x509_certificate.h" |
20 | 21 |
21 namespace crypto { | 22 namespace crypto { |
22 class SymmetricKey; | 23 class SymmetricKey; |
23 } | 24 } |
24 | 25 |
25 namespace chromeos { | 26 namespace chromeos { |
26 | 27 |
27 // This class is responsible for initializing the TPM token and loading | 28 // This class is responsible for initializing the TPM token and loading |
(...skipping 14 matching lines...) Expand all Loading... |
42 virtual void OnCertificatesLoaded(const net::CertificateList& cert_list, | 43 virtual void OnCertificatesLoaded(const net::CertificateList& cert_list, |
43 bool initial_load) = 0; | 44 bool initial_load) = 0; |
44 | 45 |
45 protected: | 46 protected: |
46 Observer() {} | 47 Observer() {} |
47 | 48 |
48 private: | 49 private: |
49 DISALLOW_COPY_AND_ASSIGN(Observer); | 50 DISALLOW_COPY_AND_ASSIGN(Observer); |
50 }; | 51 }; |
51 | 52 |
52 // Manage the global instance. | 53 virtual ~CertLoader(); |
53 static void Initialize(); | |
54 static void Shutdown(); | |
55 static CertLoader* Get(); | |
56 static bool IsInitialized(); | |
57 | 54 |
58 void AddObserver(CertLoader::Observer* observer); | 55 void AddObserver(CertLoader::Observer* observer); |
59 void RemoveObserver(CertLoader::Observer* observer); | 56 void RemoveObserver(CertLoader::Observer* observer); |
60 | 57 |
61 // Returns true when the certificate list has been requested but not loaded. | 58 // Returns true when the certificate list has been requested but not loaded. |
62 bool CertificatesLoading() const; | 59 bool CertificatesLoading() const; |
63 | 60 |
64 // Returns true if the TPM is available for hardware-backed certificates. | 61 // Returns true if the TPM is available for hardware-backed certificates. |
65 bool IsHardwareBacked() const; | 62 bool IsHardwareBacked() const; |
66 | 63 |
67 std::string GetPkcs11IdForCert(const net::X509Certificate& cert) const; | 64 std::string GetPkcs11IdForCert(const net::X509Certificate& cert) const; |
68 | 65 |
69 bool certificates_loaded() const { return certificates_loaded_; } | 66 bool certificates_loaded() const { return certificates_loaded_; } |
70 | 67 |
71 // TPM info is only valid once the TPM is available (IsHardwareBacked is | 68 // TPM info is only valid once the TPM is available (IsHardwareBacked is |
72 // true). Otherwise empty strings will be returned. | 69 // true). Otherwise empty strings will be returned. |
73 const std::string& tpm_token_name() const { return tpm_token_name_; } | 70 const std::string& tpm_token_name() const { return tpm_token_name_; } |
74 const std::string& tpm_token_slot() const { return tpm_token_slot_; } | 71 const std::string& tpm_token_slot() const { return tpm_token_slot_; } |
75 const std::string& tpm_user_pin() const { return tpm_user_pin_; } | 72 const std::string& tpm_user_pin() const { return tpm_user_pin_; } |
76 | 73 |
77 // This will be empty until certificates_loaded() is true. | 74 // This will be empty until certificates_loaded() is true. |
78 const net::CertificateList& cert_list() const { return cert_list_; } | 75 const net::CertificateList& cert_list() const { return cert_list_; } |
79 | 76 |
80 private: | 77 private: |
| 78 friend class NetworkHandler; |
81 CertLoader(); | 79 CertLoader(); |
82 virtual ~CertLoader(); | |
83 | 80 |
84 void RequestCertificates(); | 81 void RequestCertificates(); |
85 | 82 |
86 // This is the cyclic chain of callbacks to initialize the TPM token and to | 83 // This is the cyclic chain of callbacks to initialize the TPM token and to |
87 // kick off the update of the certificate list. | 84 // kick off the update of the certificate list. |
88 void InitializeTokenAndLoadCertificates(); | 85 void InitializeTokenAndLoadCertificates(); |
89 void RetryTokenInitializationLater(); | 86 void RetryTokenInitializationLater(); |
90 void OnTpmIsEnabled(DBusMethodCallStatus call_status, | 87 void OnTpmIsEnabled(DBusMethodCallStatus call_status, |
91 bool tpm_is_enabled); | 88 bool tpm_is_enabled); |
92 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, | 89 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // This factory should be used only for callbacks during updating the | 148 // This factory should be used only for callbacks during updating the |
152 // certificate list. | 149 // certificate list. |
153 base::WeakPtrFactory<CertLoader> update_certificates_factory_; | 150 base::WeakPtrFactory<CertLoader> update_certificates_factory_; |
154 | 151 |
155 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 152 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
156 }; | 153 }; |
157 | 154 |
158 } // namespace chromeos | 155 } // namespace chromeos |
159 | 156 |
160 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ | 157 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ |
OLD | NEW |