Exemple #1
0
        private static void ValidateIncludedPaths(IEnumerable <ClientEncryptionIncludedPath> clientEncryptionIncludedPath)
        {
            List <string> includedPathsList = new List <string>();

            foreach (ClientEncryptionIncludedPath path in clientEncryptionIncludedPath)
            {
                PSClientEncryptionPolicy.ValidateClientEncryptionIncludedPath(path);
                if (includedPathsList.Contains(path.Path))
                {
                    throw new ArgumentException($"Duplicate Path({path.Path}) found.", nameof(clientEncryptionIncludedPath));
                }

                includedPathsList.Add(path.Path);
            }
        }
        public PSSqlContainerGetPropertiesResource(SqlContainerGetPropertiesResource sqlContainerGetPropertiesResource)
        {
            if (sqlContainerGetPropertiesResource == null)
            {
                return;
            }

            Id                       = sqlContainerGetPropertiesResource.Id;
            IndexingPolicy           = new PSIndexingPolicy(sqlContainerGetPropertiesResource.IndexingPolicy);
            PartitionKey             = new PSContainerPartitionKey(sqlContainerGetPropertiesResource.PartitionKey);
            DefaultTtl               = sqlContainerGetPropertiesResource.DefaultTtl;
            UniqueKeyPolicy          = new PSUniqueKeyPolicy(sqlContainerGetPropertiesResource.UniqueKeyPolicy);
            ClientEncryptionPolicy   = new PSClientEncryptionPolicy(sqlContainerGetPropertiesResource.ClientEncryptionPolicy);
            ConflictResolutionPolicy = new PSConflictResolutionPolicy(sqlContainerGetPropertiesResource.ConflictResolutionPolicy);
            AnalyticalStorageTtl     = (int?)sqlContainerGetPropertiesResource.AnalyticalStorageTtl;
            _rid                     = sqlContainerGetPropertiesResource._rid;
            _ts                      = sqlContainerGetPropertiesResource._ts;
            _etag                    = sqlContainerGetPropertiesResource._etag;
        }
Exemple #3
0
        public PSClientEncryptionPolicy(ClientEncryptionPolicy clientEncryptionPolicy)
        {
            if (clientEncryptionPolicy == null)
            {
                return;
            }

            if (ModelHelper.IsNotNullOrEmpty(clientEncryptionPolicy.IncludedPaths))
            {
                PSClientEncryptionPolicy.ValidateIncludedPaths(clientEncryptionPolicy.IncludedPaths);

                IncludedPaths = new List <PSClientEncryptionIncludedPath>();
                foreach (ClientEncryptionIncludedPath key in clientEncryptionPolicy.IncludedPaths)
                {
                    IncludedPaths.Add(new PSClientEncryptionIncludedPath(key));
                }
            }

            this.PolicyFormatVersion = (int)clientEncryptionPolicy.PolicyFormatVersion;
        }
Exemple #4
0
        public static ClientEncryptionPolicy ToSDKModel(PSClientEncryptionPolicy pSClientEncryptionPolicy, List <string> partitionKeyPathTokens)
        {
            if (pSClientEncryptionPolicy == null)
            {
                return(null);
            }

            ClientEncryptionPolicy clientEncryptionPolicy = new ClientEncryptionPolicy
            {
                IncludedPaths       = new List <ClientEncryptionIncludedPath>(),
                PolicyFormatVersion = pSClientEncryptionPolicy.PolicyFormatVersion
            };

            if (ModelHelper.IsNotNullOrEmpty(pSClientEncryptionPolicy.IncludedPaths))
            {
                foreach (PSClientEncryptionIncludedPath includedPath in pSClientEncryptionPolicy.IncludedPaths)
                {
                    ClientEncryptionIncludedPath clientEncryptionIncludedPath = new ClientEncryptionIncludedPath
                    {
                        Path = includedPath.Path,
                        ClientEncryptionKeyId = includedPath.ClientEncryptionKeyId,
                        EncryptionAlgorithm   = includedPath.EncryptionAlgorithm,
                        EncryptionType        = includedPath.EncryptionType
                    };

                    clientEncryptionPolicy.IncludedPaths.Add(clientEncryptionIncludedPath);
                }
            }

            PSClientEncryptionPolicy.ValidatePartitionKeyPathsAreNotEncrypted(clientEncryptionPolicy.IncludedPaths, partitionKeyPathTokens);

            if (clientEncryptionPolicy.PolicyFormatVersion != 1)
            {
                throw new InvalidOperationException($"Invalid PolicyFormatVersion:{clientEncryptionPolicy.PolicyFormatVersion} used in Client Encryption Policy. ");
            }

            return(clientEncryptionPolicy);
        }