protected override void WriteResult(IConfigurable dataObject)
        {
            TaskLogger.LogEnter();
            TransportRule transportRule = dataObject as TransportRule;

            if (transportRule != null)
            {
                XDocument ruleCollectionDocumentFromTransportRule = ClassificationDefinitionUtils.GetRuleCollectionDocumentFromTransportRule(transportRule);
                if (ruleCollectionDocumentFromTransportRule != null)
                {
                    string[] ruleIdQueries = new string[]
                    {
                        ((DataClassificationObjectId)this.implementation.DataClassificationPresentationObject.Identity).Name
                    };
                    List <QueryMatchResult> list = XmlProcessingUtils.GetMatchingRulesById(ruleCollectionDocumentFromTransportRule, ruleIdQueries).ToList <QueryMatchResult>();
                    if (list.Count > 0)
                    {
                        ClassificationRuleCollectionPresentationObject rulePackPresentationObject = ClassificationRuleCollectionPresentationObject.Create(transportRule);
                        DataClassificationPresentationObject           result = DataClassificationPresentationObject.Create(list[0].MatchingRuleId, list[0].MatchingRuleXElement, list[0].MatchingResourceXElement, rulePackPresentationObject);
                        this.WriteResult(result);
                    }
                }
            }
            else
            {
                base.WriteResult(dataObject);
            }
            TaskLogger.LogExit();
        }
        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);
        }
示例#3
0
        private static List <DataClassificationPresentationObject> CreateDataClassificationPresentationObjects(TransportRule transportRuleObject, XDocument rulePackXDoc)
        {
            ClassificationRuleCollectionPresentationObject rulePackPresentationObject = ClassificationRuleCollectionPresentationObject.Create(transportRuleObject, rulePackXDoc);
            IEnumerable <QueryMatchResult> matchingRulesById = XmlProcessingUtils.GetMatchingRulesById(rulePackXDoc, null);

            return((from rawDataClassificationResult in matchingRulesById
                    select DataClassificationPresentationObject.Create(rawDataClassificationResult.MatchingRuleId, rawDataClassificationResult.MatchingRuleXElement, rawDataClassificationResult.MatchingResourceXElement, rulePackPresentationObject)).ToList <DataClassificationPresentationObject>());
        }
示例#4
0
        internal static ClassificationRuleCollectionPresentationObject Create(TransportRule transportRule)
        {
            if (transportRule == null)
            {
                throw new ArgumentNullException("transportRule");
            }
            ClassificationRuleCollectionPresentationObject classificationRuleCollectionPresentationObject = new ClassificationRuleCollectionPresentationObject(transportRule);

            classificationRuleCollectionPresentationObject.Initialize();
            return(classificationRuleCollectionPresentationObject);
        }
        public TransportRule Initialize(TransportRule adRulePack, XDocument rulePackXDoc)
        {
            ArgumentValidator.ThrowIfNull("adRulepack", adRulePack);
            ArgumentValidator.ThrowIfNull("rulePackXDoc", rulePackXDoc);
            this.adRulePack        = adRulePack;
            this.rulePackXDocument = rulePackXDoc;
            ClassificationRuleCollectionPresentationObject rulePackPresentationObject = ClassificationRuleCollectionPresentationObject.Create(this.adRulePack, this.rulePackXDocument);

            this.DataClassificationPresentationObject = DataClassificationPresentationObject.Create(rulePackPresentationObject);
            return(this.adRulePack);
        }
        protected override void WriteResult(IConfigurable result)
        {
            TaskLogger.LogEnter(new object[]
            {
                result.Identity
            });
            IConfigurable result2 = ClassificationRuleCollectionPresentationObject.Create((TransportRule)result, this.rulePackVersion, this.rulePackageDetailsElement, this.isEncrypted);

            base.WriteResult(result2);
            TaskLogger.LogExit();
        }
示例#7
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);
        }
示例#8
0
 internal static DataClassificationPresentationObject Create(ClassificationRuleCollectionPresentationObject rulePackPresentationObject)
 {
     return(new DataClassificationPresentationObject
     {
         defaultDetails = new DataClassificationLocalizableDetails(),
         localizedNames = new Dictionary <CultureInfo, string>(),
         localizedDescriptions = new Dictionary <CultureInfo, string>(),
         ClassificationRuleCollection = rulePackPresentationObject,
         Identity = DataClassificationPresentationObject.CreateDataClassificationIdentifier(Guid.NewGuid().ToString(), rulePackPresentationObject),
         ClassificationType = (rulePackPresentationObject.IsFingerprintRuleCollection ? ClassificationTypeEnum.Fingerprint : ClassificationTypeEnum.Affinity),
         RecommendedConfidence = new uint?(75U),
         MinEngineVersion = ClassificationDefinitionConstants.TextProcessorTypeToVersions[TextProcessorType.Fingerprint],
         IsDirty = true
     });
 }
