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 } |
| 26 |
22 namespace chromeos { | 27 namespace chromeos { |
23 namespace onc { | 28 namespace onc { |
24 | 29 |
25 struct OncValueSignature; | 30 struct OncValueSignature; |
26 | 31 |
27 // A valid but empty (no networks and no certificates) and unencrypted | 32 // A valid but empty (no networks and no certificates) and unencrypted |
28 // configuration. | 33 // configuration. |
29 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; | 34 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; |
30 | 35 |
| 36 typedef std::map<std::string, |
| 37 scoped_refptr<net::X509Certificate> > CertsByGUIDMap; |
| 38 |
31 // Parses |json| according to the JSON format. If |json| is a JSON formatted | 39 // Parses |json| according to the JSON format. If |json| is a JSON formatted |
32 // dictionary, the function returns the dictionary as a DictionaryValue. | 40 // dictionary, the function returns the dictionary as a DictionaryValue. |
33 // Otherwise returns NULL. | 41 // Otherwise returns NULL. |
34 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson( | 42 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson( |
35 const std::string& json); | 43 const std::string& json); |
36 | 44 |
37 // Decrypts the given EncryptedConfiguration |onc| (see the ONC specification) | 45 // Decrypts the given EncryptedConfiguration |onc| (see the ONC specification) |
38 // using |passphrase|. The resulting UnencryptedConfiguration is returned. If an | 46 // using |passphrase|. The resulting UnencryptedConfiguration is returned. If an |
39 // error occurs, returns NULL. | 47 // error occurs, returns NULL. |
40 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> Decrypt( | 48 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> Decrypt( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 CHROMEOS_EXPORT bool ParseAndValidateOncForImport( | 92 CHROMEOS_EXPORT bool ParseAndValidateOncForImport( |
85 const std::string& onc_blob, | 93 const std::string& onc_blob, |
86 ONCSource onc_source, | 94 ONCSource onc_source, |
87 const std::string& passphrase, | 95 const std::string& passphrase, |
88 base::ListValue* network_configs, | 96 base::ListValue* network_configs, |
89 base::ListValue* certificates); | 97 base::ListValue* certificates); |
90 | 98 |
91 // Parse the given PEM encoded certificate |pem_encoded| and create a | 99 // Parse the given PEM encoded certificate |pem_encoded| and create a |
92 // X509Certificate from it. | 100 // X509Certificate from it. |
93 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> DecodePEMCertificate( | 101 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> DecodePEMCertificate( |
94 const std::string& pem_encoded, | 102 const std::string& pem_encoded); |
95 const std::string& nickname); | 103 |
| 104 // Replaces all references by GUID to Server or CA certs by their PEM |
| 105 // encoding. Returns true if all references could be resolved. Otherwise returns |
| 106 // false and network configurations with unresolveable references are removed |
| 107 // from |network_configs|. |network_configs| must be a list of ONC |
| 108 // NetworkConfiguration dictionaries. |
| 109 CHROMEOS_EXPORT bool ResolveServerCertRefsInNetworks( |
| 110 const CertsByGUIDMap& certs_by_guid, |
| 111 base::ListValue* network_configs); |
| 112 |
| 113 // Replaces all references by GUID to Server or CA certs by their PEM |
| 114 // encoding. Returns true if all references could be resolved. |network_config| |
| 115 // must be a ONC NetworkConfiguration. |
| 116 CHROMEOS_EXPORT bool ResolveServerCertRefsInNetwork( |
| 117 const CertsByGUIDMap& certs_by_guid, |
| 118 base::DictionaryValue* network_config); |
96 | 119 |
97 } // namespace onc | 120 } // namespace onc |
98 } // namespace chromeos | 121 } // namespace chromeos |
99 | 122 |
100 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 123 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
OLD | NEW |