static FLMRequiredExtensionsType BuildFlmRequiredExtention(X509Certificate2 x509Certificate2) { FLMRequiredExtensionsType flmRequiredExtention = new FLMRequiredExtensionsType(); flmRequiredExtention.FacilityInfo = new FLMRequiredExtensionsTypeFacilityInfo(); flmRequiredExtention.FacilityInfo.AnnotationText = new UserTextType(); flmRequiredExtention.FacilityInfo.AnnotationText.language = "en-us"; flmRequiredExtention.FacilityInfo.AnnotationText.Value = "Example Facility List Message"; flmRequiredExtention.FacilityInfo.FacilityName = new UserTextType(); flmRequiredExtention.FacilityInfo.FacilityName.Value = "urn:x-facilityID:dcipllc.com:000000"; flmRequiredExtention.FacilityInfo.UTCOffset = new UTCOffsetType(); flmRequiredExtention.FacilityInfo.UTCOffset.Offset = "-05:00"; flmRequiredExtention.SecurityDeviceList = new SecurityDeviceListType(); CombinedType securityDevice = new CombinedType(); securityDevice.KeyInfo = new KeyInfoType(); securityDevice.KeyInfo.ItemsElementName = new ItemsChoiceType3[2]; securityDevice.KeyInfo.ItemsElementName[0] = ItemsChoiceType3.KeyName; securityDevice.KeyInfo.ItemsElementName[1] = ItemsChoiceType3.X509Data; securityDevice.KeyInfo.Items = new object[2]; securityDevice.KeyInfo.Items[0] = x509Certificate2.IssuerName.Name; X509DataType x509Data = new X509DataType(); x509Data.ItemsElementName = new ItemsChoiceType1[1]; x509Data.ItemsElementName[0] = ItemsChoiceType1.X509Certificate; x509Data.Items = new object[1]; x509Data.Items[0] = x509Certificate2.RawData; securityDevice.KeyInfo.Items[1] = x509Data; securityDevice.DeviceDescription = new deviceDescriptionType(); securityDevice.DeviceDescription.DeviceIdentifier = new deviceIdentifierPolyType(); securityDevice.DeviceDescription.DeviceIdentifier.idtype = new deviceIdentifierPolyTypeIdtype(); securityDevice.DeviceDescription.DeviceIdentifier.idtype = deviceIdentifierPolyTypeIdtype.DeviceUID; securityDevice.DeviceDescription.DeviceIdentifier.Value = "urn:uid:" + Guid.Empty; securityDevice.DeviceDescription.DeviceTypeID = new deviceTypeType(); securityDevice.DeviceDescription.DeviceTypeID.scope = "http://www.dcipllc.com/schemas/430-7/2009/FLM#deviceTypes"; securityDevice.DeviceDescription.DeviceTypeID.Value = "SMS"; securityDevice.DeviceDescription.DeviceSerial = "000000"; securityDevice.DeviceDescription.ManufacturerName = "Doremi"; securityDevice.DeviceDescription.ModelNumber = "DCP0000"; securityDevice.DeviceDescription.DeviceComment = new UserTextType(); securityDevice.DeviceDescription.DeviceComment.Value = "Not a Real Device"; flmRequiredExtention.SecurityDeviceList.Items = new CertOnlyType[1]; flmRequiredExtention.SecurityDeviceList.Items[0] = securityDevice; return flmRequiredExtention; }
private static CombinedType BuildSecurityDeviceCombinedType(flm_GetFacilitySecureEquipmentResult secureDevice, ArrayList versionInformation, X509Certificate2 deviceCertificate) { CombinedType securityDevice = new CombinedType(); securityDevice.KeyInfo = new www.w3.org.dsig.KeyInfoType(); securityDevice.KeyInfo.ItemsElementName = new www.w3.org.dsig.ItemsChoiceType3[2]; securityDevice.KeyInfo.ItemsElementName[0] = www.w3.org.dsig.ItemsChoiceType3.KeyName; securityDevice.KeyInfo.ItemsElementName[1] = www.w3.org.dsig.ItemsChoiceType3.X509Data; securityDevice.KeyInfo.Items = new object[2]; securityDevice.KeyInfo.Items[0] = deviceCertificate.GetNameInfo(X509NameType.SimpleName, false); www.w3.org.dsig.X509DataType x509Data = new www.w3.org.dsig.X509DataType(); x509Data.ItemsElementName = new www.w3.org.dsig.ItemsChoiceType1[1]; x509Data.ItemsElementName[0] = www.w3.org.dsig.ItemsChoiceType1.X509Certificate; x509Data.Items = new object[1]; x509Data.Items[0] = deviceCertificate.RawData; securityDevice.KeyInfo.Items[1] = x509Data; securityDevice.DeviceDescription = new deviceDescriptionType(); securityDevice.DeviceDescription.DeviceIdentifier = new deviceIdentifierPolyType(); securityDevice.DeviceDescription.DeviceIdentifier.idtype = new deviceIdentifierPolyTypeIdtype(); securityDevice.DeviceDescription.DeviceIdentifier.idtype = deviceIdentifierPolyTypeIdtype.DeviceUID; if (null == secureDevice.UniqueIdentifier) securityDevice.DeviceDescription.DeviceIdentifier.Value = "urn:uid:" + Guid.Empty; else securityDevice.DeviceDescription.DeviceIdentifier.Value = "urn:uid:" + secureDevice.UniqueIdentifier.ToString(); securityDevice.DeviceDescription.DeviceTypeID = new deviceTypeType(); securityDevice.DeviceDescription.DeviceTypeID.scope = "http://www.dcipllc.com/schemas/430-7/2009/FLM#deviceTypes"; if (null == secureDevice.FLM_DeviceType) securityDevice.DeviceDescription.DeviceTypeID.Value = "Other"; else securityDevice.DeviceDescription.DeviceTypeID.Value = secureDevice.FLM_DeviceType; securityDevice.DeviceDescription.DeviceSerial = secureDevice.Serial_Number; if (null == secureDevice.Manufacturer_UniqueIdentifier) securityDevice.DeviceDescription.ManufacturerID = "urn:uid:" + Guid.Empty; else securityDevice.DeviceDescription.ManufacturerID = "urn:uid:" + secureDevice.Manufacturer_UniqueIdentifier.ToString(); securityDevice.DeviceDescription.ManufacturerName = secureDevice.Manufacturer; securityDevice.DeviceDescription.ModelNumber = secureDevice.Model; securityDevice.DeviceDescription.VersionInfo = new versionInfoListType(); securityDevice.DeviceDescription.VersionInfo.Items = new string[versionInformation.Count * 2]; securityDevice.DeviceDescription.VersionInfo.ItemsElementName = new ItemsChoiceType[versionInformation.Count * 2]; int indexVersion = 0; foreach (versionInfoListType versionInfo in versionInformation) { securityDevice.DeviceDescription.VersionInfo.Items[indexVersion] = versionInfo.Items[0]; securityDevice.DeviceDescription.VersionInfo.ItemsElementName[indexVersion] = versionInfo.ItemsElementName[0]; securityDevice.DeviceDescription.VersionInfo.Items[indexVersion + 1] = versionInfo.Items[1]; securityDevice.DeviceDescription.VersionInfo.ItemsElementName[indexVersion + 1] = versionInfo.ItemsElementName[1]; indexVersion += 2; } return securityDevice; }