Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/chromeos/cros/onc_network_parser.h

Issue 8566056: This applies GUIDs to certificate and key nicknames when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_CROS_ONC_NETWORK_PARSER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" // for OVERRIDE 11 #include "base/compiler_specific.h" // for OVERRIDE
12 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/chromeos/cros/network_parser.h" 15 #include "chrome/browser/chromeos/cros/network_parser.h"
15 16
16 namespace base { 17 namespace base {
17 class DictionaryValue; 18 class DictionaryValue;
18 class ListValue; 19 class ListValue;
19 class Value; 20 class Value;
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 29
24 // This is a simple representation of the signature of an ONC typed 30 // This is a simple representation of the signature of an ONC typed
25 // field, used in validation and translation. It could be extended 31 // field, used in validation and translation. It could be extended
26 // to include more complex rules of when the field is required/optional, 32 // to include more complex rules of when the field is required/optional,
27 // as well as to handle "enum" types, which are strings with a small 33 // as well as to handle "enum" types, which are strings with a small
28 // static set of possible values. 34 // static set of possible values.
29 struct OncValueSignature { 35 struct OncValueSignature {
30 const char* field; 36 const char* field;
31 PropertyIndex index; 37 PropertyIndex index;
(...skipping 13 matching lines...) Expand all
45 const base::Value&, 51 const base::Value&,
46 Network*); 52 Network*);
47 53
48 explicit OncNetworkParser(const std::string& onc_blob); 54 explicit OncNetworkParser(const std::string& onc_blob);
49 virtual ~OncNetworkParser(); 55 virtual ~OncNetworkParser();
50 static const EnumMapper<PropertyIndex>* property_mapper(); 56 static const EnumMapper<PropertyIndex>* property_mapper();
51 57
52 // Returns the number of networks in the "NetworkConfigs" list. 58 // Returns the number of networks in the "NetworkConfigs" list.
53 int GetNetworkConfigsSize() const; 59 int GetNetworkConfigsSize() const;
54 60
55 // Returns the number of certificates in the "Certificates" list.
56 int GetCertificatesSize() const;
57
58 // Call to create the network by parsing network config in the nth position. 61 // Call to create the network by parsing network config in the nth position.
59 // (0-based). Returns NULL if there's a parse error or if n is out of range. 62 // (0-based). Returns NULL if there's a parse error or if n is out of range.
60 Network* ParseNetwork(int n); 63 Network* ParseNetwork(int n);
61 64
65 // Returns the number of certificates in the "Certificates" list.
66 int GetCertificatesSize() const;
67
62 // Call to parse and import the nth certificate in the certificate 68 // Call to parse and import the nth certificate in the certificate
63 // list. Returns false on failure. 69 // list into the certificate store. Returns a NULL refptr if
64 bool ParseCertificate(int n); 70 // there's a parse error or if n is out of range.
71 scoped_refptr<net::X509Certificate> ParseCertificate(int n);
65 72
66 virtual Network* CreateNetworkFromInfo(const std::string& service_path, 73 virtual Network* CreateNetworkFromInfo(const std::string& service_path,
67 const base::DictionaryValue& info) OVERRIDE; 74 const base::DictionaryValue& info) OVERRIDE;
68 75
69 // Parses a nested ONC object with the given mapper and parser function. 76 // Parses a nested ONC object with the given mapper and parser function.
70 // If Value is not the proper type or there is an error in parsing 77 // If Value is not the proper type or there is an error in parsing
71 // any individual field, VLOGs diagnostics, and returns false. 78 // any individual field, VLOGs diagnostics, and returns false.
72 bool ParseNestedObject(Network* network, 79 bool ParseNestedObject(Network* network,
73 const std::string& onc_type, 80 const std::string& onc_type,
74 const base::Value& value, 81 const base::Value& value,
(...skipping 22 matching lines...) Expand all
97 PropertyIndex index, 104 PropertyIndex index,
98 const base::Value& value, 105 const base::Value& value,
99 Network* network); 106 Network* network);
100 107
101 // Issue a diagnostic and return false if a type mismatch is found. 108 // Issue a diagnostic and return false if a type mismatch is found.
102 static bool CheckNetworkType(Network* network, 109 static bool CheckNetworkType(Network* network,
103 ConnectionType expected, 110 ConnectionType expected,
104 const std::string& onc_type); 111 const std::string& onc_type);
105 112
106 private: 113 private:
107 bool ParseServerOrCaCertificate( 114 FRIEND_TEST_ALL_PREFIXES(OncNetworkParserTest, TestAddClientCertificate);
115 FRIEND_TEST_ALL_PREFIXES(OncNetworkParserTest, TestAddServerCertificate);
116 FRIEND_TEST_ALL_PREFIXES(OncNetworkParserTest, TestAddAuthorityCertificate);
117 scoped_refptr<net::X509Certificate> ParseServerOrCaCertificate(
108 int cert_index, 118 int cert_index,
109 const std::string& cert_type, 119 const std::string& cert_type,
120 const std::string& guid,
110 base::DictionaryValue* certificate); 121 base::DictionaryValue* certificate);
111 bool ParseClientCertificate( 122 scoped_refptr<net::X509Certificate> ParseClientCertificate(
112 int cert_index, 123 int cert_index,
124 const std::string& guid,
113 base::DictionaryValue* certificate); 125 base::DictionaryValue* certificate);
114 126
127 // This lists the certificates that have the string |label| as their
128 // certificate nickname (exact match).
129 static void ListCertsWithNickname(const std::string& label,
130 net::CertificateList* result);
wtc 2011/12/10 00:58:43 Nit: you should also rename the first input parame
131 // This deletes any certificate that has the string |label| as its
132 // nickname (exact match).
133 static bool DeleteCertAndKeyByNickname(const std::string& label);
134
115 // Error message from the JSON parser, if applicable. 135 // Error message from the JSON parser, if applicable.
116 std::string parse_error_; 136 std::string parse_error_;
117 137
118 scoped_ptr<base::DictionaryValue> root_dict_; 138 scoped_ptr<base::DictionaryValue> root_dict_;
119 base::ListValue* network_configs_; 139 base::ListValue* network_configs_;
120 base::ListValue* certificates_; 140 base::ListValue* certificates_;
121 141
122 DISALLOW_COPY_AND_ASSIGN(OncNetworkParser); 142 DISALLOW_COPY_AND_ASSIGN(OncNetworkParser);
123 }; 143 };
124 144
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 const base::Value& value, 216 const base::Value& value,
197 Network* network); 217 Network* network);
198 218
199 private: 219 private:
200 DISALLOW_COPY_AND_ASSIGN(OncVirtualNetworkParser); 220 DISALLOW_COPY_AND_ASSIGN(OncVirtualNetworkParser);
201 }; 221 };
202 222
203 } // namespace chromeos 223 } // namespace chromeos
204 224
205 #endif // CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ 225 #endif // CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698