internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!(predicateCondition.Property is HeaderProperty)) { return(null); } HeaderContainsPredicate headerContainsPredicate = (HeaderContainsPredicate)SinglePropertyContainsPredicate.CreateFromInternalCondition <HeaderContainsPredicate>(condition, predicateCondition.Property.Name); if (headerContainsPredicate == null) { return(null); } try { headerContainsPredicate.MessageHeader = new HeaderName(predicateCondition.Property.Name); } catch (ArgumentOutOfRangeException) { return(null); } return(headerContainsPredicate); }
private Microsoft.Exchange.MessagingPolicies.Rules.Condition CreateRecipientCondition() { if (this.recipient == null) { return(null); } Property property = JournalingRuleParser.Instance.CreateProperty("Message.Sender"); ShortList <string> shortList = new ShortList <string>(); shortList.Add(this.recipient.ToString()); PredicateCondition predicateCondition = JournalingRuleParser.Instance.CreatePredicate("isMemberOf", property, shortList); PredicateCondition predicateCondition2 = JournalingRuleParser.Instance.CreatePredicate("isSameUser", property, shortList); Microsoft.Exchange.MessagingPolicies.Rules.Condition condition = this.CombineUsingOr(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { predicateCondition, predicateCondition2 }); Property property2 = JournalingRuleParser.Instance.CreateProperty("Message.EnvelopeRecipients"); PredicateCondition predicateCondition3 = JournalingRuleParser.Instance.CreatePredicate("isMemberOf", property2, shortList); PredicateCondition predicateCondition4 = JournalingRuleParser.Instance.CreatePredicate("isSameUser", property2, shortList); Microsoft.Exchange.MessagingPolicies.Rules.Condition condition2 = this.CombineUsingOr(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { predicateCondition3, predicateCondition4 }); return(this.CombineUsingOr(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { condition, condition2 })); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Name.Equals("isMessageType")) { return(null); } MessageType messageType; try { messageType = (MessageType)Enum.Parse(typeof(MessageType), predicateCondition.Value.RawValues[0]); } catch (ArgumentException) { return(null); } return(new MessageTypeMatchesPredicate { MessageType = messageType }); }
internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string propertyName) where T : SizeOverPredicate, new() { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("greaterThanOrEqual") || !predicateCondition.Property.Name.Equals(propertyName) || predicateCondition.Value.RawValues.Count != 1) { return(null); } ulong num; if (!ulong.TryParse(predicateCondition.Value.RawValues[0], out num)) { return(null); } T t = Activator.CreateInstance <T>(); if (num == 0UL) { t.Size = ByteQuantifiedSize.FromKB(0UL); } else { t.Size = ByteQuantifiedSize.FromBytes(num); } return(t); }
internal static PsComplianceRulePredicateBase FromEnginePredicate(PredicateCondition predicate) { if (predicate is GreaterThanOrEqualPredicate && predicate.Property.Name.Equals("Item.WhenCreated")) { return(PsContentDateFromPredicate.FromEnginePredicate(predicate as GreaterThanOrEqualPredicate)); } if (predicate is LessThanOrEqualPredicate && predicate.Property.Name.Equals("Item.WhenCreated")) { return(PsContentDateToPredicate.FromEnginePredicate(predicate as LessThanOrEqualPredicate)); } if (predicate is TextQueryPredicate) { return(PsContentMatchQueryPredicate.FromEnginePredicate(predicate as TextQueryPredicate)); } if (predicate is EqualPredicate && predicate.Property.Name.Equals("Item.AccessScope")) { return(PsAccessScopeIsPredicate.FromEnginePredicate(predicate as EqualPredicate)); } if (predicate is ContentContainsSensitiveInformationPredicate) { return(PsContentContainsSensitiveInformationPredicate.FromEnginePredicate(predicate as ContentContainsSensitiveInformationPredicate)); } if (predicate is ContentMetadataContainsPredicate) { return(PsContentPropertyContainsWordsPredicate.FromEnginePredicate(predicate as ContentMetadataContainsPredicate)); } throw new UnexpectedConditionOrActionDetectedException(); }
internal static IEnumerable <PsComplianceRulePredicateBase> ConvertEngineConditionToTaskConditions(Microsoft.Office.CompliancePolicy.PolicyEvaluation.Condition condition) { List <PsComplianceRulePredicateBase> list = new List <PsComplianceRulePredicateBase>(); QueryPredicate queryPredicate = condition as QueryPredicate; if (queryPredicate != null) { AndCondition andCondition = queryPredicate.SubCondition as AndCondition; if (andCondition == null) { return(list); } using (List <Microsoft.Office.CompliancePolicy.PolicyEvaluation.Condition> .Enumerator enumerator = andCondition.SubConditions.GetEnumerator()) { while (enumerator.MoveNext()) { Microsoft.Office.CompliancePolicy.PolicyEvaluation.Condition condition2 = enumerator.Current; list.AddRange(PsHoldRule.ConvertEngineConditionToTaskConditions(condition2)); } return(list); } } if (condition is PredicateCondition) { PredicateCondition predicate = condition as PredicateCondition; list.Add(PsComplianceRulePredicateBase.FromEnginePredicate(predicate)); } else if (!(condition is TrueCondition)) { throw new UnexpectedConditionOrActionDetectedException(); } return(list); }
internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string internalPredicateName, string internalPropertyName) where T : SmtpAddressesPredicate, new() { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals(internalPredicateName) || !predicateCondition.Property.Name.Equals(internalPropertyName)) { return(null); } List <SmtpAddress> list = new List <SmtpAddress>(predicateCondition.Value.RawValues.Count); for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++) { SmtpAddress item = new SmtpAddress(predicateCondition.Value.RawValues[i]); if (item.IsValidAddress) { list.Add(item); } } T t = Activator.CreateInstance <T>(); if (list.Count > 0) { t.Addresses = list.ToArray(); } return(t); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("senderAttributeContains")) { return(null); } Word[] array = new Word[predicateCondition.Value.RawValues.Count]; for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++) { try { array[i] = new Word(predicateCondition.Value.RawValues[i]); } catch (ArgumentOutOfRangeException) { return(null); } } return(new SenderAttributeContainsPredicate { Words = array }); }
internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string internalPropertyName) where T : SinglePropertyContainsPredicate, new() { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("contains") || !predicateCondition.Property.Name.Equals(internalPropertyName)) { return(null); } Word[] array = new Word[predicateCondition.Value.RawValues.Count]; for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++) { try { array[i] = new Word(predicateCondition.Value.RawValues[i]); } catch (ArgumentOutOfRangeException) { return(null); } } T t = Activator.CreateInstance <T>(); t.Words = array; return(t); }
internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string internalPropertyName) where T : SinglePropertyMatchesPredicate, new() { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if ((!predicateCondition.Name.Equals("matches") && !predicateCondition.Name.Equals("matchesRegex")) || !predicateCondition.Property.Name.Equals(internalPropertyName)) { return(null); } bool useLegacyRegex = !predicateCondition.Name.Equals("matchesRegex"); Pattern[] array = new Pattern[predicateCondition.Value.RawValues.Count]; for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++) { try { array[i] = new Pattern(predicateCondition.Value.RawValues[i], useLegacyRegex, false); } catch (ArgumentException) { return(null); } } T t = Activator.CreateInstance <T>(); t.UseLegacyRegex = useLegacyRegex; t.patterns = array; return(t); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("senderAttributeMatches") && !predicateCondition.Name.Equals("senderAttributeMatchesRegex")) { return(null); } bool useLegacyRegex = !predicateCondition.Name.Equals("senderAttributeMatchesRegex"); Pattern[] array = new Pattern[predicateCondition.Value.RawValues.Count]; for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++) { try { array[i] = new Pattern(predicateCondition.Value.RawValues[i], useLegacyRegex, false); } catch (ArgumentException) { return(null); } } return(new SenderAttributeMatchesPredicate(useLegacyRegex) { Patterns = array }); }
private static bool IsImportanceCondition(Condition condition, Importance importance) { if (condition.ConditionType != ConditionType.Predicate) { return(false); } PredicateCondition predicateCondition = (PredicateCondition)condition; return(predicateCondition.Name.Equals("is") && predicateCondition.Property is HeaderProperty && predicateCondition.Property.Name.Equals("Importance") && predicateCondition.Value.RawValues.Count == 1 && predicateCondition.Value.RawValues[0].Equals(importance.ToString())); }
public override bool Equals(object obj) { PredicateCondition c = obj as PredicateCondition; if (c == null) { return(false); } return(m_predicate.Equals(c.m_predicate) && m_invert == c.m_invert); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Or) { return(null); } OrCondition orCondition = (OrCondition)condition; if (orCondition.SubConditions.Count != 2) { return(null); } if (orCondition.SubConditions[0].ConditionType != ConditionType.Predicate) { return(null); } if (orCondition.SubConditions[1].ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)orCondition.SubConditions[0]; PredicateCondition predicateCondition2 = (PredicateCondition)orCondition.SubConditions[1]; if (!predicateCondition.Name.Equals("contains") || !predicateCondition2.Name.Equals("contains") || !predicateCondition.Property.Name.Equals("Message.Subject") || !predicateCondition2.Property.Name.Equals("Message.Body")) { return(null); } if (predicateCondition.Value.RawValues.Count != predicateCondition2.Value.RawValues.Count) { return(null); } Word[] array = new Word[predicateCondition.Value.RawValues.Count]; for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++) { if (predicateCondition.Value.RawValues[i] != predicateCondition2.Value.RawValues[i]) { return(null); } try { array[i] = new Word(predicateCondition.Value.RawValues[i]); } catch (ArgumentOutOfRangeException) { return(null); } } return(new SubjectOrBodyContainsPredicate { Words = array }); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("attachmentIsUnsupported")) { return(null); } return(new AttachmentIsUnsupportedPredicate()); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("hasSenderOverride") || !predicateCondition.Property.Name.Equals("X-Ms-Exchange-Organization-Dlp-SenderOverrideJustification")) { return(null); } return(new HasSenderOverridePredicate()); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.AttachmentTypes") || predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Value.RawValues[0].Equals("executable")) { return(null); } return(new AttachmentHasExecutableContentPredicate()); }
internal override PredicateCondition ToEnginePredicate() { PredicateCondition result = null; try { result = new ContentMetadataContainsPredicate(base.Words.ToList <string>()); } catch (CompliancePolicyValidationException innerException) { throw new InvalidContentContentPropertyContainsWordsException(Strings.InvalidContentPropertyContainsWordsPredicate, innerException); } return(result); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { bool flag = false; if (condition.ConditionType == ConditionType.Not) { condition = ((NotCondition)condition).SubCondition; flag = true; } if (condition.ConditionType != ConditionType.And) { return(null); } AndCondition andCondition = (AndCondition)condition; if (andCondition.SubConditions.Count != 2 || andCondition.SubConditions[0].ConditionType != ConditionType.Not || andCondition.SubConditions[1].ConditionType != ConditionType.Predicate) { return(null); } NotCondition notCondition = (NotCondition)andCondition.SubConditions[0]; if (notCondition.SubCondition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)notCondition.SubCondition; PredicateCondition predicateCondition2 = (PredicateCondition)andCondition.SubConditions[1]; if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.Auth") || predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Value.RawValues[0].Equals("<>")) { return(null); } if (!predicateCondition2.Name.Equals("isInternal") || !predicateCondition2.Property.Name.Equals("Message.From") || predicateCondition2.Value.RawValues.Count != 0) { return(null); } FromScopePredicate fromScopePredicate = new FromScopePredicate(); if (flag) { fromScopePredicate.Scope = FromUserScope.NotInOrganization; } else { fromScopePredicate.Scope = FromUserScope.InOrganization; } return(fromScopePredicate); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.AttachmentExtensions")) { return(null); } Word[] array = (from value in predicateCondition.Value.RawValues select new Word(value)).ToArray <Word>(); return(new AttachmentExtensionMatchesWordsPredicate(array)); }
private void AddPredicateToCondition <T>(List <Condition> subConditions, string conditionTag, string propertyName, bool negateCondition, T[] values) { if (values == null || values.Length == 0) { return; } PredicateCondition predicateCondition = ClientAccessRuleParser.Instance.CreatePredicate(conditionTag, ClientAccessRuleParser.Instance.CreateProperty(propertyName), from value in values select value.ToString()); if (negateCondition) { subConditions.Add(new NotCondition(predicateCondition)); return; } subConditions.Add(predicateCondition); }
internal static TransportRulePredicate CreateFromInternalConditionWithSession(Condition condition, IConfigDataProvider session) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if ((!predicateCondition.Name.Equals("is") && !predicateCondition.Name.Equals("contains")) || !(predicateCondition.Property is HeaderProperty) || !predicateCondition.Property.Name.Equals("X-MS-Exchange-Organization-Classification") || predicateCondition.Value.RawValues.Count != 1) { return(null); } return(new HasClassificationPredicate(session) { Classification = Utils.GetClassificationADObjectId(predicateCondition.Value.RawValues[0], session) }); }
public static string GetStringCondition(PredicateCondition condition) { switch (condition) { case PredicateCondition.Equal: return "="; break; case PredicateCondition.LessThanOrEqual: return "<="; break; case PredicateCondition.GreaterThan: return ">"; break; default: throw new ArgumentOutOfRangeException(); } }
internal override Condition ToInternalCondition() { PredicateCondition item = TransportRuleParser.Instance.CreatePredicate("exists", TransportRuleParser.Instance.CreateProperty("Message.SclValue"), new ShortList <string>()); PredicateCondition item2 = TransportRuleParser.Instance.CreatePredicate("greaterThanOrEqual", TransportRuleParser.Instance.CreateProperty("Message.SclValue"), new ShortList <string> { this.SclValue.ToString() }); return(new AndCondition { SubConditions = { item, item2 } }); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!(predicateCondition.Property is HeaderProperty)) { return(null); } if (!predicateCondition.Name.Equals("notExists") || !predicateCondition.Property.Name.Equals("X-MS-Exchange-Organization-Classification")) { return(null); } return(new HasNoClassificationPredicate()); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)condition; if (!predicateCondition.Name.Equals("attachmentPropertyContains")) { return(null); } AttachmentPropertyContainsWordsPredicate attachmentPropertyContainsWordsPredicate = new AttachmentPropertyContainsWordsPredicate(); attachmentPropertyContainsWordsPredicate.Words = (from w in predicateCondition.Value.RawValues select new Word(w)).ToArray <Word>(); return(attachmentPropertyContainsWordsPredicate); }
internal override Condition ToInternalCondition() { if (this.Importance != Importance.Normal) { return(WithImportancePredicate.CreateImportancePredicate(this.Importance)); } PredicateCondition item = WithImportancePredicate.CreateImportancePredicate(Importance.High); PredicateCondition item2 = WithImportancePredicate.CreateImportancePredicate(Importance.Low); return(new NotCondition(new OrCondition { SubConditions = { item, item2 } })); }
private bool TryReadRecipientCondition(Microsoft.Exchange.MessagingPolicies.Rules.Condition condition) { if (condition.ConditionType != ConditionType.Or) { return(false); } List <Microsoft.Exchange.MessagingPolicies.Rules.Condition> subConditions = ((OrCondition)condition).SubConditions; if (subConditions.Count != 2) { return(false); } foreach (Microsoft.Exchange.MessagingPolicies.Rules.Condition condition2 in subConditions) { if (condition2.ConditionType != ConditionType.Or) { return(false); } List <Microsoft.Exchange.MessagingPolicies.Rules.Condition> subConditions2 = ((OrCondition)condition2).SubConditions; using (List <Microsoft.Exchange.MessagingPolicies.Rules.Condition> .Enumerator enumerator2 = subConditions2.GetEnumerator()) { if (enumerator2.MoveNext()) { Microsoft.Exchange.MessagingPolicies.Rules.Condition condition3 = enumerator2.Current; if (condition3.ConditionType != ConditionType.Predicate) { return(false); } PredicateCondition predicateCondition = condition3 as PredicateCondition; if (!predicateCondition.Name.Equals("isMemberOf") && !predicateCondition.Name.Equals("isSameUser")) { return(false); } if (!predicateCondition.Property.Name.Equals("Message.Sender") && !predicateCondition.Property.Name.Equals("Message.EnvelopeRecipients")) { return(false); } this.recipient = new SmtpAddress?(new SmtpAddress(predicateCondition.Value.RawValues[0])); return(true); } } } return(false); }
internal override Condition ToInternalCondition() { ShortList <string> shortList = new ShortList <string>(); foreach (Word word in this.Words) { shortList.Add(word.ToString()); } PredicateCondition item = TransportRuleParser.Instance.CreatePredicate("contains", TransportRuleParser.Instance.CreateProperty("Message.Subject"), shortList); PredicateCondition item2 = TransportRuleParser.Instance.CreatePredicate("contains", TransportRuleParser.Instance.CreateProperty("Message.Body"), shortList); return(new OrCondition { SubConditions = { item, item2 } }); }
internal static TransportRulePredicate CreateFromInternalCondition(Condition condition) { if (condition.ConditionType != ConditionType.And) { return(null); } AndCondition andCondition = (AndCondition)condition; if (andCondition.SubConditions.Count != 2 || andCondition.SubConditions[0].ConditionType != ConditionType.Predicate || andCondition.SubConditions[1].ConditionType != ConditionType.Predicate) { return(null); } PredicateCondition predicateCondition = (PredicateCondition)andCondition.SubConditions[0]; PredicateCondition predicateCondition2 = (PredicateCondition)andCondition.SubConditions[1]; if (!predicateCondition.Name.Equals("exists") || !predicateCondition.Property.Name.Equals("Message.SclValue")) { return(null); } if (!predicateCondition2.Name.Equals("greaterThanOrEqual") || !predicateCondition2.Property.Name.Equals("Message.SclValue") || predicateCondition2.Value.RawValues.Count != 1) { return(null); } int input; if (!int.TryParse(predicateCondition2.Value.RawValues[0], out input)) { return(null); } SclOverPredicate sclOverPredicate = new SclOverPredicate(); try { sclOverPredicate.SclValue = new SclValue(input); } catch (ArgumentOutOfRangeException) { return(null); } return(sclOverPredicate); }
internal override Condition ToInternalCondition() { ShortList <string> valueEntries = new ShortList <string> { "<>" }; PredicateCondition subCondition = TransportRuleParser.Instance.CreatePredicate("is", TransportRuleParser.Instance.CreateProperty("Message.Auth"), valueEntries); valueEntries = new ShortList <string>(); NotCondition item = new NotCondition(subCondition); PredicateCondition item2 = TransportRuleParser.Instance.CreatePredicate("isInternal", TransportRuleParser.Instance.CreateProperty("Message.From"), valueEntries); AndCondition andCondition = new AndCondition(); andCondition.SubConditions.Add(item); andCondition.SubConditions.Add(item2); if (this.Scope == FromUserScope.NotInOrganization) { return(new NotCondition(andCondition)); } return(andCondition); }