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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void TestOnPremDatasourceEncryptionSQLAuth()
{
SecureString secureString = new SecureString();
string expectedOutput = "My encrypted string " + Guid.NewGuid();
string linkedServiceType = "OnPremisesSqlLinkedService";

var cmdlet = new NewAzureDataFactoryEncryptValueCommand
{
Expand All @@ -44,17 +45,18 @@ public void TestOnPremDatasourceEncryptionSQLAuth()
Value = secureString,
ResourceGroupName = ResourceGroupName,
DataFactoryName = DataFactoryName,
GatewayName = GatewayName
GatewayName = GatewayName,
Type = linkedServiceType
};

// Arrange
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null)).Returns(expectedOutput);
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType)).Returns(expectedOutput);

// Action
cmdlet.ExecuteCmdlet();

// Assert
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null), Times.Once());
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType), Times.Once());
this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once());
}

Expand All @@ -67,6 +69,7 @@ public void TestOnPremDatasourceEncryptionWinAuth()
string winAuthUserName = "foo";
SecureString winAuthPassword = new SecureString();
PSCredential credential = new PSCredential(winAuthUserName, winAuthPassword);
string linkedServiceType = "OnPremisesFileSystemLinkedService";

var cmdlet = new NewAzureDataFactoryEncryptValueCommand
{
Expand All @@ -76,17 +79,18 @@ public void TestOnPremDatasourceEncryptionWinAuth()
ResourceGroupName = ResourceGroupName,
DataFactoryName = DataFactoryName,
GatewayName = GatewayName,
Credential = credential
Credential = credential,
Type = linkedServiceType
};

// Arrange
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential)).Returns(expectedOutput);
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType)).Returns(expectedOutput);

// Action
cmdlet.ExecuteCmdlet();

// Assert
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential), Times.Once());
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType), Times.Once());
this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<HintPath>..\..\..\packages\Microsoft.DataFactories.Runtime.0.11.1-preview\lib\net45\Microsoft.DataFactories.Runtime.dll</HintPath>
</Reference>
<Reference Include="Microsoft.DataTransfer.Gateway.Encryption">
<HintPath>..\..\..\packages\Microsoft.DataTransfer.Gateway.Encryption.1.1.0-preview\lib\net45\Microsoft.DataTransfer.Gateway.Encryption.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.DataTransfer.Gateway.Encryption.1.2.1-preview\lib\net45\Microsoft.DataTransfer.Gateway.Encryption.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class NewAzureDataFactoryEncryptValueCommand : DataFactoryBaseCmdlet
[Parameter(ParameterSetName = ByFactoryName, Position = 4, Mandatory = false, HelpMessage = "The windows authentication credential.")]
public PSCredential Credential { get; set; }

[Parameter(ParameterSetName = ByFactoryObject, Position = 4, Mandatory = false, HelpMessage = "The linked service type.")]
[Parameter(ParameterSetName = ByFactoryName, Position = 5, Mandatory = false, HelpMessage = "The linked service type.")]
[ValidateSet("OnPremisesSqlLinkedService", "OnPremisesFileSystemLinkedService", IgnoreCase = true)]
public string Type { get; set; }

[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
public override void ExecuteCmdlet()
{
Expand All @@ -72,7 +77,7 @@ public override void ExecuteCmdlet()
else
{
// On-premises encryption with Gateway
encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName, GatewayName, Credential);
encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName, GatewayName, Credential, Type);
}

