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

            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, userName, password);
            var gatewayEncryptionClient = new GatewayEncryptionClient();

            return(gatewayEncryptionClient.Encrypt(connectionString, gatewayEncryptionInfos));
        }
Beispiel #2
0
        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));
        }
        public virtual string IntegrationRuntimeEncryptCredential(
            string resourceGroupName,
            string dataFactoryName,
            string integrationRuntimeName,
            string linkedServiceJson)
        {
            var response = DataFactoryManagementClient.IntegrationRuntimes.GetConnectionInfo(resourceGroupName, dataFactoryName, integrationRuntimeName);
            var irVerStr = response.Version;
            var irVer    = new Version(irVerStr);

            //Private preview customers can use 2.x gateways for this feature, below code change gateway version of 2.x to 3.0  to pass version check by gateway.
            if (irVer.Major < GatewayMajorVersionWithIRSupport)
            {
                irVer    = new Version(GatewayMajorVersionWithIRSupport, 0);
                irVerStr = irVer.ToString();
            }
            var encryptionInfos = new[]
            {
                new GatewayEncryptionInfo
                {
                    HostServiceUri         = new Uri(response.HostServiceUri),
                    IdentityCertThumbprint = response.IdentityCertThumbprint,
                    PublicKey             = response.PublicKey,
                    ServiceToken          = response.ServiceToken,
                    InstanceVersionString = irVerStr
                }
            };

            return(GatewayEncryptionClient.Encrypt(linkedServiceJson, encryptionInfos));
        }
        public virtual string OnPremisesEncryptString(SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName, PSCredential credential)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            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, userName, password);
            var gatewayEncryptionClient = new GatewayEncryptionClient();
            return gatewayEncryptionClient.Encrypt(connectionString, gatewayEncryptionInfos);
        }
        public virtual string OnPremisesEncryptString(SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            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
                        }
                };

            var gatewayEncryptionClient = new GatewayEncryptionClient();
            return gatewayEncryptionClient.Encrypt(value, gatewayEncryptionInfos);
        }
        public virtual string OnPremisesEncryptString(SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            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
                }
            };

            var gatewayEncryptionClient = new GatewayEncryptionClient();

            return(gatewayEncryptionClient.Encrypt(value, gatewayEncryptionInfos));
        }