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 void OnTpmIsEnabled(DBusMethodCallStatus call_status, | 83 void OnTpmIsEnabled(DBusMethodCallStatus call_status, |
87 bool tpm_is_enabled); | 84 bool tpm_is_enabled); |
88 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, | 85 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, |
89 bool is_tpm_token_ready); | 86 bool is_tpm_token_ready); |
90 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, | 87 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, |
91 const std::string& token_name, | 88 const std::string& token_name, |
92 const std::string& user_pin); | 89 const std::string& user_pin); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 129 |
133 // TODO(stevenjb): Use multiple factories to track callback chains. | 130 // TODO(stevenjb): Use multiple factories to track callback chains. |
134 base::WeakPtrFactory<CertLoader> weak_ptr_factory_; | 131 base::WeakPtrFactory<CertLoader> weak_ptr_factory_; |
135 | 132 |
136 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 133 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
137 }; | 134 }; |
138 | 135 |
139 } // namespace chromeos | 136 } // namespace chromeos |
140 | 137 |
141 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ | 138 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ |
OLD | NEW |