OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 bool CertificatesLoaded() const; | 61 bool CertificatesLoaded() const; |
62 | 62 |
63 // Returns true if the TPM is available for hardware-backed certificates. | 63 // Returns true if the TPM is available for hardware-backed certificates. |
64 bool IsHardwareBacked() const; | 64 bool IsHardwareBacked() const; |
65 | 65 |
66 // Retruns the number of certificates available for |type|. | 66 // Retruns the number of certificates available for |type|. |
67 int NumCertificates(CertType type) const; | 67 int NumCertificates(CertType type) const; |
68 | 68 |
69 // Retreives the certificate property for |type| at |index|. | 69 // Retreives the certificate property for |type| at |index|. |
70 base::string16 GetCertDisplayStringAt(CertType type, int index) const; | 70 base::string16 GetCertDisplayStringAt(CertType type, int index) const; |
71 std::string GetCertPEMAt(CertType type, int index) const; | 71 std::string GetServerCACertPEMAt(int index) const; |
72 std::string GetCertPkcs11IdAt(CertType type, int index) const; | 72 std::string GetUserCertPkcs11IdAt(int index) const; |
73 bool IsCertHardwareBackedAt(CertType type, int index) const; | 73 bool IsCertHardwareBackedAt(CertType type, int index) const; |
74 | 74 |
75 // Returns the index of a Certificate matching |pem_encoded| or -1 if none | 75 // Returns the index of a Certificate matching |pem_encoded| or -1 if none |
76 // found. This function may be slow depending on the number of stored | 76 // found. This function may be slow depending on the number of stored |
77 // certificates. | 77 // certificates. |
78 // TOOD(pneubeck): Either make this more efficient, asynchronous or get rid of | 78 // TOOD(pneubeck): Either make this more efficient, asynchronous or get rid of |
79 // it. | 79 // it. |
80 int GetCertIndexByPEM(CertType type, const std::string& pem_encoded) const; | 80 int GetServerCACertIndexByPEM(const std::string& pem_encoded) const; |
81 // Same as above but for a PKCS#11 id. TODO(stevenjb): Replace this with a | 81 // Same as above but for a PKCS#11 id. |
82 // better mechanism for uniquely idientifying certificates, crbug.com/236978. | 82 int GetUserCertIndexByPkcs11Id(const std::string& pkcs11_id) const; |
83 int GetCertIndexByPkcs11Id(CertType type, const std::string& pkcs11_id) const; | |
84 | 83 |
85 // CertLoader::Observer | 84 // CertLoader::Observer |
86 virtual void OnCertificatesLoaded(const net::CertificateList&, | 85 virtual void OnCertificatesLoaded(const net::CertificateList&, |
87 bool initial_load) OVERRIDE; | 86 bool initial_load) OVERRIDE; |
88 | 87 |
89 private: | 88 private: |
90 CertLibrary(); | 89 CertLibrary(); |
91 virtual ~CertLibrary(); | 90 virtual ~CertLibrary(); |
92 | 91 |
93 net::X509Certificate* GetCertificateAt(CertType type, int index) const; | 92 net::X509Certificate* GetCertificateAt(CertType type, int index) const; |
94 const net::CertificateList& GetCertificateListForType(CertType type) const; | 93 const net::CertificateList& GetCertificateListForType(CertType type) const; |
95 | 94 |
96 ObserverList<CertLibrary::Observer> observer_list_; | 95 ObserverList<CertLibrary::Observer> observer_list_; |
97 | 96 |
98 // Sorted certificate lists | 97 // Sorted certificate lists |
99 net::CertificateList certs_; | 98 net::CertificateList certs_; |
100 net::CertificateList user_certs_; | 99 net::CertificateList user_certs_; |
101 net::CertificateList server_certs_; | 100 net::CertificateList server_certs_; |
102 net::CertificateList server_ca_certs_; | 101 net::CertificateList server_ca_certs_; |
103 | 102 |
104 DISALLOW_COPY_AND_ASSIGN(CertLibrary); | 103 DISALLOW_COPY_AND_ASSIGN(CertLibrary); |
105 }; | 104 }; |
106 | 105 |
107 } // namespace chromeos | 106 } // namespace chromeos |
108 | 107 |
109 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_ | 108 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_ |
OLD | NEW |