Esempio n. 1
0
 internal BatchSignUtil(ISignTool signTool, BatchSignInput batchData, string orchestrationManifestPath)
 {
     _signTool  = signTool;
     _batchData = batchData;
     _orchestrationManifestPath = orchestrationManifestPath;
     // TODO: Better path; for now making sure the relative paths are all in the same "OutputDirectory" value should help things work.
     _unpackingDirectory = Path.Combine(batchData.OutputPath, "ZipArchiveUnpackingDirectory");
 }
Esempio n. 2
0
        internal static bool TryReadOrchestrationConfigFile(TextWriter output, TextReader configReader, string outputPath, out BatchSignInput batchData)
        {
            var serializer = new JsonSerializer();
            var fileJson   = (Json.OrchestratedFileJson)serializer.Deserialize(configReader, typeof(Json.OrchestratedFileJson));
            var map        = new Dictionary <FileSignDataEntry, SignInfo>();
            // For now, a given json file will be assumed to serialize to one place and we'll throw otherwise
            string publishUrl = (from OrchestratedFileSignData entry in fileJson.SignList
                                 from FileSignDataEntry fileToSign in entry.FileList
                                 select fileToSign.PublishToFeedUrl).Distinct().Single();
            var allGood = true;

            foreach (var item in fileJson.SignList)
            {
                var data = new SignInfo(certificate: item.Certificate, strongName: item.StrongName);

                foreach (FileSignDataEntry entry in item.FileList)
                {
                    if (map.ContainsKey(entry))
                    {
                        Console.WriteLine($"signtool : error : Duplicate signing info entry for: {entry.FilePath}");
                        allGood = false;
                    }
                    else
                    {
                        map.Add(entry, data);
                    }
                }
            }

            if (!allGood)
            {
                batchData = null;
                return(false);
            }

            batchData = new BatchSignInput(outputPath, map, fileJson.ExcludeList ?? Array.Empty <string>(), publishUrl);
            return(true);
        }
Esempio n. 3
0
        private bool GenerateOrchestrationManifest(TextWriter textWriter, BatchSignInput batchData, ContentMap contentMap, string outputPath)
        {
            textWriter.WriteLine($"Generating orchestration file manifest into {outputPath}");
            OrchestratedFileJson fileJsonWithInfo = new OrchestratedFileJson
            {
                ExcludeList = _batchData.ExternalFileNames.ToArray() ?? Array.Empty <string>()
            };

            var distinctSigningCombos = batchData.FileSignInfoMap.Values.GroupBy(v => new { v.Certificate, v.StrongName });

            List <OrchestratedFileSignData> newList = new List <OrchestratedFileSignData>();

            foreach (var combinationToSign in distinctSigningCombos)
            {
                var filesInThisGroup = combinationToSign.Select(c => new FileSignDataEntry()
                {
                    FilePath         = c.FileName.RelativePath,
                    SHA256Hash       = contentMap.GetChecksum(c.FileName),
                    PublishToFeedUrl = batchData.PublishUri
                });
                newList.Add(new OrchestratedFileSignData()
                {
                    Certificate = combinationToSign.Key.Certificate,
                    StrongName  = combinationToSign.Key.StrongName,
                    FileList    = filesInThisGroup.ToArray()
                });
            }
            fileJsonWithInfo.SignList = newList.ToArray();
            fileJsonWithInfo.Kind     = "orchestration";

            using (StreamWriter file = File.CreateText(outputPath))
            {
                file.Write(JsonConvert.SerializeObject(fileJsonWithInfo, Formatting.Indented));
            }

            return(true);
        }
Esempio n. 4
0
        internal static bool TryReadConfigFile(TextWriter output, TextReader configReader, string outputPath, out BatchSignInput batchData)
        {
            var serializer = new JsonSerializer();
            var fileJson   = (Json.FileJson)serializer.Deserialize(configReader, typeof(Json.FileJson));
            var map        = new Dictionary <string, SignInfo>(StringComparer.OrdinalIgnoreCase);
            var allGood    = true;

            foreach (var item in fileJson.SignList)
            {
                var data = new SignInfo(certificate: item.Certificate, strongName: item.StrongName);
                foreach (var relativeFileName in ExpandFileList(outputPath, item.FileList, ref allGood))
                {
                    if (map.ContainsKey(relativeFileName))
                    {
                        Console.WriteLine($"signtool : error : Duplicate file entry: {relativeFileName}");
                        allGood = false;
                    }
                    else
                    {
                        map.Add(relativeFileName, data);
                    }
                }
            }

            if (!allGood)
            {
                batchData = null;
                return(false);
            }

            batchData = new BatchSignInput(outputPath, map, fileJson.ExcludeList ?? Array.Empty <string>(), fileJson.PublishUrl ?? "unset");
            return(true);
        }
Esempio n. 5
0
        internal static bool TryReadConfigFile(TextWriter output, TextReader configReader, string outputPath, out BatchSignInput batchData)
        {
            var serializer = new JsonSerializer();
            var fileJson   = (Json.FileJson)serializer.Deserialize(configReader, typeof(Json.FileJson));
            var map        = new Dictionary <string, SignInfo>();
            var allGood    = true;

            foreach (var item in fileJson.SignList)
            {
                var data = new SignInfo(certificate: item.Certificate, strongName: item.StrongName);
                foreach (var name in item.FileList)
                {
                    if (map.ContainsKey(name))
                    {
                        Console.WriteLine($"Duplicate file entry: {name}");
                        allGood = false;
                    }
                    else
                    {
                        map.Add(name, data);
                    }
                }
            }

            if (!allGood)
            {
                batchData = null;
                return(false);
            }

            batchData = new BatchSignInput(outputPath, map, fileJson.ExcludeList ?? Array.Empty <string>());
            return(true);
        }
Esempio n. 6
0
 internal BatchSignUtil(ISignTool signTool, BatchSignInput batchData)
 {
     _signTool  = signTool;
     _batchData = batchData;
 }