WriteObject(encryptedValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,13 @@
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="5" aliases="">
<maml:name>Type</maml:name>
<maml:description>
<maml:para>Specifies the linked service type. This cmdlet encrypts data for the linked service type that this parameter specifies. For on premises SQL linked service, type OnPremisesSqlLinkedService. For file system linked service, type OnPremisesFileSystemLinkedService.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>New-AzureDataFactoryEncryptValue</maml:name>
Expand Down Expand Up @@ -2126,6 +2133,13 @@
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="6" aliases="">
<maml:name>Type</maml:name>
<maml:description>
<maml:para>Specifies the linked service type. This cmdlet encrypts data for the linked service type that this parameter specifies. For on premises SQL linked service, type OnPremisesSqlLinkedService. For file system linked service, type OnPremisesFileSystemLinkedService.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
Expand Down Expand Up @@ -2201,6 +2215,18 @@
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="6" aliases="">
<maml:name>Type</maml:name>
<maml:description>
<maml:para>Specifies the linked service type. For on premises SQL linked service, type OnPremisesSqlLinkedService. For file system linked service, type OnPremisesFileSystemLinkedService. </maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
Expand Down Expand Up @@ -2277,13 +2303,35 @@
<dev:code>
PS C:\&gt; $Value = ConvertTo-SecureString "Data Source=ContosoServer;Initial Catalog=catelog;Integrated Security=True" -AsPlainText -Force
PS C:\&gt; $Credential = Get-Credential
PS C:\&gt; New-AzureDataFactoryEncryptValue -DataFactoryName "WikiADF" -GatewayName "WikiGateway" -ResourceGroupName "ADF" -Value $Value -Credential $Credential
PS C:\&gt; New-AzureDataFactoryEncryptValue -DataFactoryName "WikiADF" -GatewayName "WikiGateway" -ResourceGroupName "ADF" -Value $Value -Credential $Credential -Type OnPremisesSqlLinkedService
data source=ContosoServer;initial catalog=catelog;EncryptedCredential=KAAAAAABAAAQAAAAQUU5MUVBNzY4QkFCQkI3MEUwRTMxOUNFNkM0MjRDOTVDNDk3RTcyRi8XAXyE/H+f3JydTkdg5t2g1eC/VtyF3NAD3idYnhrAphPJmO0pCaG5nH2IY48L3XJi7wabrlrGF+ieiWh1bwdgdxrW+t2jWPnLvT/ENUXtcevpx/dmTGKagH8TU9HLcoL1CAanb7Vkpga1B/uzRxBnVdsdtfvBzxG2M810tj1WzL8lFzA1mO5GbB0+ge116y0scL1vxjerjl5Muv0r0scG3lhj+IF0sXUMITFvhQwOIqweR052E6JlfJu+mTNFLCCkpw1iV+rhRhKqJF752dBuWjzI1EoyQUE17oK4OevkquuhUbfJmzj9BhGKQ+VkndAZiSw19FEGSC7JzoUe/XWEs/FJYrQCCXIeNS94J9/VzN6KPYJR1pzAYCtnhq+p8Q==
</dev:code>
<dev:remarks>
<maml:para>The first command uses the ConvertTo-SecureString cmdlet to convert the specified string to a SecureString object, and then stores that object in the $Value variable.</maml:para>
<maml:para>The second command uses the Get-Credential cmdlet to collect the windows authentication user name and password, and then stores that PSCredential object in the $Credential variable. For more information, type Get-Help Get-Credential.</maml:para>
<maml:para>The third command creates an encrypted value for the object stored in $Value and $Credential for the specified data factory, gateway, and resource group. </maml:para>
<maml:para>The third command creates an encrypted value for the object stored in $Value and $Credential for the specified data factory, gateway, resource group, and linked service type. </maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>Example 4: Encrypt the file system host name</maml:title>
<maml:introduction>
<maml:para></maml:para>
</maml:introduction>
<dev:code>
PS C:\&gt; $Value = ConvertTo-SecureString "hostname" -AsPlainText -Force
PS C:\&gt; $Credential = Get-Credential
PS C:\&gt; New-AzureDataFactoryEncryptValue -DataFactoryName "WikiADF" -GatewayName "WikiGateway" -ResourceGroupName "ADF" -Value $Value -Credential $Credential -Type OnPremisesFileSystemLinkedService
EncryptedCredential=KAAAAAABAAAQAAAAQUU5MUVBNzY4QkFCQkI3MEUwRTMxOUNFNkM0MjRDOTVDNDk3RTcyRi8XAXyE/H+f3JydTkdg5t2g1eC/VtyF3NAD3idYnhrAphPJmO0pCaG5nH2IY48L3XJi7wabrlrGF+ieiWh1bwdgdxrW+t2jWPnLvT/ENUXtcevpx/dmTGKagH8TU9HLcoL1CAanb7Vkpga1B/uzRxBnVdsdtfvBzxG2M810tj1WzL8lFzA1mO5GbB0+ge116y0scL1vxjerjl5Muv0r0scG3lhj+IF0sXUMITFvhQwOIqweR052E6JlfJu+mTNFLCCkpw1iV+rhRhKqJF752dBuWjzI1EoyQUE17oK4OevkquuhUbfJmzj9BhGKQ+VkndAZiSw19FEGSC7JzoUe/XWEs/FJYrQCCXIeNS94J9/VzN6KPYJR1pzAYCtnhq+p8Q==
</dev:code>
<dev:remarks>
<maml:para>The first command uses the ConvertTo-SecureString cmdlet to convert the specified string to a SecureString object, and then stores that object in the $Value variable.</maml:para>
<maml:para>The second command uses the Get-Credential cmdlet to collect the windows authentication user name and password, and then stores that PSCredential object in the $Credential variable. For more information, type Get-Help Get-Credential.</maml:para>
<maml:para>The third command creates an encrypted value for the object stored in $Value and $Credential for the specified data factory, gateway, resource group, and linked service type. </maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ public virtual string CloudEncryptString(SecureString value, string resourceGrou
resourceGroupName, dataFactoryName);
}

public virtual string OnPremisesEncryptString(SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName, PSCredential credential)
public virtual string OnPremisesEncryptString(SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName, PSCredential credential, string type)
{
if (value == null)
{
throw new ArgumentNullException("value");
}

LinkedServiceType linkedServiceType = type == null ? LinkedServiceType.OnPremisesSqlLinkedService : (LinkedServiceType) Enum.Parse(typeof(LinkedServiceType), type, true);

var response = DataPipelineManagementClient.Gateways.RetrieveConnectionInfo(resourceGroupName, dataFactoryName, gatewayName);
var gatewayEncryptionInfos = new[]
{
Expand All @@ -54,9 +56,8 @@ public virtual string OnPremisesEncryptString(SecureString value, string resourc

string userName = credential != null ? credential.UserName : null;
SecureString password = credential != null ? credential.Password : null;
UserInputConnectionString connectionString = new UserInputConnectionString(value, userName, password);
var gatewayEncryptionClient = new GatewayEncryptionClient();
return gatewayEncryptionClient.Encrypt(connectionString, gatewayEncryptionInfos);
UserInputConnectionString connectionString = new UserInputConnectionString(value, userName, password, linkedServiceType);
return GatewayEncryptionClient.Encrypt(connectionString, gatewayEncryptionInfos);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
<package id="Microsoft.DataFactories.Runtime" version="0.11.1-preview" targetFramework="net45" />
<package id="Microsoft.DataTransfer.Gateway.Encryption" version="1.1.0-preview" targetFramework="net45" />
<package id="Microsoft.DataTransfer.Gateway.Encryption" version="1.2.1-preview" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.11.10918.1222" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.0.0" targetFramework="net45" />
Expand Down