OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chromeos/network_settings/onc_signature.h" | |
6 | |
7 #include "chrome/browser/chromeos/cros/onc_constants.h" | |
8 #include "third_party/cros_system_api/dbus/service_constants.h" | |
9 | |
10 using base::Value; | |
11 | |
12 namespace chromeos { | |
13 namespace onc { | |
14 namespace { | |
15 | |
16 const OncValueSignature kBoolSignature = { | |
17 Value::TYPE_BOOLEAN, NULL | |
18 }; | |
19 const OncValueSignature kStringSignature = { | |
20 Value::TYPE_STRING, NULL | |
21 }; | |
22 const OncValueSignature kIntegerSignature = { | |
23 Value::TYPE_INTEGER, NULL | |
24 }; | |
25 const OncValueSignature kStringListSignature = { | |
26 Value::TYPE_LIST, NULL, &kStringSignature | |
27 }; | |
28 const OncValueSignature kIPConfigListSignature = { | |
29 Value::TYPE_LIST, NULL, &kIPConfigSignature | |
30 }; | |
31 const OncValueSignature kCertificateListSignature = { | |
32 Value::TYPE_LIST, NULL, &kCertificateSignature | |
33 }; | |
34 const OncValueSignature kNetworkConfigurationListSignature = { | |
35 Value::TYPE_LIST, NULL, &kNetworkConfigurationSignature | |
36 }; | |
37 | |
38 const OncFieldSignature issuer_subject_pattern_fields[] = { | |
39 { certificate::kCommonName, NULL, &kStringSignature }, | |
40 { certificate::kLocality, NULL, &kStringSignature }, | |
41 { certificate::kOrganization, NULL, &kStringSignature }, | |
42 { certificate::kOrganizationalUnit, NULL, &kStringSignature }, | |
43 { NULL } | |
44 }; | |
45 | |
46 const OncFieldSignature certificate_pattern_fields[] = { | |
47 { kRecommended, NULL, &kRecommendedSignature }, | |
48 { certificate::kEnrollmentURI, NULL, &kStringListSignature }, | |
49 { certificate::kIssuer, NULL, &kIssuerSubjectPatternSignature }, | |
50 { certificate::kIssuerCARef, NULL, &kStringListSignature }, | |
51 { certificate::kSubject, NULL, &kIssuerSubjectPatternSignature }, | |
52 { NULL } | |
53 }; | |
54 | |
55 const OncFieldSignature eap_fields[] = { | |
56 { kRecommended, NULL, &kRecommendedSignature }, | |
57 { eap::kAnonymousIdentity, flimflam::kEapAnonymousIdentityProperty, | |
58 &kStringSignature }, | |
59 { eap::kClientCertPattern, NULL, &kCertificatePatternSignature }, | |
60 { eap::kClientCertRef, NULL, &kStringSignature }, | |
61 { eap::kClientCertType, NULL, &kStringSignature }, | |
62 { eap::kIdentity, flimflam::kEapIdentityProperty, &kStringSignature }, | |
63 { eap::kInner, flimflam::kEapPhase2AuthProperty, &kStringSignature }, | |
64 { eap::kOuter, flimflam::kEapMethodProperty, &kStringSignature }, | |
65 { eap::kPassword, flimflam::kEapPasswordProperty, &kStringSignature }, | |
66 { eap::kSaveCredentials, flimflam::kSaveCredentialsProperty, | |
67 &kBoolSignature }, | |
68 { eap::kServerCARef, flimflam::kEapCaCertNssProperty, &kStringSignature }, | |
69 { eap::kUseSystemCAs, flimflam::kEapUseSystemCasProperty, &kBoolSignature }, | |
70 { NULL } | |
71 }; | |
72 | |
73 const OncFieldSignature ipsec_fields[] = { | |
74 { kRecommended, NULL, &kRecommendedSignature }, | |
75 // Ignored by Shill, not necessary to synchronize. | |
76 // Would be: flimflam::kL2tpIpsecAuthenticationType | |
77 { vpn::kAuthenticationType, NULL, &kStringSignature }, | |
78 { vpn::kClientCertPattern, NULL, &kCertificatePatternSignature }, | |
79 { vpn::kClientCertRef, NULL, &kStringSignature }, | |
80 { vpn::kClientCertType, NULL, &kStringSignature }, | |
81 { vpn::kGroup, flimflam::kL2tpIpsecGroupNameProperty, &kStringSignature }, | |
82 // Ignored by Shill, not necessary to synchronize. | |
83 // Would be: flimflam::kL2tpIpsecIkeVersion | |
84 { vpn::kIKEVersion, NULL, &kIntegerSignature }, | |
85 { vpn::kPSK, flimflam::kL2tpIpsecPskProperty, &kStringSignature }, | |
86 { vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty, | |
87 &kBoolSignature }, | |
88 { vpn::kServerCARef, flimflam::kL2tpIpsecCaCertNssProperty, | |
89 &kStringSignature }, | |
90 // Not yet supported. | |
91 // { vpn::kEAP, NULL, &kEAPSignature }, | |
92 // { vpn::kXAUTH, NULL, &kXAUTHSignature }, | |
93 { NULL } | |
94 }; | |
95 | |
96 const OncFieldSignature l2tp_fields[] = { | |
97 { kRecommended, NULL, &kRecommendedSignature }, | |
98 { vpn::kPassword, flimflam::kL2tpIpsecPasswordProperty, &kStringSignature }, | |
99 // We don't synchronize l2tp's SaveCredentials field for now, as Shill doesn't | |
100 // support separate settings for ipsec and l2tp. | |
101 { vpn::kSaveCredentials, NULL, &kBoolSignature }, | |
102 { vpn::kUsername, flimflam::kL2tpIpsecUserProperty, &kStringSignature }, | |
103 { NULL } | |
104 }; | |
105 | |
106 const OncFieldSignature openvpn_fields[] = { | |
107 { kRecommended, NULL, &kRecommendedSignature }, | |
108 { vpn::kAuth, flimflam::kOpenVPNAuthProperty, &kStringSignature }, | |
109 { vpn::kAuthNoCache, flimflam::kOpenVPNAuthNoCacheProperty, &kBoolSignature }, | |
110 { vpn::kAuthRetry, flimflam::kOpenVPNAuthRetryProperty, &kStringSignature }, | |
111 { vpn::kCipher, flimflam::kOpenVPNCipherProperty, &kStringSignature }, | |
112 { vpn::kClientCertPattern, NULL, &kCertificatePatternSignature }, | |
113 { vpn::kClientCertRef, NULL, &kStringSignature }, | |
114 { vpn::kClientCertType, NULL, &kStringSignature }, | |
115 { vpn::kCompLZO, flimflam::kOpenVPNCompLZOProperty, &kStringSignature }, | |
116 { vpn::kCompNoAdapt, flimflam::kOpenVPNCompNoAdaptProperty, &kBoolSignature }, | |
117 { vpn::kKeyDirection, flimflam::kOpenVPNKeyDirectionProperty, | |
118 &kStringSignature }, | |
119 { vpn::kNsCertType, flimflam::kOpenVPNNsCertTypeProperty, &kStringSignature }, | |
120 { vpn::kPassword, flimflam::kOpenVPNPasswordProperty, &kStringSignature }, | |
121 { vpn::kPort, flimflam::kOpenVPNPortProperty, &kIntegerSignature }, | |
122 { vpn::kProto, flimflam::kOpenVPNProtoProperty, &kStringSignature }, | |
123 { vpn::kPushPeerInfo, flimflam::kOpenVPNPushPeerInfoProperty, | |
124 &kBoolSignature }, | |
125 { vpn::kRemoteCertEKU, flimflam::kOpenVPNRemoteCertEKUProperty, | |
126 &kStringSignature }, | |
127 // This field is converted during translation, see onc_translator_*. | |
128 { vpn::kRemoteCertKU, NULL, &kStringListSignature }, | |
129 { vpn::kRemoteCertTLS, flimflam::kOpenVPNRemoteCertTLSProperty, | |
130 &kStringSignature }, | |
131 { vpn::kRenegSec, flimflam::kOpenVPNRenegSecProperty, &kIntegerSignature }, | |
132 { vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty, | |
133 &kBoolSignature }, | |
134 { vpn::kServerCARef, flimflam::kOpenVPNCaCertNSSProperty, &kStringSignature }, | |
135 { vpn::kServerCertRef, NULL, &kStringSignature }, | |
136 { vpn::kServerPollTimeout, flimflam::kOpenVPNServerPollTimeoutProperty, | |
137 &kIntegerSignature }, | |
138 { vpn::kShaper, flimflam::kOpenVPNShaperProperty, &kIntegerSignature }, | |
139 { vpn::kStaticChallenge, flimflam::kOpenVPNStaticChallengeProperty, | |
140 &kStringSignature }, | |
141 { vpn::kTLSAuthContents, flimflam::kOpenVPNTLSAuthContentsProperty, | |
142 &kStringSignature }, | |
143 { vpn::kTLSRemote, flimflam::kOpenVPNTLSRemoteProperty, &kStringSignature }, | |
144 { vpn::kUsername, flimflam::kOpenVPNUserProperty, &kStringSignature }, | |
145 { vpn::kVerb, NULL, &kStringSignature }, | |
146 { NULL } | |
147 }; | |
148 | |
149 const OncFieldSignature vpn_fields[] = { | |
150 { kRecommended, NULL, &kRecommendedSignature }, | |
151 { vpn::kHost, flimflam::kProviderHostProperty, &kStringSignature }, | |
152 { vpn::kIPsec, NULL, &kIPsecSignature }, | |
153 { vpn::kL2TP, NULL, &kL2TPSignature }, | |
154 { vpn::kOpenVPN, NULL, &kOpenVPNSignature }, | |
155 // This field is converted during translation, see onc_translator_*. | |
156 { kType, NULL, &kStringSignature }, | |
157 { NULL } | |
158 }; | |
159 | |
160 const OncFieldSignature ethernet_fields[] = { | |
161 { kRecommended, NULL, &kRecommendedSignature }, | |
162 { ethernet::kAuthentication, NULL, &kStringSignature }, | |
163 { ethernet::kEAP, NULL, &kEAPSignature }, | |
164 { NULL } | |
165 }; | |
166 | |
167 const OncFieldSignature ipconfig_fields[] = { | |
168 { ipconfig::kGateway, NULL, &kStringSignature }, | |
169 { ipconfig::kIPAddress, NULL, &kStringSignature }, | |
170 { kNameServers, NULL, &kStringSignature }, | |
171 { ipconfig::kRoutingPrefix, NULL, &kIntegerSignature }, | |
172 { kSearchDomains, NULL, &kStringListSignature }, | |
173 // This field is converted during translation, see onc_translator_*. | |
174 { kType, NULL, &kStringSignature }, | |
175 { NULL } | |
176 }; | |
177 | |
178 const OncFieldSignature proxy_location_fields[] = { | |
179 { proxy::kHost, NULL, &kStringSignature }, | |
180 { proxy::kPort, NULL, &kIntegerSignature }, | |
181 { NULL } | |
182 }; | |
183 | |
184 const OncFieldSignature proxy_manual_fields[] = { | |
185 { proxy::kFtp, NULL, &kProxyLocationSignature }, | |
186 { proxy::kHttp, NULL, &kProxyLocationSignature }, | |
187 { proxy::kHttps, NULL, &kProxyLocationSignature }, | |
188 { proxy::kSocks, NULL, &kProxyLocationSignature }, | |
189 { NULL } | |
190 }; | |
191 | |
192 const OncFieldSignature proxy_settings_fields[] = { | |
193 { kRecommended, NULL, &kRecommendedSignature }, | |
194 { proxy::kExcludeDomains, NULL, &kStringListSignature }, | |
195 { proxy::kManual, NULL, &kProxyManualSignature }, | |
196 { proxy::kPAC, NULL, &kStringSignature }, | |
197 { kType, NULL, &kStringSignature }, | |
198 { NULL } | |
199 }; | |
200 | |
201 const OncFieldSignature wifi_fields[] = { | |
202 { kRecommended, NULL, &kRecommendedSignature }, | |
203 { wifi::kAutoConnect, flimflam::kAutoConnectProperty, &kBoolSignature }, | |
204 { wifi::kEAP, NULL, &kEAPSignature }, | |
205 { wifi::kHiddenSSID, flimflam::kWifiHiddenSsid, &kBoolSignature }, | |
206 { wifi::kPassphrase, flimflam::kPassphraseProperty, &kStringSignature }, | |
207 { wifi::kSSID, flimflam::kSSIDProperty, &kStringSignature }, | |
208 { wifi::kSecurity, flimflam::kSecurityProperty, &kStringSignature }, | |
209 { NULL } | |
210 }; | |
211 | |
212 const OncFieldSignature network_configuration_fields[] = { | |
213 { kRecommended, NULL, &kRecommendedSignature }, | |
214 { kEthernet, NULL, &kEthernetSignature }, | |
215 { kGUID, flimflam::kGuidProperty, &kStringSignature }, | |
216 { kIPConfigs, NULL, &kIPConfigListSignature }, | |
217 { kName, flimflam::kNameProperty, &kStringSignature }, | |
218 { kNameServers, NULL, &kStringListSignature }, | |
219 { kProxySettings, NULL, &kProxySettingsSignature }, | |
220 { kRemove, NULL, &kBoolSignature }, | |
221 { kSearchDomains, NULL, &kStringListSignature }, | |
222 // This field is converted during translation, see onc_translator_*. | |
223 { kType, NULL, &kStringSignature }, | |
224 { kVPN, NULL, &kVPNSignature }, | |
225 { kWiFi, NULL, &kWiFiSignature }, | |
226 { NULL } | |
227 }; | |
228 | |
229 const OncFieldSignature certificate_fields[] = { | |
230 { kGUID, flimflam::kGuidProperty, &kStringSignature }, | |
231 { certificate::kPKCS12, NULL, &kStringSignature }, | |
232 { kRemove, NULL, &kBoolSignature }, | |
233 { certificate::kTrust, NULL, &kStringListSignature }, | |
234 { kType, NULL, &kStringSignature }, | |
235 { certificate::kX509, NULL, &kStringSignature }, | |
236 { NULL } | |
237 }; | |
238 | |
239 const OncFieldSignature unencrypted_configuration_fields[] = { | |
240 { kCertificates, NULL, &kCertificateListSignature }, | |
241 { kNetworkConfigurations, NULL, &kNetworkConfigurationListSignature }, | |
242 { kType, NULL, &kStringSignature }, | |
243 { NULL } | |
244 }; | |
245 | |
246 } // namespace | |
247 | |
248 const OncValueSignature kRecommendedSignature = { | |
249 Value::TYPE_LIST, NULL, &kStringSignature | |
250 }; | |
251 const OncValueSignature kEAPSignature = { | |
252 Value::TYPE_DICTIONARY, eap_fields, NULL | |
253 }; | |
254 const OncValueSignature kIssuerSubjectPatternSignature = { | |
255 Value::TYPE_DICTIONARY, issuer_subject_pattern_fields, NULL | |
256 }; | |
257 const OncValueSignature kCertificatePatternSignature = { | |
258 Value::TYPE_DICTIONARY, certificate_pattern_fields, NULL | |
259 }; | |
260 const OncValueSignature kIPsecSignature = { | |
261 Value::TYPE_DICTIONARY, ipsec_fields, NULL | |
262 }; | |
263 const OncValueSignature kL2TPSignature = { | |
264 Value::TYPE_DICTIONARY, l2tp_fields, NULL | |
265 }; | |
266 const OncValueSignature kOpenVPNSignature = { | |
267 Value::TYPE_DICTIONARY, openvpn_fields, NULL | |
268 }; | |
269 const OncValueSignature kVPNSignature = { | |
270 Value::TYPE_DICTIONARY, vpn_fields, NULL | |
271 }; | |
272 const OncValueSignature kEthernetSignature = { | |
273 Value::TYPE_DICTIONARY, ethernet_fields, NULL | |
274 }; | |
275 const OncValueSignature kIPConfigSignature = { | |
276 Value::TYPE_DICTIONARY, ipconfig_fields, NULL | |
277 }; | |
278 const OncValueSignature kProxyLocationSignature = { | |
279 Value::TYPE_DICTIONARY, proxy_location_fields, NULL | |
280 }; | |
281 const OncValueSignature kProxyManualSignature = { | |
282 Value::TYPE_DICTIONARY, proxy_manual_fields, NULL | |
283 }; | |
284 const OncValueSignature kProxySettingsSignature = { | |
285 Value::TYPE_DICTIONARY, proxy_settings_fields, NULL | |
286 }; | |
287 const OncValueSignature kWiFiSignature = { | |
288 Value::TYPE_DICTIONARY, wifi_fields, NULL | |
289 }; | |
290 const OncValueSignature kCertificateSignature = { | |
291 Value::TYPE_DICTIONARY, certificate_fields, NULL | |
292 }; | |
293 const OncValueSignature kNetworkConfigurationSignature = { | |
294 Value::TYPE_DICTIONARY, network_configuration_fields, NULL | |
295 }; | |
296 const OncValueSignature kUnencryptedConfigurationSignature = { | |
297 Value::TYPE_DICTIONARY, unencrypted_configuration_fields, NULL | |
298 }; | |
299 | |
300 const OncFieldSignature* GetFieldSignature(const OncValueSignature& signature, | |
301 const std::string& onc_field_name) { | |
302 if (!signature.fields) | |
303 return NULL; | |
304 for (const OncFieldSignature* field_signature = signature.fields; | |
305 field_signature->onc_field_name != NULL; ++field_signature) { | |
306 if (onc_field_name == field_signature->onc_field_name) | |
307 return field_signature; | |
308 } | |
309 return NULL; | |
310 } | |
311 | |
312 } // namespace onc | |
313 } // namespace chromeos | |
OLD | NEW |