Bug 745468 - 0001. Support WPA-EAP configure parameters. r=vchang, r=mrbkap

This commit is contained in:
Chuck Lee 2014-04-30 19:58:54 +08:00
parent f505f27dd6
commit 9cc1761dc3
2 changed files with 38 additions and 16 deletions

View File

@ -53,6 +53,7 @@ dictionary NetworkProperties {
DOMString eap; DOMString eap;
DOMString pin; DOMString pin;
boolean dontConnect; boolean dontConnect;
DOMString serverCertificate;
}; };
[Constructor(optional NetworkProperties properties), [Constructor(optional NetworkProperties properties),
@ -87,6 +88,7 @@ interface MozWifiNetwork {
attribute DOMString? eap; attribute DOMString? eap;
attribute DOMString? pin; attribute DOMString? pin;
attribute boolean? dontConnect; attribute boolean? dontConnect;
attribute DOMString? serverCertificate;
}; };
[JSImplementation="@mozilla.org/mozwificonnection;1", [JSImplementation="@mozilla.org/mozwificonnection;1",

View File

@ -1061,7 +1061,7 @@ var WifiManager = (function() {
"ssid", "bssid", "psk", "wep_key0", "wep_key1", "wep_key2", "wep_key3", "ssid", "bssid", "psk", "wep_key0", "wep_key1", "wep_key2", "wep_key3",
"wep_tx_keyidx", "priority", "key_mgmt", "scan_ssid", "disabled", "wep_tx_keyidx", "priority", "key_mgmt", "scan_ssid", "disabled",
"identity", "password", "auth_alg", "phase1", "phase2", "eap", "pin", "identity", "password", "auth_alg", "phase1", "phase2", "eap", "pin",
"pcsc" "pcsc", "ca_cert"
]; ];
manager.getNetworkConfiguration = function(config, callback) { manager.getNetworkConfiguration = function(config, callback) {
@ -1081,16 +1081,17 @@ var WifiManager = (function() {
var netId = config.netId; var netId = config.netId;
var done = 0; var done = 0;
var errors = 0; var errors = 0;
function hasValidProperty(name) {
return ((name in config) &&
config[name] != null &&
(["password", "wep_key0", "psk"].indexOf(name) !== -1 ||
config[name] !== '*'));
}
for (var n = 0; n < networkConfigurationFields.length; ++n) { for (var n = 0; n < networkConfigurationFields.length; ++n) {
let fieldName = networkConfigurationFields[n]; let fieldName = networkConfigurationFields[n];
if (!(fieldName in config) || if (!hasValidProperty(fieldName)) {
// These fields are special: We can't retrieve them from the
// supplicant, and often we have a star in our config. In that case,
// we need to avoid overwriting the correct password with a *.
(fieldName === "password" ||
fieldName === "wep_key0" ||
fieldName === "psk") &&
config[fieldName] === '*') {
++done; ++done;
} else { } else {
wifiCommand.setNetworkVariable(netId, fieldName, config[fieldName], function(ok) { wifiCommand.setNetworkVariable(netId, fieldName, config[fieldName], function(ok) {
@ -1532,7 +1533,8 @@ Network.api = {
eap: "rw", eap: "rw",
pin: "rw", pin: "rw",
phase1: "rw", phase1: "rw",
phase2: "rw" phase2: "rw",
serverCertificate: "rw"
}; };
// Note: We never use ScanResult.prototype, so the fact that it's unrelated to // Note: We never use ScanResult.prototype, so the fact that it's unrelated to
@ -1763,6 +1765,10 @@ function WifiWorker() {
pub.known = true; pub.known = true;
if (net.scan_ssid === 1) if (net.scan_ssid === 1)
pub.hidden = true; pub.hidden = true;
if ("ca_cert" in net && net.ca_cert &&
net.ca_cert.indexOf("keystore://WIFI_SERVERCERT_" === 0)) {
pub.serverCertificate = net.ca_cert.substr(27);
}
return pub; return pub;
}; };
@ -1825,15 +1831,29 @@ function WifiWorker() {
configured.auth_alg = net.auth_alg = "OPEN SHARED"; configured.auth_alg = net.auth_alg = "OPEN SHARED";
} }
if ("pin" in net) { function hasValidProperty(name) {
net.pin = quote(net.pin); return ((name in net) && net[name] != null);
} }
if ("phase1" in net) if (hasValidProperty("eap")) {
net.phase1 = quote(net.phase1); if (hasValidProperty("pin")) {
net.pin = quote(net.pin);
}
if ("phase2" in net) if (hasValidProperty("phase1"))
net.phase2 = quote(net.phase2); net.phase1 = quote(net.phase1);
if (hasValidProperty("phase2")) {
if (net.eap === "PEAP") {
net.phase2 = quote("auth=" + net.phase2);
} else { // TLS, TTLS
net.phase2 = quote("autheap=" + net.phase2);
}
}
if (hasValidProperty("serverCertificate"))
net.ca_cert = quote("keystore://WIFI_SERVERCERT_" + net.serverCertificate);
}
return net; return net;
}; };