| 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 bool certificates_loaded() const { return certificates_loaded_; } | 64 bool certificates_loaded() const { return certificates_loaded_; } |
| 68 | 65 |
| 69 // TPM info is only valid once the TPM is available (IsHardwareBacked is | 66 // TPM info is only valid once the TPM is available (IsHardwareBacked is |
| 70 // true). Otherwise empty strings will be returned. | 67 // true). Otherwise empty strings will be returned. |
| 71 const std::string& tpm_token_name() const { return tpm_token_name_; } | 68 const std::string& tpm_token_name() const { return tpm_token_name_; } |
| 72 const std::string& tpm_token_slot() const { return tpm_token_slot_; } | 69 const std::string& tpm_token_slot() const { return tpm_token_slot_; } |
| 73 const std::string& tpm_user_pin() const { return tpm_user_pin_; } | 70 const std::string& tpm_user_pin() const { return tpm_user_pin_; } |
| 74 | 71 |
| 75 // This will be empty until certificates_loaded() is true. | 72 // This will be empty until certificates_loaded() is true. |
| 76 const net::CertificateList& cert_list() const { return cert_list_; } | 73 const net::CertificateList& cert_list() const { return cert_list_; } |
| 77 | 74 |
| 78 private: | 75 private: |
| 76 friend class NetworkHandler; |
| 79 CertLoader(); | 77 CertLoader(); |
| 80 virtual ~CertLoader(); | |
| 81 | 78 |
| 82 void RequestCertificates(); | 79 void RequestCertificates(); |
| 83 | 80 |
| 84 void OnTpmIsEnabled(DBusMethodCallStatus call_status, | 81 void OnTpmIsEnabled(DBusMethodCallStatus call_status, |
| 85 bool tpm_is_enabled); | 82 bool tpm_is_enabled); |
| 86 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, | 83 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, |
| 87 bool is_tpm_token_ready); | 84 bool is_tpm_token_ready); |
| 88 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, | 85 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, |
| 89 const std::string& token_name, | 86 const std::string& token_name, |
| 90 const std::string& user_pin); | 87 const std::string& user_pin); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 127 |
| 131 // TODO(stevenjb): Use multiple factories to track callback chains. | 128 // TODO(stevenjb): Use multiple factories to track callback chains. |
| 132 base::WeakPtrFactory<CertLoader> weak_ptr_factory_; | 129 base::WeakPtrFactory<CertLoader> weak_ptr_factory_; |
| 133 | 130 |
| 134 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 131 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
| 135 }; | 132 }; |
| 136 | 133 |
| 137 } // namespace chromeos | 134 } // namespace chromeos |
| 138 | 135 |
| 139 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ | 136 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ |
| OLD | NEW |