private StorageAccountCredentialResponse ConvertToSACResponse(StorageAccountCredential cred) { StorageAccountCredentialResponse sac = new StorageAccountCredentialResponse(); sac.CloudType = cred.CloudType; sac.Hostname = cred.Hostname; sac.InstanceId = cred.InstanceId; sac.IsDefault = cred.IsDefault; sac.Location = cred.Location; sac.Login = cred.Login; sac.Name = cred.Name; sac.OperationInProgress = cred.OperationInProgress; sac.PasswordEncryptionCertThumbprint = cred.PasswordEncryptionCertThumbprint; sac.Password = cred.Password; sac.UseSSL = cred.UseSSL; sac.VolumeCount = 0; return sac; }
/// <summary> /// Parse storage account credential /// </summary> private void ParseStorageAccountCredentials() { this.storageAcctCredList = new List<StorageAccountCredential>(); var cloudCredentialsList = this.GetSubElements(doc.Root, "CloudCredentials"); foreach (var cloudCredentialsL1 in cloudCredentialsList) { foreach (var elemL2 in cloudCredentialsL1.Elements()) { StorageAccountCredential credential = new StorageAccountCredential(); foreach (var elemL3 in elemL2.Elements()) { switch (elemL3.Name.LocalName) { case "Hostname": { credential.Hostname = elemL3.Value; break; } case "Login": { credential.Login = elemL3.Value; break; } case "Password": { credential.Password = this.serviceSecretEncryptor.EncryptSecret(elemL3.Value); credential.PasswordEncryptionCertThumbprint = this.serviceSecretEncryptor.GetSecretsEncryptionThumbprint(); break; } case "Id": { credential.InstanceId = elemL3.Value; break; } case "Alias": { credential.Name = elemL3.Value; break; } case "Provider": { credential.CloudType = CloudTypeMap[elemL3.Value]; break; } case "SSL": { credential.UseSSL = Boolean.Parse(elemL3.Value); break; } case "Location": { credential.Location = elemL3.Value; break; } default: { break; } } } credential.IsDefault = false; credential.OperationInProgress = OperationInProgress.None; credential.VolumeCount = 0; this.storageAcctCredList.Add(credential); } } }
private List<StorageAccountCredential> ParseSACs(XmlDocument document) { List<StorageAccountCredential> sacList = new List<StorageAccountCredential>(); XmlNodeList nodeList = document.SelectNodes(@"//SAC"); foreach (XmlNode node in nodeList) { StorageAccountCredential sac = new StorageAccountCredential(); sac.Name = node.Attributes["Name"].Value; sac.Hostname = node.Attributes["HostName"].Value; sac.Password = node.Attributes["Password"].Value; sac.Location = node.Attributes["Location"].Value; sac.Login = node.Attributes["Login"].Value; sac.InstanceId = node.Attributes["Id"].Value; sac.CloudType = (CloudType)Enum.Parse(typeof(CloudType), node.Attributes["Provider"].Value, true); sac.UseSSL = Boolean.Parse(node.Attributes["UseSSL"].Value); sac.PasswordEncryptionCertThumbprint = node.Attributes["PasswordEncryptionCertThumbprint"].Value; sacList.Add(sac); } return sacList; }
/// <summary> /// Convert sac to sac response /// </summary> /// <param name="cred">Sac object to be converted</param> /// <returns>StorageAccountCredentialResponse object</returns> private StorageAccountCredentialResponse ConvertToSACResponse(StorageAccountCredential cred) { StorageAccountCredentialResponse credResponse = new StorageAccountCredentialResponse(); credResponse.CloudType = cred.CloudType; credResponse.Hostname = cred.Hostname; credResponse.InstanceId = cred.InstanceId; credResponse.IsDefault = cred.IsDefault; credResponse.Location = cred.Location; credResponse.Login = cred.Login; credResponse.Name = cred.Name; credResponse.OperationInProgress = cred.OperationInProgress; credResponse.Password = cred.Password; credResponse.PasswordEncryptionCertThumbprint = cred.PasswordEncryptionCertThumbprint; credResponse.UseSSL = cred.UseSSL; credResponse.VolumeCount = cred.VolumeCount; return credResponse; }