public virtual string OnPremisesEncryptString(SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName, PSCredential credential, string type, string nonCredentialValue, string authenticationType) { LinkedServiceType linkedServiceType = type == null ? LinkedServiceType.OnPremisesSqlLinkedService : (LinkedServiceType)Enum.Parse(typeof(LinkedServiceType), type, true); if (linkedServiceType != LinkedServiceType.OnPremisesOdbcLinkedService && (value == null || value.Length == 0)) { throw new ArgumentNullException("value"); } AuthenticationType authType = authenticationType == null ? AuthenticationType.None : (AuthenticationType)Enum.Parse(typeof(AuthenticationType), authenticationType, true); var response = DataPipelineManagementClient.Gateways.RetrieveConnectionInfo(resourceGroupName, dataFactoryName, gatewayName); var gatewayEncryptionInfos = new[] { new GatewayEncryptionInfo { ServiceToken = response.ConnectionInfo.ServiceToken, IdentityCertThumbprint = response.ConnectionInfo.IdentityCertThumbprint, HostServiceUri = response.ConnectionInfo.HostServiceUri, InstanceVersionString = response.ConnectionInfo.Version } }; string userName = credential != null ? credential.UserName : null; SecureString password = credential != null ? credential.Password : null; UserInputConnectionString connectionString = new UserInputConnectionString(value, nonCredentialValue, userName, password, linkedServiceType, authType); return(GatewayEncryptionClient.Encrypt(connectionString, gatewayEncryptionInfos)); }
private (AdfItemType type, object value) DeserializeLinkedService() { var jo = JObject.Parse(_json); var typeValue = jo["properties"]?["type"]?.Value <string>(); LinkedServiceType linkedServiceType = typeValue.ToEnum <LinkedServiceType>(); try { LinkedService linkedService = null; switch (linkedServiceType) { case LinkedServiceType.AzureBatch: linkedService = jo.ToObject <AzureBatch>(); break; case LinkedServiceType.AzureDataLakeAnalytics: linkedService = jo.ToObject <AzureDataLakeAnalytics>(); break; case LinkedServiceType.AzureDataLakeStore: linkedService = jo.ToObject <AzureDataLakeStore>(); break; case LinkedServiceType.AzureSqlDatabase: linkedService = jo.ToObject <AzureSqlDatabase>(); break; case LinkedServiceType.AzureSqlDW: linkedService = jo.ToObject <AzureSqlDW>(); break; case LinkedServiceType.AzureStorage: linkedService = jo.ToObject <AzureStorage>(); break; case LinkedServiceType.AzureStorageSas: linkedService = jo.ToObject <AzureStorageSas>(); break; case LinkedServiceType.HDInsight: linkedService = jo.ToObject <HDInsight>(); break; case LinkedServiceType.HDInsightOnDemand: linkedService = jo.ToObject <HDInsightOnDemand>(); break; case LinkedServiceType.AzureCosmosDb: linkedService = jo.ToObject <AzureCosmosDb>(); break; case LinkedServiceType.AzureSearch: linkedService = jo.ToObject <AzureSearch>(); break; case LinkedServiceType.AzureML: linkedService = jo.ToObject <AzureMachineLearning>(); break; } return(AdfItemType.LinkedService, linkedService); } catch (JsonSerializationException ex) { Logger.Instance.Error($"LinkedService {typeValue}. \"{ex.Message}\" was handled"); throw new AdfParseException($"LinkedService {typeValue}", ex); } }