OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 CHROMEOS_NETWORK_NETWORK_CERTIFICATE_HANDLER_H_ |
| 6 #define CHROMEOS_NETWORK_NETWORK_CERTIFICATE_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "chromeos/cert_loader.h" |
| 12 #include "chromeos/chromeos_export.h" |
| 13 |
| 14 namespace chromeos { |
| 15 |
| 16 // This class maintains user and server CA certificate lists for network |
| 17 // configuration UI. |
| 18 class CHROMEOS_EXPORT NetworkCertificateHandler : public CertLoader::Observer { |
| 19 public: |
| 20 class Observer { |
| 21 public: |
| 22 virtual ~Observer() {} |
| 23 |
| 24 // Called for any Observers whenever the certificates are loaded and any |
| 25 // time the certificate lists change. |
| 26 virtual void OnCertificatesChanged() = 0; |
| 27 |
| 28 protected: |
| 29 Observer() {} |
| 30 |
| 31 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 33 }; |
| 34 |
| 35 struct Certificate { |
| 36 Certificate(); |
| 37 ~Certificate(); |
| 38 Certificate(const Certificate& other); |
| 39 |
| 40 // A net::HashValue result used to uniquely identify certificates. |
| 41 std::string hash; |
| 42 |
| 43 // The X509 certificate issuer common name. |
| 44 std::string issued_by; |
| 45 |
| 46 // The X509 certificate common name or nickname. |
| 47 std::string issued_to; |
| 48 |
| 49 // The common name or nickname in Internationalized Domain Name format. |
| 50 std::string issued_to_ascii; |
| 51 |
| 52 // The PEM for Server CA certificates. |
| 53 std::string pem; |
| 54 |
| 55 // The PKCS#11 identifier in slot:id format for user certificates. |
| 56 std::string pkcs11_id; |
| 57 |
| 58 // True if a user certificate is stored in a hardware slot. |
| 59 bool hardware_backed = false; |
| 60 }; |
| 61 |
| 62 NetworkCertificateHandler(); |
| 63 ~NetworkCertificateHandler() override; |
| 64 |
| 65 void AddObserver(Observer* observer); |
| 66 void RemoveObserver(Observer* observer); |
| 67 |
| 68 const std::vector<Certificate>& server_ca_certificates() const { |
| 69 return server_ca_certificates_; |
| 70 } |
| 71 const std::vector<Certificate>& user_certificates() const { |
| 72 return user_certificates_; |
| 73 } |
| 74 |
| 75 void SetCertificatesForTest(const net::CertificateList& cert_list); |
| 76 void NotifyCertificatsChangedForTest(); |
| 77 |
| 78 private: |
| 79 // CertLoader::Observer |
| 80 void OnCertificatesLoaded(const net::CertificateList& cert_list, |
| 81 bool initial_load) override; |
| 82 |
| 83 void ProcessCertificates(const net::CertificateList& cert_list); |
| 84 |
| 85 base::ObserverList<NetworkCertificateHandler::Observer> observer_list_; |
| 86 |
| 87 std::vector<Certificate> server_ca_certificates_; |
| 88 std::vector<Certificate> user_certificates_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(NetworkCertificateHandler); |
| 91 }; |
| 92 |
| 93 } // namespace chromeos |
| 94 |
| 95 #endif // CHROMEOS_NETWORK_NETWORK_CERTIFICATE_HANDLER_H_ |
OLD | NEW |