예제 #1
0
        /// <summary>
        /// To Validate the Integrity of Catalog
        /// </summary>
        /// <param name="catalogFolders">Folder for which catalog is created.</param>
        /// <param name="catalogFilePath">File Name of the Catalog.</param>
        /// <param name="excludedPatterns"></param>
        /// <param name="cmdlet">Instance of cmdlet calling this method.</param>
        /// <returns>Information about Catalog.</returns>
        internal static CatalogInformation ValidateCatalog(PSCmdlet cmdlet, Collection <string> catalogFolders, string catalogFilePath, WildcardPattern[] excludedPatterns)
        {
            _cmdlet = cmdlet;
            int catalogVersion = 0;
            Dictionary <string, string> catalogHashes = GetHashesFromCatalog(catalogFilePath, excludedPatterns, out catalogVersion);
            string hashAlgorithm = GetCatalogHashAlgorithm(catalogVersion);

            if (!string.IsNullOrEmpty(hashAlgorithm))
            {
                Dictionary <string, string> fileHashes = CalculateHashesFromPath(catalogFolders, catalogFilePath, hashAlgorithm, excludedPatterns);
                CatalogInformation          catalog    = new CatalogInformation();
                catalog.CatalogItems = catalogHashes;
                catalog.PathItems    = fileHashes;
                bool status = CompareDictionaries(catalogHashes, fileHashes);
                if (status == true)
                {
                    catalog.Status = CatalogValidationStatus.Valid;
                }
                else
                {
                    catalog.Status = CatalogValidationStatus.ValidationFailed;
                }

                catalog.HashAlgorithm = hashAlgorithm;
                catalog.Signature     = SignatureHelper.GetSignature(catalogFilePath, null);
                return(catalog);
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// To Validate the Integrity of Catalog 
        /// </summary>
        ///              
        /// <param name="catalogFolders"> Folder for which catalog is created </param>
        /// <param name="catalogFilePath"> File Name of the Catalog </param>
        /// <param name="excludedPatterns"></param>
        /// <param name="cmdlet"> Instance of cmdlet calling this method  </param>
        /// <returns> Information about Catalog </returns>
        internal static CatalogInformation ValidateCatalog(PSCmdlet cmdlet, Collection<string> catalogFolders, String catalogFilePath, WildcardPattern[] excludedPatterns)
        {
            _cmdlet = cmdlet;
            int catalogVersion = 0;
            Dictionary<String, String> catalogHashes = GetHashesFromCatalog(catalogFilePath, excludedPatterns, out catalogVersion);
            string hashAlgorithm = GetCatalogHashAlgorithm(catalogVersion);

            if (!String.IsNullOrEmpty(hashAlgorithm))
            {
                Dictionary<String, String> fileHashes = CalculateHashesFromPath(catalogFolders, catalogFilePath, hashAlgorithm, excludedPatterns);
                CatalogInformation catalog = new CatalogInformation();
                catalog.CatalogItems = catalogHashes;
                catalog.PathItems = fileHashes;
                bool status = CompareDictionaries(catalogHashes, fileHashes);
                if (status == true)
                {
                    catalog.Status = CatalogValidationStatus.Valid;
                }
                else
                {
                    catalog.Status = CatalogValidationStatus.ValidationFailed;
                }
                catalog.HashAlgorithm = hashAlgorithm;
                catalog.Signature = SignatureHelper.GetSignature(catalogFilePath, null);
                return catalog;
            }
            return null;
        }