OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ONC_ONC_UTILS_H_ | 5 #ifndef CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
6 #define CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 6 #define CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <string> | 9 #include <string> |
| 10 #include <vector> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
13 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
14 #include "chromeos/network/onc/onc_constants.h" | 16 #include "chromeos/network/onc/onc_constants.h" |
15 #include "net/cert/x509_certificate.h" | |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class DictionaryValue; | 19 class DictionaryValue; |
19 class ListValue; | 20 class ListValue; |
20 } | 21 } |
21 | 22 |
| 23 namespace net { |
| 24 class X509Certificate; |
| 25 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 26 } |
| 27 |
22 namespace chromeos { | 28 namespace chromeos { |
23 namespace onc { | 29 namespace onc { |
24 | 30 |
25 struct OncValueSignature; | 31 struct OncValueSignature; |
26 | 32 |
27 // A valid but empty (no networks and no certificates) and unencrypted | 33 // A valid but empty (no networks and no certificates) and unencrypted |
28 // configuration. | 34 // configuration. |
29 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; | 35 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; |
30 | 36 |
31 // Parses |json| according to the JSON format. If |json| is a JSON formatted | 37 // Parses |json| according to the JSON format. If |json| is a JSON formatted |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // and Certificates of |onc_blob|. Returns false if any validation errors or | 87 // and Certificates of |onc_blob|. Returns false if any validation errors or |
82 // warnings occurred. Still, some networks or certificates might be added to the | 88 // warnings occurred. Still, some networks or certificates might be added to the |
83 // output lists and should be further processed by the caller. | 89 // output lists and should be further processed by the caller. |
84 CHROMEOS_EXPORT bool ParseAndValidateOncForImport( | 90 CHROMEOS_EXPORT bool ParseAndValidateOncForImport( |
85 const std::string& onc_blob, | 91 const std::string& onc_blob, |
86 ONCSource onc_source, | 92 ONCSource onc_source, |
87 const std::string& passphrase, | 93 const std::string& passphrase, |
88 base::ListValue* network_configs, | 94 base::ListValue* network_configs, |
89 base::ListValue* certificates); | 95 base::ListValue* certificates); |
90 | 96 |
| 97 // Get the hexadecimal representation of the fingerprint of |cert|. |
| 98 CHROMEOS_EXPORT std::string GetHexFingerprintOfCert( |
| 99 const net::X509Certificate& cert); |
| 100 |
| 101 // Get the hexadecimal representation of the fingerprint of a PEM encoded |
| 102 // certificate. |
| 103 CHROMEOS_EXPORT std::string GetHexFingerprintOfPEMCert( |
| 104 const std::string& pem_encoded_cert); |
| 105 |
| 106 // Returns a certificate of |cert_list| with the given |fingerprint|. If none or |
| 107 // more than one matching entry exists, returns NULL. |
| 108 CHROMEOS_EXPORT net::X509Certificate* FindCertByFingerprint( |
| 109 const net::CertificateList& cert_list, |
| 110 const std::string& fingerprint); |
| 111 |
| 112 // Returns the PEM encoding of the certificate of |cert_list| with |
| 113 // |fingerprint|. If none or more than one matching entry exists or the encoding |
| 114 // failed, returns an empty string. |
| 115 CHROMEOS_EXPORT std::string GetPEMEncodedCertFromFingerprint( |
| 116 const net::CertificateList& cert_list, |
| 117 const std::string& fingerprint); |
| 118 |
91 // Parse the given PEM encoded certificate |pem_encoded| and create a | 119 // Parse the given PEM encoded certificate |pem_encoded| and create a |
92 // X509Certificate from it. | 120 // X509Certificate from it. |
93 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> DecodePEMCertificate( | 121 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> DecodePEMCertificate( |
94 const std::string& pem_encoded, | 122 const std::string& pem_encoded); |
95 const std::string& nickname); | 123 |
| 124 // Replaces all references by GUID to Server or CA certs by their fingerprints |
| 125 // (see GetHexFingerprintOfCert). Returns true if all references could be |
| 126 // resolved. Otherwise returns false and network configurations with |
| 127 // unresolveable references are removed from |
| 128 // |network_configs|. |network_configs| must be a list of ONC |
| 129 // NetworkConfiguration dictionaries. |
| 130 CHROMEOS_EXPORT bool ResolveServerCertRefsInNetworks( |
| 131 const std::map<std::string, |
| 132 scoped_refptr<net::X509Certificate> >& certs_by_guid, |
| 133 base::ListValue* network_configs); |
| 134 |
| 135 // Replaces all references by GUID to Server or CA certs by their fingerprints |
| 136 // (see GetHexFingerprintOfCert). |network_config| must be a ONC |
| 137 // NetworkConfiguration. |
| 138 CHROMEOS_EXPORT bool ResolveServerCertRefsInNetwork( |
| 139 const std::map<std::string, |
| 140 scoped_refptr<net::X509Certificate> >& certs_by_guid, |
| 141 base::DictionaryValue* network_config); |
96 | 142 |
97 } // namespace onc | 143 } // namespace onc |
98 } // namespace chromeos | 144 } // namespace chromeos |
99 | 145 |
100 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 146 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
OLD | NEW |