public TransportRule Initialize(IConfigDataProvider dataSession, DataClassificationIdParameter identity, OptionalIdentityData optionalData)
        {
            ArgumentValidator.ThrowIfNull("dataSession", dataSession);
            ArgumentValidator.ThrowIfNull("identity", identity);
            identity.ShouldIncludeOutOfBoxCollections = false;
            this.task.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(identity, dataSession, typeof(TransportRule), null));
            IEnumerable <TransportRule> enumerable = null;

            try
            {
                LocalizedString?localizedString;
                enumerable = identity.GetObjects <TransportRule>(null, dataSession, optionalData, out localizedString);
            }
            finally
            {
                this.task.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(dataSession));
            }
            string[] array = new string[]
            {
                identity.DataClassificationIdentity
            };
            List <QueryMatchResult> list = new List <QueryMatchResult>();

            foreach (TransportRule transportRule in enumerable)
            {
                XDocument rulePackXDoc;
                if (this.TryParseADRulePack(transportRule, out rulePackXDoc) && XmlProcessingUtils.IsFingerprintRuleCollection(rulePackXDoc))
                {
                    List <QueryMatchResult> list2 = XmlProcessingUtils.GetMatchingRulesById(rulePackXDoc, array).ToList <QueryMatchResult>();
                    if (list2.Count == 0)
                    {
                        list2 = XmlProcessingUtils.GetMatchingRulesByName(rulePackXDoc, array, NameMatchingOptions.InvariantNameOrLocalizedNameMatch, true).ToList <QueryMatchResult>();
                    }
                    list.AddRange(list2);
                    if (list.Count == 1)
                    {
                        this.adRulePack           = transportRule;
                        this.ruleXElement         = list[0].MatchingRuleXElement;
                        this.ruleResourceXElement = list[0].MatchingResourceXElement;
                        this.rulePackXDocument    = this.ruleXElement.Document;
                        ClassificationRuleCollectionPresentationObject rulePackPresentationObject = ClassificationRuleCollectionPresentationObject.Create(this.adRulePack, this.rulePackXDocument);
                        this.DataClassificationPresentationObject = DataClassificationPresentationObject.Create(list[0].MatchingRuleId, list[0].MatchingRuleXElement, list[0].MatchingResourceXElement, rulePackPresentationObject);
                    }
                    else if (list.Count > 1)
                    {
                        break;
                    }
                }
            }
            if (list.Count <= 0)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorCannotFindFingerprintDataClassification(identity.ToString()));
            }
            if (list.Count > 1)
            {
                throw new ManagementObjectAmbiguousException(Strings.ErrorManagementObjectAmbiguous(identity.ToString()));
            }
            return(this.adRulePack);
        }
Ejemplo n.º 2
0
        protected virtual void Initialize(XDocument rulePackXDoc)
        {
            Version  rulePackVersion            = XmlProcessingUtils.GetRulePackVersion(rulePackXDoc);
            XElement rulePackageMetadataElement = XmlProcessingUtils.GetRulePackageMetadataElement(rulePackXDoc);
            bool     isEncrypted = RulePackageDecrypter.IsRulePackageEncrypted(rulePackXDoc);

            this.Initialize(rulePackVersion, rulePackageMetadataElement, isEncrypted, XmlProcessingUtils.IsFingerprintRuleCollection(rulePackXDoc));
        }
Ejemplo n.º 3
0
        internal static ClassificationRuleCollectionPresentationObject Create(TransportRule transportRule, Version rulePackageVersion, XElement rulePackageDetailsElement, bool isEncrypted)
        {
            if (transportRule == null)
            {
                throw new ArgumentNullException("transportRule");
            }
            if (null == rulePackageVersion)
            {
                throw new ArgumentNullException("rulePackageVersion");
            }
            ClassificationRuleCollectionPresentationObject classificationRuleCollectionPresentationObject = new ClassificationRuleCollectionPresentationObject(transportRule);

            classificationRuleCollectionPresentationObject.Initialize(rulePackageVersion, rulePackageDetailsElement, isEncrypted, XmlProcessingUtils.IsFingerprintRuleCollection(rulePackageDetailsElement.Document));
            return(classificationRuleCollectionPresentationObject);
        }