private void LoadReferencedProduct() { ClearCanvasManifest input = ClearCanvasManifest.Deserialize(_cmdLine.ProductManifest); _manifest.PackageManifest.Package.Product.Name = input.ProductManifest.Product.Name; _manifest.PackageManifest.Package.Product.Suffix = input.ProductManifest.Product.Suffix; _manifest.PackageManifest.Package.Product.Version = input.ProductManifest.Product.Version; _manifest.PackageManifest.Package.Product.Component = input.ProductManifest.Product.Component; _manifest.PackageManifest.Package.Product.Edition = input.ProductManifest.Product.Edition; }
private void LoadManifestFiles(out Exception delayedException) { List <string> files = new List <string>(); FileProcessor.Process(Platform.ManifestDirectory, null, delegate(string filePath, out bool cancel) { files.Add(filePath); cancel = false; }, true); List <ClearCanvasManifest> manifests = new List <ClearCanvasManifest>(); bool foundManifest = false; delayedException = null; foreach (string file in files) { try { XmlDocument doc = new XmlDocument(); // must open stream manually in case file is read-only using (var fileStream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { doc.Load(fileStream); } XmlElement modulusNode = (XmlElement)CollectionUtils.FirstElement(doc.GetElementsByTagName("Modulus")); XmlElement exponentNode = (XmlElement)CollectionUtils.FirstElement(doc.GetElementsByTagName("Exponent")); // delay these exceptions until after verifying contents of manifest, in order to make manifests easier to debug if (!modulusNode.InnerText.Equals("gRuWfDdo9ZCQ9G4hIt6amEgr1DBPDltP0NoBQI/GpooT6hGh6UkFRpaYQMt4ijxbHI5UDGZvAU66Vjt+FUcRVJ4I8AAuhyI4mU2BIzsfpUsKjxJMNdh3fxjaAOjMc4s5pX0CUvCJuZEhY/+PY/aYnjX2a6wes3nGHTx/YJhh42M=")) { delayedException = new ApplicationException("Invalid public key in digital signature."); } else if (!exponentNode.InnerText.Equals("AQAB")) { delayedException = new ApplicationException("Invalid public key in digital signature."); } if (!ManifestSignature.VerifyXmlSignature(doc)) { throw new ApplicationException("Manifest digital signature failed verification."); } ClearCanvasManifest manifest = ClearCanvasManifest.Deserialize(file); if (manifest.ProductManifest != null) { if (string.IsNullOrEmpty(manifest.ProductManifest.Product.Version)) { // The ClearCanvas.Common.ProductInformation class uses the // clearcanvas.common.dll version if a version is not contained in // the ProductSettings. foreach (ManifestFile manFile in manifest.ProductManifest.Files) { if (manFile.Filename.ToLower().Equals("common\\clearcanvas.common.dll")) { manifest.ProductManifest.Product.Version = manFile.Version; } } } foundManifest = true; if (!manifest.ProductManifest.Product.Manifest.Equals("Manifest.xml")) { throw new ApplicationException("Product manifest not named Manifest.xml"); } _productManifest = manifest; if (!manifest.ProductManifest.Product.Manifest.Equals(Path.GetFileName(file))) { throw new ApplicationException("Manifest name does not match manifest: " + Path.GetFileName(file)); } } else if (manifest.PackageManifest != null) { if (!manifest.PackageManifest.Package.Manifest.Equals(Path.GetFileName(file))) { throw new ApplicationException("Package Manifest name does not match manifest: " + Path.GetFileName(file)); } } manifests.Add(manifest); } catch (Exception e) { throw new ApplicationException("Unexpected problem parsing manifest: " + e.Message + " (" + Path.GetFileName(file) + ")"); } } if (!foundManifest) { throw new ApplicationException("Unable to find Manifest.xml"); } _manifests = manifests.ToArray(); }