Chromium Code Reviews| 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 namespace chromeos { | |
| 11 namespace onc { | |
| 12 namespace { | |
| 13 | |
| 14 const base::Value::Type TYPE_DICTIONARY = base::Value::TYPE_DICTIONARY; | |
|
stevenjb
2012/10/11 19:54:00
using base::Value
pneubeck (no reviews)
2012/10/15 13:57:44
Would be nice, but unfortunately doesn't work.
stevenjb
2012/10/15 17:23:54
You still have to use Value::TYPE_DICTIONARY, but
pneubeck (no reviews)
2012/10/30 08:42:04
Done.
| |
| 15 const base::Value::Type TYPE_LIST = base::Value::TYPE_LIST; | |
| 16 | |
| 17 const OncValueSignature bool_signature = { | |
| 18 base::Value::TYPE_BOOLEAN, NULL | |
| 19 }; | |
| 20 const OncValueSignature string_signature = { | |
| 21 base::Value::TYPE_STRING, NULL | |
| 22 }; | |
| 23 const OncValueSignature integer_signature = { | |
| 24 base::Value::TYPE_INTEGER, NULL | |
| 25 }; | |
| 26 // TODO: only temporary, remove this when all dictionaries are fully described | |
| 27 const OncValueSignature dictionary_signature = { | |
| 28 base::Value::TYPE_DICTIONARY, NULL | |
| 29 }; | |
| 30 const OncValueSignature string_list_signature = { | |
| 31 base::Value::TYPE_LIST, NULL, &string_signature | |
| 32 }; | |
| 33 const OncValueSignature ipconfig_list_signature = { | |
| 34 base::Value::TYPE_LIST, NULL, &ipconfig_signature | |
| 35 }; | |
| 36 | |
| 37 OncFieldSignature certificate_pattern_fields[] = { | |
| 38 { onc::kRecommended, NULL, &recommended_signature }, | |
| 39 { onc::certificate::kIssuerCARef, NULL, &string_list_signature }, | |
| 40 { onc::certificate::kIssuer, NULL, &dictionary_signature }, | |
| 41 { onc::certificate::kSubject, NULL, &dictionary_signature }, | |
| 42 { onc::certificate::kEnrollmentURI, NULL, &string_list_signature }, | |
| 43 { NULL } | |
| 44 }; | |
| 45 | |
| 46 const OncFieldSignature ipsec_fields[] = { | |
| 47 { onc::kRecommended, NULL, &recommended_signature }, | |
| 48 { onc::vpn::kAuthenticationType, flimflam::kL2tpIpsecAuthenticationType, | |
| 49 &string_signature }, | |
| 50 { onc::vpn::kClientCertPattern, NULL, &certificate_pattern_signature }, | |
| 51 { onc::vpn::kClientCertRef, NULL, &string_signature }, | |
| 52 { onc::vpn::kClientCertType, NULL, &string_signature }, | |
| 53 { onc::vpn::kEAP, NULL, &dictionary_signature }, | |
| 54 { onc::vpn::kGroup, flimflam::kL2tpIpsecGroupNameProperty, | |
| 55 &string_signature }, | |
| 56 { onc::vpn::kIKEVersion, flimflam::kL2tpIpsecIkeVersion, &integer_signature }, | |
| 57 { onc::vpn::kPSK, flimflam::kL2tpIpsecPskProperty, &string_signature }, | |
| 58 { onc::vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty, | |
| 59 &bool_signature }, | |
| 60 { onc::vpn::kServerCARef, flimflam::kL2tpIpsecCaCertNssProperty, | |
| 61 &string_signature }, | |
| 62 { onc::vpn::kXAUTH, NULL, &dictionary_signature }, | |
| 63 { NULL } | |
| 64 }; | |
| 65 | |
| 66 OncFieldSignature openvpn_fields[] = { | |
| 67 { onc::kRecommended, NULL, &recommended_signature }, | |
| 68 { onc::vpn::kAuth, flimflam::kOpenVPNAuthProperty, &string_signature }, | |
| 69 { onc::vpn::kAuthRetry, flimflam::kOpenVPNAuthRetryProperty, | |
| 70 &string_signature }, | |
| 71 { onc::vpn::kAuthNoCache, flimflam::kOpenVPNAuthNoCacheProperty, | |
| 72 &bool_signature }, | |
| 73 { onc::vpn::kCipher, flimflam::kOpenVPNCipherProperty, &string_signature }, | |
| 74 { onc::vpn::kClientCertPattern, NULL, &certificate_pattern_signature }, | |
| 75 { onc::vpn::kClientCertRef, NULL, &string_signature }, | |
| 76 { onc::vpn::kClientCertType, NULL, &string_signature }, | |
| 77 { onc::vpn::kCompLZO, flimflam::kOpenVPNCompLZOProperty, &string_signature }, | |
| 78 { onc::vpn::kCompNoAdapt, flimflam::kOpenVPNCompNoAdaptProperty, | |
| 79 &bool_signature }, | |
| 80 { onc::vpn::kKeyDirection, flimflam::kOpenVPNKeyDirectionProperty, | |
| 81 &string_signature }, | |
| 82 { onc::vpn::kNsCertType, flimflam::kOpenVPNNsCertTypeProperty, | |
| 83 &string_signature }, | |
| 84 { onc::vpn::kPassword, flimflam::kOpenVPNPasswordProperty, | |
| 85 &string_signature }, | |
| 86 { onc::vpn::kPort, flimflam::kOpenVPNPortProperty, &integer_signature }, | |
| 87 { onc::vpn::kProto, flimflam::kOpenVPNProtoProperty, &string_signature }, | |
| 88 { onc::vpn::kPushPeerInfo, flimflam::kOpenVPNPushPeerInfoProperty, | |
| 89 &bool_signature }, | |
| 90 { onc::vpn::kRemoteCertEKU, flimflam::kOpenVPNRemoteCertEKUProperty, | |
| 91 &string_signature }, | |
| 92 { onc::vpn::kRemoteCertKU, flimflam::kOpenVPNRemoteCertKUProperty, | |
| 93 &string_list_signature }, | |
| 94 { onc::vpn::kRemoteCertTLS, flimflam::kOpenVPNRemoteCertTLSProperty, | |
| 95 &string_signature }, | |
| 96 { onc::vpn::kRenegSec, flimflam::kOpenVPNRenegSecProperty, | |
| 97 &integer_signature }, | |
| 98 { onc::vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty, | |
| 99 &bool_signature }, | |
| 100 { onc::vpn::kServerCARef, flimflam::kOpenVPNCaCertNSSProperty, | |
| 101 &string_signature }, | |
| 102 { onc::vpn::kServerCertRef, NULL, &string_signature }, | |
| 103 { onc::vpn::kServerPollTimeout, flimflam::kOpenVPNServerPollTimeoutProperty, | |
| 104 &integer_signature }, | |
| 105 { onc::vpn::kShaper, flimflam::kOpenVPNShaperProperty, &integer_signature }, | |
| 106 { onc::vpn::kStaticChallenge, flimflam::kOpenVPNStaticChallengeProperty, | |
| 107 &string_signature }, | |
| 108 { onc::vpn::kTLSAuthContents, flimflam::kOpenVPNTLSAuthContentsProperty, | |
| 109 &string_signature }, | |
| 110 { onc::vpn::kTLSRemote, flimflam::kOpenVPNTLSRemoteProperty, | |
| 111 &string_signature }, | |
| 112 { onc::vpn::kUsername, flimflam::kOpenVPNUserProperty, &string_signature }, | |
| 113 { NULL } | |
| 114 }; | |
| 115 | |
| 116 const OncFieldSignature vpn_fields[] = { | |
| 117 { onc::kRecommended, NULL, &recommended_signature }, | |
| 118 { onc::vpn::kHost, flimflam::kProviderHostProperty, &string_signature }, | |
| 119 { onc::vpn::kIPsec, NULL, &ipsec_signature }, | |
| 120 { onc::vpn::kL2TP, NULL, &dictionary_signature }, | |
| 121 { onc::vpn::kOpenVPN, NULL, &openvpn_signature }, | |
| 122 { onc::vpn::kType, flimflam::kProviderTypeProperty, &string_signature }, | |
| 123 { NULL } | |
| 124 }; | |
| 125 | |
| 126 OncFieldSignature ethernet_fields[] = { | |
| 127 { onc::kRecommended, NULL, &recommended_signature }, | |
| 128 { onc::ethernet::kAuthentication, NULL, &string_signature }, | |
| 129 { onc::ethernet::kEAP, NULL, &eap_signature }, | |
| 130 { NULL } | |
| 131 }; | |
| 132 | |
| 133 const OncFieldSignature ipconfig_fields[] = { | |
| 134 { onc::ipconfig::kType, NULL, &string_signature }, | |
| 135 { onc::ipconfig::kIPAddress, NULL, &string_signature }, | |
| 136 { NULL } | |
| 137 }; | |
| 138 | |
| 139 const OncFieldSignature network_configuration_fields[] = { | |
| 140 { onc::kRecommended, NULL, &recommended_signature }, | |
| 141 { onc::kEthernet, NULL, ðernet_signature }, | |
| 142 { onc::kGUID, flimflam::kGuidProperty, &string_signature }, | |
| 143 { onc::kIPConfigs, NULL, &ipconfig_list_signature }, | |
| 144 { onc::kName, flimflam::kNameProperty, &string_signature }, | |
| 145 { onc::kProxySettings, NULL, &dictionary_signature }, | |
| 146 { onc::kRemove, NULL, &bool_signature }, | |
| 147 { onc::kType, flimflam::kTypeProperty, &string_signature }, | |
| 148 { onc::kVPN, NULL, &vpn_signature }, | |
| 149 { onc::kWiFi, NULL, &dictionary_signature }, | |
| 150 { NULL } | |
| 151 }; | |
| 152 | |
| 153 } // namespace | |
| 154 | |
| 155 | |
| 156 const OncValueSignature recommended_signature = { | |
| 157 TYPE_LIST, NULL, &string_signature | |
| 158 }; | |
| 159 const OncValueSignature eap_signature = { | |
| 160 TYPE_DICTIONARY, NULL | |
| 161 }; | |
| 162 const OncValueSignature certificate_pattern_signature = { | |
| 163 TYPE_DICTIONARY, certificate_pattern_fields, NULL | |
| 164 }; | |
| 165 const OncValueSignature ipsec_signature = { | |
| 166 TYPE_DICTIONARY, ipsec_fields, NULL | |
| 167 }; | |
| 168 const OncValueSignature openvpn_signature = { | |
| 169 TYPE_DICTIONARY, openvpn_fields, NULL | |
| 170 }; | |
| 171 const OncValueSignature vpn_signature = { | |
| 172 TYPE_DICTIONARY, vpn_fields, NULL | |
| 173 }; | |
| 174 const OncValueSignature ethernet_signature = { | |
| 175 TYPE_DICTIONARY, ethernet_fields, NULL | |
| 176 }; | |
| 177 const OncValueSignature ipconfig_signature = { | |
| 178 TYPE_DICTIONARY, ipconfig_fields, NULL | |
| 179 }; | |
| 180 const OncValueSignature network_configuration_signature = { | |
| 181 TYPE_DICTIONARY, network_configuration_fields, NULL | |
| 182 }; | |
| 183 | |
| 184 const OncFieldSignature* OncValueSignature::GetFieldSignature( | |
| 185 const std::string& onc_field_name) const { | |
| 186 if (!fields) | |
| 187 return NULL; | |
| 188 for (const OncFieldSignature* field_signature = fields; | |
| 189 field_signature->onc_field_name != NULL; ++field_signature) { | |
| 190 if (onc_field_name == field_signature->onc_field_name) | |
| 191 return field_signature; | |
| 192 } | |
| 193 return NULL; | |
| 194 } | |
| 195 | |
| 196 } // namespace onc | |
| 197 } // namespace chromeos | |
| OLD | NEW |