コード例 #1
0
        private List<MigrationChapSetting> ParseChapSettings(XmlDocument document, string chapSettingsNodeName)
        {
            List<MigrationChapSetting> iscsiChapList = null;
            XmlNodeList nodeList = document.SelectNodes(@"//" + chapSettingsNodeName);
            if (null != nodeList && 0 < nodeList.Count)
            {
                iscsiChapList = new List<MigrationChapSetting>();
                foreach (XmlNode node in nodeList)
                {
                    if (null != node.Attributes["Name"])
                    {
                        MigrationChapSetting iscsiChap = new MigrationChapSetting();
                        iscsiChap.Name = node.Attributes["Name"].Value;
                        iscsiChap.Password = node.Attributes["Password"].Value;
                        iscsiChap.Valid = Boolean.Parse(node.Attributes["Valid"].Value);
                        iscsiChap.Id = node.Attributes["Id"].Value;
                        iscsiChap.SecretsEncryptionThumbprint = node.Attributes["SecretsEncryptionThumbprint"].Value;
                        iscsiChapList.Add(iscsiChap);
                    }
                }
            }

            return iscsiChapList;
        }
コード例 #2
0
        /// <summary>
        /// Outbound chap setting parser
        /// </summary>
        /// <param name="scsiClapRootElement">out bound chap setting root</param>
        /// <returns>chap setting</returns>
        private List<MigrationChapSetting> ParseScsiOutBoundChapDataImpl(XElement scsiClapRootElement)
        {
            List<MigrationChapSetting> chapSettingList = null;
            if (null != scsiClapRootElement)
            {
                MigrationChapSetting chapSetting = new MigrationChapSetting();
                var Id = this.GetSubElements(scsiClapRootElement, "Id");
                if (null != Id && 0 < Id.Count())
                {
                    chapSetting.Id = Id.First().Value;
                }

                chapSetting.Name = this.GetSubElements(scsiClapRootElement, "Name").First().Value;
                chapSetting.Password =
                    this.serviceSecretEncryptor.EncryptSecret(
                        this.GetSubElements(scsiClapRootElement, "Password").First().Value);
                chapSetting.SecretsEncryptionThumbprint = this.serviceSecretEncryptor.GetSecretsEncryptionThumbprint();
                chapSetting.Valid = bool.Parse(this.GetSubElements(scsiClapRootElement, "Valid").First().Value);
                if (!string.IsNullOrEmpty(chapSetting.Name) && !string.IsNullOrEmpty(chapSetting.Password))
                {
                    chapSettingList = new List<MigrationChapSetting>();
                    chapSettingList.Add(chapSetting);
                }
            }

            return chapSettingList;
        }