示例#9
0
        internal static DataClassificationPresentationObject Create(string ruleIdentifier, DataClassificationLocalizableDetails defaultRuleDetails, XElement ruleElement, XElement resourceElement, ClassificationRuleCollectionPresentationObject rulePackPresentationObject)
        {
            ArgumentValidator.ThrowIfNullOrEmpty("ruleIdentifier", ruleIdentifier);
            ArgumentValidator.ThrowIfNull("defaultRuleDetails", defaultRuleDetails);
            ArgumentValidator.ThrowIfNull("ruleElement", ruleElement);
            ArgumentValidator.ThrowIfNull("resourceElement", resourceElement);
            ArgumentValidator.ThrowIfNull("rulePackPresentationObject", rulePackPresentationObject);
            MultiValuedProperty <Fingerprint> multiValuedProperty = null;

            if (rulePackPresentationObject.IsFingerprintRuleCollection && ruleElement.Document != null)
            {
                multiValuedProperty = XmlProcessingUtils.ReadAllReferredFingerprints(ruleElement);
            }
            return(new DataClassificationPresentationObject
            {
                defaultDetails = defaultRuleDetails,
                localizedNames = XmlProcessingUtils.ReadAllRuleNames(resourceElement),
                localizedDescriptions = XmlProcessingUtils.ReadAllRuleDescriptions(resourceElement),
                fingerprints = multiValuedProperty,
                Identity = DataClassificationPresentationObject.CreateDataClassificationIdentifier(ruleIdentifier, rulePackPresentationObject),
                ClassificationType = (rulePackPresentationObject.IsFingerprintRuleCollection ? ClassificationTypeEnum.Fingerprint : DataClassificationPresentationObject.Parse(ruleElement.Name.LocalName)),
                ClassificationRuleCollection = rulePackPresentationObject,
                RecommendedConfidence = XmlProcessingUtils.ReadRuleRecommendedConfidence(ruleElement),
                MinEngineVersion = XmlProcessingUtils.GetRulePackElementVersion(ruleElement)
            });
        }
示例#10
0
 internal static DataClassificationPresentationObject Create(string ruleIdentifier, XElement ruleElement, XElement resourceElement, ClassificationRuleCollectionPresentationObject rulePackPresentationObject)
 {
     ArgumentValidator.ThrowIfNullOrEmpty("ruleIdentifier", ruleIdentifier);
     ArgumentValidator.ThrowIfNull("ruleElement", ruleElement);
     ArgumentValidator.ThrowIfNull("resourceElement", resourceElement);
     return(DataClassificationPresentationObject.Create(ruleIdentifier, XmlProcessingUtils.ReadDefaultRuleMetadata(resourceElement), ruleElement, resourceElement, rulePackPresentationObject));
 }
示例#11
0
 private static DataClassificationObjectId CreateDataClassificationIdentifier(string ruleIdentifier, ClassificationRuleCollectionPresentationObject rulePackPresentationObject)
 {
     if (rulePackPresentationObject != null && rulePackPresentationObject.Identity != null)
     {
         string text = rulePackPresentationObject.Identity.ToString();
         int    num  = text.LastIndexOf(ClassificationDefinitionConstants.HierarchicalIdentitySeparatorChar);
         if (num != -1)
         {
             string organizationHierarchy = text.Substring(0, num);
             return(new DataClassificationObjectId(organizationHierarchy, ruleIdentifier));
         }
     }
     return(new DataClassificationObjectId(ruleIdentifier));
 }
示例#12
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));
        }
示例#13
0
        private static bool CreateDataClassificationPresentationObjects(DlpUtils.DataClassificationQueryContext queryContext, ClassificationRuleCollectionPresentationObject ruleCollectionPresentationObject, IEnumerable <QueryMatchResult> queryMatchResults, out List <Tuple <QueryMatchResult, DataClassificationPresentationObject> > presentationObjects)
        {
            presentationObjects = null;
            List <Tuple <QueryMatchResult, DataClassificationPresentationObject> > list = new List <Tuple <QueryMatchResult, DataClassificationPresentationObject> >();

            foreach (QueryMatchResult queryMatchResult in queryMatchResults)
            {
                DataClassificationPresentationObject item;
                if (!DlpUtils.CreateDataClassificationPresentationObject(queryContext, queryMatchResult.MatchingRuleId, queryMatchResult.MatchingRuleXElement, queryMatchResult.MatchingResourceXElement, ruleCollectionPresentationObject, out item))
                {
                    return(false);
                }
                list.Add(new Tuple <QueryMatchResult, DataClassificationPresentationObject>(queryMatchResult, item));
            }
            presentationObjects = list;
            return(true);
        }
示例#14
0
 private static bool CreateDataClassificationPresentationObject(DlpUtils.DataClassificationQueryContext operationContext, string ruleIdentifier, XElement ruleElement, XElement resourceElement, ClassificationRuleCollectionPresentationObject ruleCollectionPresentationObject, out DataClassificationPresentationObject dataClassificationPresentationObject)
 {
     return(DlpUtils.TryExecuteOperation <XmlException, object, object, DataClassificationPresentationObject>(operationContext, (object unusedStub1, object unusedStub2) => DataClassificationPresentationObject.Create(ruleIdentifier, ruleElement, resourceElement, ruleCollectionPresentationObject), null, null, out dataClassificationPresentationObject));
 }
示例#15
0
 private static bool CreateClassificationRuleCollectionPresentationObject(DlpUtils.DataClassificationQueryContext operationContext, out ClassificationRuleCollectionPresentationObject presentationObject)
 {
     return(DlpUtils.TryExecuteOperation <XmlException, TransportRule, XDocument, ClassificationRuleCollectionPresentationObject>(operationContext, new Func <TransportRule, XDocument, ClassificationRuleCollectionPresentationObject>(ClassificationRuleCollectionPresentationObject.Create), operationContext.CurrentRuleCollectionTransportRuleObject, operationContext.CurrentRuleCollectionXDoc, out presentationObject));
 }