Skip to content

Commit

Permalink
Can now set WIFI 802.1x certificates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Mar 11, 2022
1 parent aa872c0 commit ca34e2a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
42 changes: 22 additions & 20 deletions amt-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,15 +962,14 @@ args = {
},
*/
function execArgumentsToXml(args) {
if(args === undefined || args === null) return null;

if ((args === undefined) || (args === null)) return null;
var result = '';
for(var argName in args) {
for (var argName in args) {
var arg = args[argName];
if(!arg) continue;
if(arg['__parameterType'] === 'reference') result += referenceToXml(argName, arg);
else result += instanceToXml(argName, arg);
//if(arg['__isInstance']) result += instanceToXml(argName, arg);
if (!arg) continue;
if (arg['__parameterType'] === 'reference') { result += referenceToXml(argName, arg); }
else { result += instanceToXml(argName, arg); }
//if (arg['__isInstance']) result += instanceToXml(argName, arg);
}
return result;
}
Expand All @@ -988,25 +987,28 @@ function execArgumentsToXml(args) {
</r:WiFiEndpointSettingsInput>
*/
function instanceToXml(instanceName, inInstance) {
if(inInstance === undefined || inInstance === null) return null;
if (inInstance === undefined || inInstance === null) return null;

var hasNamespace = !!inInstance['__namespace'];
var startTag = hasNamespace ? '<q:' : '<';
var endTag = hasNamespace ? '</q:' : '</';
var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"' ): '';
var result = '<r:' + instanceName + namespaceDef + '>';
for(var prop in inInstance) {
if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;

if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop]) ) continue;

if (typeof inInstance[prop] === 'object') {
//result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
console.error('only convert one level down...');
}
else {
result += startTag + prop +'>' + inInstance[prop].toString() + endTag + prop +'>';
}
if (typeof inInstance == 'string') {
result += inInstance;
} else {
for (var prop in inInstance) {
if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;

if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;

if (typeof inInstance[prop] === 'object') {
//result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
console.error('only convert one level down...');
} else {
result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
}
}
}
result += '</r:' + instanceName + '>';
return result;
Expand Down
28 changes: 19 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7783,7 +7783,23 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>

function removeWifiEntryResponse(stack, name, response, status, tag) {
if (methodcheck(response)) return;
amtstack.Enum('CIM_WiFiEndpointSettings', function(stack, name, responses, status) { if (status == 200) { xxWireless['CIM_WiFiEndpointSettings'].responses = responses; showWirelessInfo(); } } );
// ###BEGIN###{!NetAuth}
amtstack.BatchEnum('', ['CIM_WiFiEndpointSettings'], function (stack, name, responses, status) {
if (status == 200) {
xxWireless['CIM_WiFiEndpointSettings'].responses = responses['CIM_WiFiEndpointSettings'].responses;
showWirelessInfo();
}
});
// ###END###{!NetAuth}
// ###BEGIN###{NetAuth}
amtstack.BatchEnum('', ['CIM_WiFiEndpointSettings', 'CIM_IEEE8021xSettings'], function (stack, name, responses, status) {
if (status == 200) {
xxWireless['CIM_WiFiEndpointSettings'].responses = responses['CIM_WiFiEndpointSettings'].responses;
xxWireless['CIM_IEEE8021xSettings'].responses = responses['CIM_IEEE8021xSettings'].responses;
showWirelessInfo();
}
});
// ###END###{NetAuth}
}

function showWifiNewProfile() {
Expand Down Expand Up @@ -7858,14 +7874,8 @@ <h4 style="width:100%;border-bottom:1px solid gray">Software KVM</h4>
if (Q('idx_d12password').value != '') { sc['Password'] = Q('idx_d12password').value; }
if (Q('idx_d12domain').value != '') { sc['Domain'] = Q('idx_d12domain').value; }
if (Q('idx_d12protocol').value > 3) { sc['ProtectedAccessCredential'] = Q('idx_d12pac').value; sc['PACPassword'] = Q('idx_d12pacpassword').value; }
if (parseInt(Q('idx_d12clientcert').value) >= 0) {
// TODO: DOES NOT WORK
netAuthSettingsClientCert = '<a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + amtstack.CompleteName('AMT_PublicKeyCertificate') + '</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12clientcert').value)]['InstanceID'] + '</w:Selector></w:SelectorSet></a:ReferenceParameters>';
}
if (parseInt(Q('idx_d12servercert').value) >= 0) {
// TODO: DOES NOT WORK
netAuthSettingsServerCaCert = '<a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + amtstack.CompleteName('AMT_PublicKeyCertificate') + '</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12servercert').value)]['InstanceID'] + '</w:Selector></w:SelectorSet></a:ReferenceParameters>';
}
if (parseInt(Q('idx_d12clientcert').value) >= 0) { netAuthSettingsClientCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12clientcert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
if (parseInt(Q('idx_d12servercert').value) >= 0) { netAuthSettingsServerCaCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12servercert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
}
// ###END###{NetAuth}
amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(
Expand Down

0 comments on commit ca34e2a

Please sign in to comment.