internal static XDocument CreateRuleCollectionDocumentFromTemplate(string rulePackId, string organizationId, string organizationName)
        {
            ArgumentValidator.ThrowIfNullOrEmpty("rulePackId", rulePackId);
            ArgumentValidator.ThrowIfNullOrEmpty("organizationId", organizationId);
            ArgumentValidator.ThrowIfNullOrEmpty("organizationName", organizationName);
            string text = string.Empty;

            using (Stream stream = ClassificationDefinitionUtils.LoadStreamFromEmbeddedResource("FingerprintRulePackTemplate.xml"))
            {
                using (StreamReader streamReader = new StreamReader(stream))
                {
                    text = streamReader.ReadToEnd();
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                throw new FingerprintRulePackTemplateCorruptedException("FingerprintRulePackTemplate.xml");
            }
            XDocument xdocument = XDocument.Parse(text);
            XElement  xelement  = xdocument.Root.Element(XmlProcessingUtils.GetMceNsQualifiedNodeName("RulePack"));

            xelement.SetAttributeValue("id", rulePackId);
            XElement xelement2 = xelement.Element(XmlProcessingUtils.GetMceNsQualifiedNodeName("Publisher"));

            xelement2.SetAttributeValue("id", organizationId);
            foreach (XElement xelement3 in xelement.Descendants(XmlProcessingUtils.GetMceNsQualifiedNodeName("PublisherName")))
            {
                xelement3.SetValue(organizationName);
            }
            XmlProcessingUtils.SetRulePackVersionFromAssemblyFileVersion(xdocument);
            return(xdocument);
        }
Ejemplo n.º 2
0
        private static XmlSchema LoadSchemaFromEmbeddedResource(string schemaName)
        {
            XmlSchema result;

            using (Stream stream = ClassificationDefinitionUtils.LoadStreamFromEmbeddedResource(schemaName))
            {
                result = XmlSchema.Read(stream, null);
            }
            return(result);
        }
        private static string ReadRegexTestTemplate()
        {
            string result;

            using (Stream stream = ClassificationDefinitionUtils.LoadStreamFromEmbeddedResource("RegexTestTemplate.xml"))
            {
                StreamReader streamReader = new StreamReader(stream);
                result = streamReader.ReadToEnd();
            }
            return(result);
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            if (this.InstallDefaultCollection)
            {
                using (Stream stream = ClassificationDefinitionUtils.LoadStreamFromEmbeddedResource("DefaultClassificationDefinitions.xml"))
                {
                    byte[] array = new byte[stream.Length];
                    stream.Read(array, 0, Convert.ToInt32(stream.Length));
                    this.FileData = array;
                    goto IL_71;
                }
            }
            if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                this.ValidateOperationScope();
            }
IL_71:
            byte[] rulePackageRawData = null;
            byte[] array2             = null;
            try
            {
                this.isEncrypted = RulePackageDecrypter.DecryptRulePackage(this.FileData, out rulePackageRawData, out array2);
            }
            catch (Exception innerException)
            {
                base.WriteError(new ClassificationRuleCollectionDecryptionException(innerException), ErrorCategory.InvalidData, null);
            }
            if (this.isEncrypted)
            {
                ExAssert.RetailAssert(!this.InstallDefaultCollection, "Installation of encrypted default OOB rule pack is not supported due to versioning!");
                string text = this.ValidateAndReadMetadata(rulePackageRawData);
                this.FileData = ((text == null) ? null : array2);
            }
            else
            {
                string text2 = this.ValidateAndReadMetadata(this.FileData);
                this.FileData = ((text2 == null) ? null : Encoding.Unicode.GetBytes(text2));
            }
            if (this.FileData != null)
            {
                base.InternalValidate();
            }
            TaskLogger.LogExit();
        }
Ejemplo n.º 5
0
 protected override Stream OpenSourceStream()
 {
     return(ClassificationDefinitionUtils.LoadStreamFromEmbeddedResource("MceConfig.xml"));
 }