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 // Returns a certificate of |cert_list| with the given |fingerprint|. If none or |
| 102 // more than one matching entry exists, returns NULL. |
| 103 CHROMEOS_EXPORT net::X509Certificate* FindCertByFingerprint( |
| 104 const net::CertificateList& cert_list, |
| 105 const std::string& fingerprint); |
| 106 |
| 107 // Returns the PEM encoding of the certificate of |cert_list| with |
| 108 // |fingerprint|. If none or more than one matching entry exists or the encoding |
| 109 // failed, returns an empty string. |
| 110 CHROMEOS_EXPORT std::string GetPEMEncodedCertFromFingerprint( |
| 111 const net::CertificateList& cert_list, |
| 112 const std::string& fingerprint); |
| 113 |
91 // Parse the given PEM encoded certificate |pem_encoded| and create a | 114 // Parse the given PEM encoded certificate |pem_encoded| and create a |
92 // X509Certificate from it. | 115 // X509Certificate from it. |
93 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> DecodePEMCertificate( | 116 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> DecodePEMCertificate( |
94 const std::string& pem_encoded, | 117 const std::string& pem_encoded); |
95 const std::string& nickname); | 118 |
| 119 // Replaces all references by GUID to Server or CA certs by their fingerprints |
| 120 // (see GetHexFingerprintOfCert). Return true, if all references could be |
| 121 // resolved. Otherwise return false and network configurations with |
| 122 // unresolveable references are removed from |
| 123 // |network_configs|. |network_configs| must be a list of ONC |
| 124 // NetworkConfiguration dictionaries. |
| 125 CHROMEOS_EXPORT bool ResolveServerCertRefsInNetworks( |
| 126 const std::map<std::string, |
| 127 scoped_refptr<net::X509Certificate> >& certs_by_guid, |
| 128 base::ListValue* network_configs); |
| 129 |
| 130 // Replaces all references by GUID to Server or CA certs by their fingerprints |
| 131 // (see GetHexFingerprintOfCert). |network_config| must be a ONC |
| 132 // NetworkConfiguration. |
| 133 CHROMEOS_EXPORT bool ResolveServerCertRefsInNetwork( |
| 134 const std::map<std::string, |
| 135 scoped_refptr<net::X509Certificate> >& certs_by_guid, |
| 136 base::DictionaryValue* network_config); |
96 | 137 |
97 } // namespace onc | 138 } // namespace onc |
98 } // namespace chromeos | 139 } // namespace chromeos |
99 | 140 |
100 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 141 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
OLD | NEW |