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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
13 #include "chromeos/network/onc/onc_constants.h" | 14 #include "chromeos/network/onc/onc_constants.h" |
15 #include "net/cert/x509_certificate.h" | |
14 | 16 |
15 namespace base { | 17 namespace base { |
16 class DictionaryValue; | 18 class DictionaryValue; |
17 class ListValue; | 19 class ListValue; |
18 } | 20 } |
19 | 21 |
20 namespace chromeos { | 22 namespace chromeos { |
21 namespace onc { | 23 namespace onc { |
22 | 24 |
23 struct OncValueSignature; | 25 struct OncValueSignature; |
(...skipping 18 matching lines...) Expand all Loading... | |
42 // For logging only: strings not user facing. | 44 // For logging only: strings not user facing. |
43 CHROMEOS_EXPORT std::string GetSourceAsString(ONCSource source); | 45 CHROMEOS_EXPORT std::string GetSourceAsString(ONCSource source); |
44 | 46 |
45 // Used for string expansion with function ExpandStringInOncObject(...). | 47 // Used for string expansion with function ExpandStringInOncObject(...). |
46 class CHROMEOS_EXPORT StringSubstitution { | 48 class CHROMEOS_EXPORT StringSubstitution { |
47 public: | 49 public: |
48 StringSubstitution() {} | 50 StringSubstitution() {} |
49 virtual ~StringSubstitution() {} | 51 virtual ~StringSubstitution() {} |
50 | 52 |
51 // Returns the replacement string for |placeholder| in | 53 // Returns the replacement string for |placeholder| in |
52 // |substitute|. Currently, onc::substitutes::kLoginIDField and | 54 // |substitute|. Currently, substitutes::kLoginIDField and |
53 // onc::substitutes::kEmailField are supported. | 55 // substitutes::kEmailField are supported. |
54 virtual bool GetSubstitute(std::string placeholder, | 56 virtual bool GetSubstitute(std::string placeholder, |
55 std::string* substitute) const = 0; | 57 std::string* substitute) const = 0; |
56 private: | 58 private: |
57 DISALLOW_COPY_AND_ASSIGN(StringSubstitution); | 59 DISALLOW_COPY_AND_ASSIGN(StringSubstitution); |
58 }; | 60 }; |
59 | 61 |
60 // Replaces all expandable fields that are mentioned in the ONC | 62 // Replaces all expandable fields that are mentioned in the ONC |
61 // specification. The object of |onc_object| is modified in place. Currently | 63 // specification. The object of |onc_object| is modified in place. Currently |
62 // onc::substitutes::kLoginIDField and onc::substitutes::kEmailField are | 64 // substitutes::kLoginIDField and substitutes::kEmailField are expanded. The |
63 // expanded. The replacement strings are obtained from |substitution|. | 65 // replacement strings are obtained from |substitution|. |
64 CHROMEOS_EXPORT void ExpandStringsInOncObject( | 66 CHROMEOS_EXPORT void ExpandStringsInOncObject( |
65 const OncValueSignature& signature, | 67 const OncValueSignature& signature, |
66 const StringSubstitution& substitution, | 68 const StringSubstitution& substitution, |
67 base::DictionaryValue* onc_object); | 69 base::DictionaryValue* onc_object); |
68 | 70 |
69 // Creates a copy of |onc_object| with all values of sensitive fields replaced | 71 // Creates a copy of |onc_object| with all values of sensitive fields replaced |
70 // by |mask|. To find sensitive fields, signature and field name are checked | 72 // by |mask|. To find sensitive fields, signature and field name are checked |
71 // with the function FieldIsCredential(). | 73 // with the function FieldIsCredential(). |
72 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> MaskCredentialsInOncObject( | 74 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> MaskCredentialsInOncObject( |
73 const OncValueSignature& signature, | 75 const OncValueSignature& signature, |
74 const base::DictionaryValue& onc_object, | 76 const base::DictionaryValue& onc_object, |
75 const std::string& mask); | 77 const std::string& mask); |
76 | 78 |
77 // Decrypts |onc_blob| with |passphrase| if necessary. Clears |network_configs| | 79 // Decrypts |onc_blob| with |passphrase| if necessary. Clears |network_configs| |
78 // and |certificates| and fills them with the validated NetworkConfigurations | 80 // and |certificates| and fills them with the validated NetworkConfigurations |
79 // and Certificates of |onc_blob|. Returns false if any validation errors or | 81 // and Certificates of |onc_blob|. Returns false if any validation errors or |
80 // warnings occurred. Still, some networks or certificates might be added to the | 82 // warnings occurred. Still, some networks or certificates might be added to the |
81 // output lists and should be further processed by the caller. | 83 // output lists and should be further processed by the caller. |
82 CHROMEOS_EXPORT bool ParseAndValidateOncForImport( | 84 CHROMEOS_EXPORT bool ParseAndValidateOncForImport( |
83 const std::string& onc_blob, | 85 const std::string& onc_blob, |
84 chromeos::onc::ONCSource onc_source, | 86 ONCSource onc_source, |
85 const std::string& passphrase, | 87 const std::string& passphrase, |
86 base::ListValue* network_configs, | 88 base::ListValue* network_configs, |
87 base::ListValue* certificates); | 89 base::ListValue* certificates); |
88 | 90 |
91 // Parse the given PEM encoded certificate |pem_encoded| and create a | |
92 // X509Certificate from it. | |
93 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> GetCertFromPEMEncoding( | |
Mattias Nissler (ping if slow)
2013/06/20 16:15:36
nit: Maybe DecodePEMCertificate would be a more ac
pneubeck (no reviews)
2013/06/21 11:28:00
Done.
| |
94 const std::string& pem_encoded, | |
95 const std::string& nickname); | |
96 | |
89 } // namespace onc | 97 } // namespace onc |
90 } // namespace chromeos | 98 } // namespace chromeos |
91 | 99 |
92 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 100 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
OLD | NEW |