internal static AzureBlobBackupStorageInfo FromAzureBlobBackupStorageInfoView(
            BackupRestoreView.AzureBlobBackupStorageInfo azureBlobBackupStorageInfoView)
        {
            var azureBlobBackupStorageInfo = new AzureBlobBackupStorageInfo
            {
                ContainerName = azureBlobBackupStorageInfoView.ContainerName
            };

            string certThumbprint, certStore;

            EncryptionCertConfigHandler.GetEncryptionCertDetails(out certThumbprint, out certStore);

            // Encrypt the creds if cert configured
            if (!String.IsNullOrEmpty(certThumbprint))
            {
                azureBlobBackupStorageInfo.ConnectionString = EncryptionUtility.EncryptText(azureBlobBackupStorageInfoView.ConnectionString,
                                                                                            certThumbprint,
                                                                                            certStore);
                azureBlobBackupStorageInfo.IsConnectionStringEncrypted = true;
            }
            else
            {
                azureBlobBackupStorageInfo.ConnectionString            = azureBlobBackupStorageInfoView.ConnectionString;
                azureBlobBackupStorageInfo.IsConnectionStringEncrypted = false;
            }

            return(azureBlobBackupStorageInfo);
        }
        internal static FileShareBackupStorageInfo FromfileShareBackupStorageInfoView(
            BackupRestoreView.FileShareBackupStorageInfo fileShareBackupStorageInfoView)
        {
            var fileShareBackupStorageInfo = new FileShareBackupStorageInfo
            {
                Path              = fileShareBackupStorageInfoView.Path,
                PrimaryUserName   = fileShareBackupStorageInfoView.PrimaryUserName,
                SecondaryUserName = fileShareBackupStorageInfoView.SecondaryUserName
            };

            string certThumbprint, certStore;

            EncryptionCertConfigHandler.GetEncryptionCertDetails(out certThumbprint, out certStore);

            // Encrypt the creds if cert configured
            if (!String.IsNullOrEmpty(certThumbprint))
            {
                if (!String.IsNullOrEmpty(fileShareBackupStorageInfoView.PrimaryPassword))
                {
                    fileShareBackupStorageInfo.PrimaryPassword = EncryptionUtility.EncryptText(fileShareBackupStorageInfoView.PrimaryPassword,
                                                                                               certThumbprint,
                                                                                               certStore);
                }

                if (!String.IsNullOrEmpty(fileShareBackupStorageInfoView.SecondaryPassword))
                {
                    fileShareBackupStorageInfo.SecondaryPassword =
                        EncryptionUtility.EncryptText(fileShareBackupStorageInfoView.SecondaryPassword, certThumbprint,
                                                      certStore);
                }

                fileShareBackupStorageInfo.IsPasswordEncrypted = true;
            }
            else
            {
                fileShareBackupStorageInfo.PrimaryPassword     = fileShareBackupStorageInfoView.PrimaryPassword;
                fileShareBackupStorageInfo.SecondaryPassword   = fileShareBackupStorageInfoView.SecondaryPassword;
                fileShareBackupStorageInfo.IsPasswordEncrypted = false;
            }

            return(fileShareBackupStorageInfo);
        }