public static string GetRequirementsDescriptionString(object requirements, bool isOrgScope) { string result = string.Empty; RequestedCapabilities valueOrDefault = ((RequestedCapabilities?)requirements).GetValueOrDefault(); RequestedCapabilities?requestedCapabilities; if (requestedCapabilities != null) { switch (valueOrDefault) { case RequestedCapabilities.Restricted: result = (isOrgScope ? Strings.RequirementsRestrictedDescription : OwaOptionStrings.RequirementsRestrictedDescription); break; case RequestedCapabilities.ReadItem: result = (isOrgScope ? Strings.RequirementsReadItemDescription : OwaOptionStrings.RequirementsReadItemDescription); break; case RequestedCapabilities.ReadWriteMailbox: result = (isOrgScope ? Strings.RequirementsReadWriteMailboxDescription : OwaOptionStrings.RequirementsReadWriteMailboxDescription); break; case RequestedCapabilities.ReadWriteItem: result = (isOrgScope ? Strings.RequirementsReadWriteItemDescription : OwaOptionStrings.RequirementsReadWriteItemDescription); break; } } return(result); }
private static void ValidateItemHasKnownEntityRule(XmlNode xmlNode, RequestedCapabilities requestedCapabilities, ref HashSet <string> entitiesRegExNames, ref int regexCount) { if (requestedCapabilities == RequestedCapabilities.Restricted) { XmlAttribute attribute = xmlNode.Attributes["EntityType"]; string item; if (!ExtensionDataHelper.TryGetAttributeValue(attribute, out item) || !SchemaParser.AllowedEntityTypesInRestricted.Contains(item)) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonOnlySelectedEntitiesInRestricted)); } } XmlAttribute attribute2 = xmlNode.Attributes["RegExFilter"]; XmlAttribute attribute3 = xmlNode.Attributes["FilterName"]; string text; bool flag = ExtensionDataHelper.TryGetAttributeValue(attribute3, out text); string regexPattern; bool flag2 = ExtensionDataHelper.TryGetAttributeValue(attribute2, out regexPattern); if (flag != flag2) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonRegExNameAndValueRequiredInEntitiesRules)); } if (!flag) { XmlAttribute attribute4 = xmlNode.Attributes["IgnoreCase"]; string text2; if (ExtensionDataHelper.TryGetAttributeValue(attribute4, out text2)) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonIgnoreCaseWithoutRegExInEntitiesRules)); } return; } else { regexCount++; if (entitiesRegExNames == null) { entitiesRegExNames = new HashSet <string>(); } else if (regexCount > 5) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonTooManyRegexRule(5))); } if (!entitiesRegExNames.Add(text)) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonMultipleRulesWithSameFilterName(text))); } SchemaParser.ValidateRegEx(text, regexPattern, "ItemHasKnownEntity", "RegExFilter"); return; } }
public void ValidateRules() { RequestedCapabilities requestedCapabilities = this.GetRequestedCapabilities(); using (XmlNodeList xmlNodeList = this.xmlDoc.SelectNodes(this.GetOweXpath("Rule"), this.namespaceManager)) { int num = 0; int num2 = 0; HashSet <string> hashSet = null; HashSet <string> hashSet2 = null; int num3 = 0; foreach (object obj in xmlNodeList) { XmlNode xmlNode = (XmlNode)obj; XmlAttribute attribute = xmlNode.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"]; string a; if (ExtensionDataHelper.TryGetNameSpaceStrippedAttributeValue(attribute, out a)) { if (string.Equals(a, "RuleCollection", StringComparison.Ordinal)) { num2++; } else { num++; } if (num > 15 || num2 > 15) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonTooManyRule(15))); } if (string.Equals(a, "ItemIs", StringComparison.Ordinal)) { SchemaParser.ValidateItemIsRule(xmlNode); } else if (string.Equals(a, "ItemHasKnownEntity", StringComparison.Ordinal)) { SchemaParser.ValidateItemHasKnownEntityRule(xmlNode, requestedCapabilities, ref hashSet2, ref num3); } else if (string.Equals(a, "ItemHasRegularExpressionMatch", StringComparison.Ordinal)) { num3++; if (hashSet == null) { hashSet = new HashSet <string>(); } string attributeStringValue = ExtensionData.GetAttributeStringValue(xmlNode, "RegExName"); if (!hashSet.Add(attributeStringValue)) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonMultipleRulesWithSameRegExName(attributeStringValue))); } if (requestedCapabilities == RequestedCapabilities.Restricted) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonNoRegexRuleInRestricted)); } if (num3 > 5) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonTooManyRegexRule(5))); } SchemaParser.ValidateRegEx(attributeStringValue, ExtensionData.GetAttributeStringValue(xmlNode, "RegExValue"), "ItemHasRegularExpressionMatch", "RegExValue"); } } } } }