Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/SDKs/StorSimple/Series1200/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>StorSimple_2016-10-01;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Microsoft.Azure.Management.StorSimple1200Series.Models
{
public partial class AccessControlRecord
{
public AccessControlRecord(
StorSimpleManagementClient client,
string resourceGroupName,
string managerName,
string name) : base(client, resourceGroupName, managerName, name)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Microsoft.Azure.Management.StorSimple1200Series.Models
{
public partial class AlertSettings
{
public AlertSettings(
StorSimpleManagementClient client,
string resourceGroupName,
string managerName,
string name) : base(client, resourceGroupName, managerName, name)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Microsoft.Azure.Management.StorSimple1200Series.Models
{
public partial class BackupScheduleGroup
{
public BackupScheduleGroup(
StorSimpleManagementClient client,
string resourceGroupName,
string managerName,
string name) : base(client, resourceGroupName, managerName, name)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Microsoft.Azure.Management.StorSimple1200Series.Models
{
public partial class ChapSettings
{
public ChapSettings(
StorSimpleManagementClient client,
string resourceGroupName,
string managerName,
string name) : base(client, resourceGroupName, managerName, name)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace Microsoft.Azure.Management.StorSimple1200Series
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class CisTestContextConstants
{
#region CisTestContext.xml Tags and Attributes

public const string TagCisTestContext = "CisTestContext";
public const string TagAccessDetail = "AccessDetail";
public const string TagTenantId = "TenantId";
public const string TagClientId = "ClientId";
public const string TagSecret = "Secret";
public const string TagSubscriptionId = "SubscriptionId";
public const string TagResourceGroupName = "ResourceGroupName";
public const string TagResourceLocation = "ResourceLocation";
public const string TagEnvironment = "Environment";
public const string TagAuthenticationEndPoint = "AuthenticationEndPoint";
public const string TagTokenAudience = "TokenAudience";
public const string TagArmEndPoint = "ArmEndPoint";
public const string TagProviderNamespace = "ProviderNamespace";
public const string TagCisResource = "CisResource";
public const string TagCisAppliance = "CisAppliance";
public const string TagCisIscsiServer = "CisIscsiServer";
public const string TagCisFileServer = "CisFileServer";
public const string TagIsOneBox = "IsOneBox";
public const string TagStorageConnectionString = "StorageConnectionString";
public const string TagSupportPackagePasskey = "SupportPackagePasskey";
public const string TagStorageAccount = "StorageAccount";
public const string TagIsAadEnabled = "IsAadEnabled";
public const string TagTestAadMigration = "TestAadMigration";
public const string TagCiSDataQueue = "CiSDataQueue";

public const string AttrName = "name";
public const string AttrId = "id";
public const string AttrType = "type";
public const string AttrServiceEncryptionKey = "serviceEncryptionKey";
public const string AttrLogin = "login";
public const string AttrPrimaryPassword = "primaryPassword";
public const string AttrSecondaryPassword = "secondaryPassword";
public const string AttrConnectionString = "connectionString";

public const string ValResourceTypeHelsinki = "H";
public const string ValResourceTypeGarda = "G";

public const string ValApplianceTypeHelsinkiVmIscsi = "I";
public const string ValApplianceTypeHelsinkiVmNas = "N";
public const string ValApplianceTypeGarda = "G";
public const string ValApplianceTypeAzureCis = "A";

#endregion

#region CisTestContextConfig.xml Tags and Attributes

public const string TagTestContextConfiguration = "TestContextConfiguration";
public const string TagContextDirectoryPath = "ContextDirectoryPath";
public const string TagContextXMLFileName = "ContextXMLFileName";

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Microsoft.Azure.Management.StorSimple1200Series
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class CisTestEnvironmentAndAccessDetail
{
public string TenantId { get; set; }
public string ClientId { get; set; }
public string Secret { get; set; }
public string SubscriptionId { get; set; }
public string ResourceGroupName { get; set; }
public string ResourceLocation { get; set; }
public string AuthenticationEndPoint { get; set; }
public string TokenAudience { get; set; }
public string ArmEndPoint { get; set; }
public string ProviderNamespace { get; set; }
public bool IsOneBox { get; set; }
public string StorageConnectionString { get; set; }
public string SupportPackagePasskey { get; set; }
public string StorageAccountName { get; set; }
public string StorageAccountLogin { get; set; }
public string StorageAccountPrimaryPassword { get; set; }
public string StorageAccountSecondaryPassword { get; set; }
public bool UseAadFlow { get; set; }
public bool TestAadMigration { get; set; }
public string CiSDataQueueName { get; set; }
public string CiSDataQueueConnectionString { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
namespace Microsoft.Azure.Management.StorSimple1200Series
{
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;

/// <summary>
/// The crypto helper.
/// </summary>
public class CryptoHelper
{
/// <summary>
/// The salt for generating encryption keys.
/// </summary>
private static readonly byte[] Salt = Encoding.ASCII.GetBytes("o6806642kbM7c5");

/// <summary>
/// The AES algorithm is used to decrypt the given cipherText.
/// </summary>
/// <param name="cipherText">The cipher text.</param>
/// <param name="sharedSecret">The shared secret.</param>
/// <returns>The decrypted secret in pain text.</returns>
public static string DecryptCipherAES(string cipherText, string sharedSecret)
{
if (string.IsNullOrEmpty(cipherText))
{
return cipherText;
}

Aes aesAlg = null;

string plaintext = null;

// generate the key from the shared secret and the salt
Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(sharedSecret, Salt);

// Create the streams used for decryption.
byte[] bytes = Convert.FromBase64String(cipherText);
using (MemoryStream memoryDecrypt = new MemoryStream(bytes))
{
aesAlg = Aes.Create();
aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8);

// Get the initialization vector from the encrypted stream
aesAlg.IV = ReadByteArray(memoryDecrypt);

// Create a decrytor to perform the stream transform.
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
using (CryptoStream cryptoDecrypt = new CryptoStream(memoryDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader streamDecrypt = new StreamReader(cryptoDecrypt))
{
// Read the decrypted bytes from the decrypting stream and place them in a string.
plaintext = streamDecrypt.ReadToEnd();
}
}
}

return plaintext;
}

public static string DecryptStringAES(string cipherText, string sharedSecret)
{
if (string.IsNullOrEmpty(cipherText))
return cipherText;

Aes aesAlg = null;
string plaintext = null;

// generate the key from the shared secret and the salt
Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(sharedSecret, Salt);

// Create the streams used for decryption.
byte[] bytes = Convert.FromBase64String(cipherText);
using (MemoryStream msDecrypt = new MemoryStream(bytes))
{
aesAlg = Aes.Create();
aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8);
// Get the initialization vector from the encrypted stream
aesAlg.IV = ReadByteArray(msDecrypt);
// Create a decrytor to perform the stream transform.
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
using (CryptoStream csDecrypt =
new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))

// Read the decrypted bytes from the decrypting stream
// and place them in a string.
plaintext = srDecrypt.ReadToEnd();
}
}

return plaintext;
}

/// <summary>
/// This method encrypts a given secret using the public certificate.
/// </summary>
/// <param name="plainText">The secret in plain text.</param>
/// <param name="publicCertificate">The public certificate to be used for encryption.</param>
/// <returns>The encrypted secret.</returns>
public static string EncryptSecretRSAPKCS(string plainText, string publicCertificate)
{
string encryptedSecret = null;
encryptedSecret = EncryptStringRsaPkcs1v15(plainText, publicCertificate);
return encryptedSecret;
}

private static string EncryptStringRsaPkcs1v15(string plaintext, string encodedCertificate)
{
X509Certificate2 cert = new X509Certificate2(Convert.FromBase64String(encodedCertificate));
if (string.IsNullOrEmpty(plaintext) || cert == null)
{
return null;
}

byte[] textBytes = Encoding.UTF8.GetBytes(plaintext);
byte[] encryptedTextBytes;

// Create a new instance of RSACryptoServiceProvider, and encrypt the passed byte array and specify OAEP padding false to use PKCS#1 V1.5 padding.
#if FullNetFx
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PublicKey.Key;
encryptedTextBytes = rsa.Encrypt(textBytes, false);
#else
RSA rsa = cert.GetRSAPublicKey();
encryptedTextBytes = rsa.Encrypt(textBytes, RSAEncryptionPadding.Pkcs1);
#endif
var encryptedBase64 = Convert.ToBase64String(encryptedTextBytes);
return encryptedBase64;
}

/// <summary>
/// Helper method to read byte array from a stream.
/// </summary>
/// <param name="s">The stream.</param>
/// <returns>The byte array.</returns>
private static byte[] ReadByteArray(Stream s)
{
byte[] rawLength = new byte[sizeof(int)];
if (s.Read(rawLength, 0, rawLength.Length) != rawLength.Length)
{
throw new Exception("Stream did not contain properly formatted byte array");
}

byte[] buffer = new byte[BitConverter.ToInt32(rawLength, 0)];
if (s.Read(buffer, 0, buffer.Length) != buffer.Length)
{
throw new Exception("Did not read byte array properly");
}

return buffer;
}
}
}
Loading