Beispiel #1
0
        private static bool PopulateMatchResults(DlpUtils.DataClassificationQueryContext queryContext, Dictionary <string, DataClassificationPresentationObject> queriedNameDictionary, IEnumerable <QueryMatchResult> nameMatchResultsFromCurrentRulePack, Dictionary <string, DataClassificationPresentationObject> queriedGuidDictionary, IEnumerable <QueryMatchResult> idMatchResultsFromCurrentRulePack, Dictionary <string, DataClassificationPresentationObject> allQueryResultsDictionary)
        {
            ClassificationRuleCollectionPresentationObject classificationRuleCollectionPresentationObject;

            if (!DlpUtils.CreateClassificationRuleCollectionPresentationObject(queryContext, out classificationRuleCollectionPresentationObject))
            {
                return(false);
            }
            List <Tuple <QueryMatchResult, DataClassificationPresentationObject> > list;

            if (!DlpUtils.CreateDataClassificationPresentationObjects(queryContext, classificationRuleCollectionPresentationObject, nameMatchResultsFromCurrentRulePack, out list))
            {
                return(false);
            }
            List <Tuple <QueryMatchResult, DataClassificationPresentationObject> > list2;

            if (!DlpUtils.CreateDataClassificationPresentationObjects(queryContext, classificationRuleCollectionPresentationObject, idMatchResultsFromCurrentRulePack, out list2))
            {
                return(false);
            }
            foreach (Tuple <QueryMatchResult, DataClassificationPresentationObject> tuple in list)
            {
                QueryMatchResult item = tuple.Item1;
                DataClassificationPresentationObject item2 = tuple.Item2;
                if (queriedNameDictionary[item.QueryString] != null)
                {
                    throw new ArgumentException(Strings.DataClassificationAmbiguousName(item.QueryString));
                }
                DlpUtils.EnsureResultsIntegrity(queryContext, item, allQueryResultsDictionary, classificationRuleCollectionPresentationObject);
                queriedNameDictionary[item.QueryString] = item2;
                allQueryResultsDictionary.Add(item.MatchingRuleId, item2);
            }
            foreach (Tuple <QueryMatchResult, DataClassificationPresentationObject> tuple2 in list2)
            {
                QueryMatchResult item3 = tuple2.Item1;
                DataClassificationPresentationObject item4 = tuple2.Item2;
                DataClassificationPresentationObject dataClassificationPresentationObject = queriedGuidDictionary[item3.QueryString];
                if (dataClassificationPresentationObject != null)
                {
                    queryContext.CurrentDiagnosticsReporter.WriteDuplicateRuleIdAcrossRulePacksDiagnosticsInformation(0, queryContext.CurrentOrganizationId, dataClassificationPresentationObject.ClassificationRuleCollection.DistinguishedName, queryContext.CurrentRuleCollectionTransportRuleObject.DistinguishedName, item3.MatchingRuleId);
                    throw new ArgumentException(Strings.DataClassificationAmbiguousIdentifier(item3.QueryString));
                }
                DlpUtils.EnsureResultsIntegrity(queryContext, item3, allQueryResultsDictionary, classificationRuleCollectionPresentationObject);
                queriedGuidDictionary[item3.QueryString] = item4;
                allQueryResultsDictionary.Add(item3.MatchingRuleId, item4);
            }
            return(true);
        }
Beispiel #2
0
        private static void EnsureResultsIntegrity(DlpUtils.DataClassificationQueryContext queryContext, QueryMatchResult queryMatchResult, Dictionary <string, DataClassificationPresentationObject> allQueryResultsDictionary, ClassificationRuleCollectionPresentationObject currentRulePackagePresentationObject)
        {
            DataClassificationPresentationObject dataClassificationPresentationObject;

            if (!allQueryResultsDictionary.TryGetValue(queryMatchResult.MatchingRuleId, out dataClassificationPresentationObject))
            {
                return;
            }
            if (ClassificationDefinitionConstants.RuleCollectionIdComparer.Equals(dataClassificationPresentationObject.ClassificationRuleCollection.Name, currentRulePackagePresentationObject.Name))
            {
                throw new ArgumentException(Strings.DataClassificationNonUniqueQuery(dataClassificationPresentationObject.LocalizedName, dataClassificationPresentationObject.Identity.ToString(), dataClassificationPresentationObject.ClassificationRuleCollection.Name));
            }
            queryContext.CurrentDiagnosticsReporter.WriteDuplicateRuleIdAcrossRulePacksDiagnosticsInformation(0, queryContext.CurrentOrganizationId, dataClassificationPresentationObject.ClassificationRuleCollection.DistinguishedName, queryContext.CurrentRuleCollectionTransportRuleObject.DistinguishedName, queryMatchResult.MatchingRuleId);
            throw new ArgumentException(Strings.DataClassificationAmbiguousIdentity(queryMatchResult.QueryString, currentRulePackagePresentationObject.Name, dataClassificationPresentationObject.LocalizedName, dataClassificationPresentationObject.Identity.ToString(), dataClassificationPresentationObject.ClassificationRuleCollection.Name));
        }