262 lines
7.3 KiB
C#
262 lines
7.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Intel.Management.Wsman;
|
|
|
|
namespace Intel.Management.PSModule.Amt
|
|
{
|
|
class Wired8021xService : SettingsContainer
|
|
{
|
|
|
|
public Wired8021xService(DriveItem parent)
|
|
: base("Wired8021x",parent)
|
|
{
|
|
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
// only enable will update the container
|
|
}
|
|
|
|
public void Apply()
|
|
{
|
|
_refToSettings.Put(_settingsObj);
|
|
}
|
|
|
|
|
|
public override void GetChildItems(ChildWriter writer)
|
|
{
|
|
IWsmanConnection conn = ((AmtRootService)GetRoot()).Connection;
|
|
|
|
_refToSettings = conn.NewReference("SELECT * FROM AMT_8021XProfile");
|
|
|
|
_settingsObj= _refToSettings.Get();
|
|
|
|
|
|
|
|
writer.Add(new EnableProfile(this));
|
|
|
|
|
|
writer.Add(new DriveEntry("SupportedProtocols", ValueList.AuthenticationProtocol.Values.ToArray(), this));
|
|
writer.Add(new DriveEntry("CertificateComparisonMethods", new string[] { "FullName", "DomainSuffix" }, this));
|
|
|
|
if (HasSetting("ActiveInS0"))
|
|
writer.Add(new BooleanSetting("ActiveInS0", this));
|
|
|
|
writer.Add(new AuthenticationSetting(this));
|
|
|
|
writer.Add( new OptionalStringSetting("RoamingIdentity", this));
|
|
writer.Add(new OptionalStringSetting("ServerCertificateName", this));
|
|
|
|
writer.Add(new OptionalStringSetting("ServerCertificateNameComparison", this));
|
|
|
|
writer.Add(new OptionalStringSetting("Username", this));
|
|
writer.Add(new OptionalStringSetting("Password", this));
|
|
writer.Add(new OptionalStringSetting("Domain", this));
|
|
|
|
writer.Add(new ProtectedAccessCredential(this));
|
|
|
|
|
|
|
|
writer.Add(new OptionalStringSetting("PACPassword", this));
|
|
|
|
|
|
if (HasSetting("PxeTimeout"))
|
|
writer.Add(new UIntSetting("PxeTimeout", this));
|
|
|
|
writer.Add(new CertificateCredential("ClientCertificate", this));
|
|
writer.Add(new CertificateCredential("ServerCertificateIssuer", this));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class EnableProfile : SettingsItem
|
|
{
|
|
public EnableProfile(SettingsContainer container)
|
|
: base("Enabled", container)
|
|
{
|
|
}
|
|
|
|
public override object Value
|
|
{
|
|
get
|
|
{
|
|
SettingsContainer settings = _parent as SettingsContainer;
|
|
return bool.Parse(settings.GetSetting(_name));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public override void SetItem(object values, DriveProvider provider)
|
|
{
|
|
Wired8021xService settings = _parent as Wired8021xService;
|
|
|
|
settings.SetSetting("Enabled", values.ToString().ToLower());
|
|
settings.Apply();
|
|
|
|
_parent.Clear();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Wired 802.1x Authentiation protocol Setting
|
|
/// </summary>
|
|
class AuthenticationSetting : SettingsItem
|
|
{
|
|
public AuthenticationSetting(SettingsContainer container)
|
|
: base("AuthenticationProtocol", container)
|
|
{
|
|
}
|
|
|
|
public override object Value
|
|
{
|
|
get
|
|
{
|
|
SettingsContainer settings = _parent as SettingsContainer;
|
|
if (settings.HasSetting(_name))
|
|
{
|
|
return (AuthenticationProtocol)uint.Parse(settings.GetSetting(_name));
|
|
}
|
|
else
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
|
|
public override void SetItem(object values, DriveProvider provider)
|
|
{
|
|
SettingsContainer settings = _parent as SettingsContainer;
|
|
|
|
string value = null;
|
|
|
|
|
|
if (values is string)
|
|
{
|
|
|
|
ValueMap map = ValueMap.Create("1", ValueList.AuthenticationProtocol);
|
|
|
|
value = map.GetValueFromString(values.ToString());
|
|
}
|
|
|
|
settings.SetSetting(_name, value);
|
|
}
|
|
|
|
|
|
|
|
}// end AuthenticationSetting class
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// ProtectedAccessCredential
|
|
/// </summary>
|
|
class ProtectedAccessCredential : SettingsItem
|
|
{
|
|
public ProtectedAccessCredential(SettingsContainer container)
|
|
: base("ProtectedAccessCredential", container)
|
|
{
|
|
}
|
|
|
|
public override object Value
|
|
{
|
|
get
|
|
{
|
|
SettingsContainer settings = _parent as SettingsContainer;
|
|
if (settings.HasSetting(_name))
|
|
return Convert.FromBase64String( settings.GetSetting(_name) );
|
|
|
|
return new byte[0];
|
|
}
|
|
}
|
|
|
|
public override void SetItem(object values, DriveProvider provider)
|
|
{
|
|
SettingsContainer settings = _parent as SettingsContainer;
|
|
settings.SetSetting(_name, Convert.ToBase64String( (byte[])values));
|
|
}
|
|
|
|
}// end ProtectedAccessCredential class
|
|
|
|
/// <summary>
|
|
/// CertificateCredential
|
|
/// </summary>
|
|
class CertificateCredential : DriveItem
|
|
{
|
|
|
|
public CertificateCredential(string name,SettingsContainer container)
|
|
: base(name,null, container)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
public override object Value
|
|
{
|
|
get
|
|
{
|
|
|
|
if (_value == null)
|
|
_value = new DeviceCertificate();
|
|
|
|
return _value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SetItem(object values, DriveProvider provider)
|
|
{
|
|
|
|
SettingsContainer settings = _parent as SettingsContainer;
|
|
|
|
|
|
IWsmanConnection conn = ((AmtRootService)GetRoot()).Connection;
|
|
if (values == null)
|
|
{
|
|
settings.ChangeSetting(_name, null);
|
|
}
|
|
else if (values is DeviceCertificate)
|
|
{
|
|
DeviceCertificate devCert = (DeviceCertificate)values;
|
|
|
|
settings.ChangeSetting(_name, TLSService.GetCertificateRef(devCert, conn));
|
|
|
|
_value = devCert;
|
|
|
|
}
|
|
else
|
|
{
|
|
throw new System.Management.Automation.PSArgumentException("DeviceCertificate required");
|
|
}
|
|
|
|
|
|
//FirmwareCertificate firmware = new FirmwareCertificate("", "", "");
|
|
//IManagedReference refToValue = TLSService.GetTlsCertificate(_value.ToString(),conn);
|
|
//settings.ChangeSetting(_name, refToValue);
|
|
|
|
}
|
|
|
|
public override object GetReturnObject()
|
|
{
|
|
return new NameValuePairItem(Name, Value);
|
|
}
|
|
|
|
}// end CertificateCredential class
|
|
|
|
}//end Wired8021x
|
|
} //end Namepace
|
|
|
|
|
|
|