Exemplo n.º 1
0
        internal static SharingMessage DeserializeFromStream(Stream stream)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SharingMessage));
            XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(stream);

            xmlTextReader.WhitespaceHandling = WhitespaceHandling.Significant;
            xmlTextReader.Normalization      = true;
            return(xmlSerializer.Deserialize(xmlTextReader) as SharingMessage);
        }
Exemplo n.º 2
0
 public RBACContext(Stream inputStream)
 {
     if (inputStream == null)
     {
         throw new ArgumentNullException("inputStream");
     }
     using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(inputStream))
     {
         this.Deserialize(xmlTextReader);
     }
 }
Exemplo n.º 3
0
 public void Load(CallContext callContext)
 {
     this.entries.Clear();
     using (UserConfiguration userConfiguration = this.GetUserConfiguration(this.configurationAttribute.ConfigurationName, callContext.SessionCache.GetMailboxIdentityMailboxSession()))
     {
         using (Stream xmlStream = userConfiguration.GetXmlStream())
         {
             if (xmlStream != null && xmlStream.Length > 0L)
             {
                 this.reader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream);
                 this.Parse(this.reader, callContext);
             }
         }
     }
 }
Exemplo n.º 4
0
 public void Load()
 {
     this.entries.Clear();
     using (UserConfiguration userConfiguration = UserConfigurationUtilities.GetUserConfiguration(this.configurationAttribute.ConfigurationName, this.userContext))
     {
         using (Stream xmlStream = userConfiguration.GetXmlStream())
         {
             if (xmlStream != null && xmlStream.Length > 0L)
             {
                 this.reader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream);
                 this.Parse(this.reader);
             }
         }
     }
 }
        public ClassificationRulePackage GetRulePackage(string ruleString)
        {
            ClassificationRulePackage result = null;
            XmlReader reader = null;

            try
            {
                XmlReaderSettings settings = new XmlReaderSettings
                {
                    ConformanceLevel = ConformanceLevel.Auto,
                    IgnoreComments   = true,
                    DtdProcessing    = DtdProcessing.Prohibit,
                    XmlResolver      = null
                };
                using (StringReader stringReader = new StringReader(ruleString))
                {
                    using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(stringReader))
                    {
                        XmlReader xmlReader;
                        reader = (xmlReader = XmlReader.Create(xmlTextReader, settings));
                        try
                        {
                            result = this.ParseRule(reader);
                        }
                        finally
                        {
                            if (xmlReader != null)
                            {
                                ((IDisposable)xmlReader).Dispose();
                            }
                        }
                    }
                }
            }
            catch (XmlException e)
            {
                throw new ParserException(e);
            }
            catch (RulesValidationException e2)
            {
                throw new ParserException(e2, reader);
            }
            return(result);
        }
 // Token: 0x06000925 RID: 2341 RVA: 0x00041CBC File Offset: 0x0003FEBC
 public void Load()
 {
     using (UserConfiguration userConfiguration = this.GetUserConfiguration())
     {
         using (Stream xmlStream = userConfiguration.GetXmlStream())
         {
             if (xmlStream != null && xmlStream.Length > 0L)
             {
                 using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream))
                 {
                     this.Parse(xmlTextReader);
                     goto IL_3B;
                 }
             }
             this.ClearCache();
             IL_3B :;
         }
     }
 }
Exemplo n.º 7
0
        // Token: 0x06003033 RID: 12339 RVA: 0x0011A5B0 File Offset: 0x001187B0
        private static List <DocumentLibrary> GetFavoritesList(UserContext userContext)
        {
            List <DocumentLibrary> list = new List <DocumentLibrary>();

            using (UserConfiguration userConfiguration = UserConfigurationUtilities.GetUserConfiguration("Owa.DocumentLibraryFavorites", userContext))
            {
                using (Stream xmlStream = userConfiguration.GetXmlStream())
                {
                    if (xmlStream != null && xmlStream.Length > 0L)
                    {
                        using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream))
                        {
                            DocumentLibraryUtilities.ParseFavoritesList(xmlTextReader, list, userContext);
                        }
                    }
                }
            }
            return(list);
        }
Exemplo n.º 8
0
        static MExConfiguration()
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            MExConfiguration.Schemas         = new XmlSchemaSet();
            MExConfiguration.InternalSchemas = new XmlSchemaSet();
            using (Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("MExRuntimeConfig.xsd"))
            {
                MExConfiguration.Schemas.Add(null, SafeXmlFactory.CreateSafeXmlTextReader(manifestResourceStream));
                manifestResourceStream.Position = 0L;
                MExConfiguration.InternalSchemas.Add(null, SafeXmlFactory.CreateSafeXmlTextReader(manifestResourceStream));
            }
            using (Stream manifestResourceStream2 = executingAssembly.GetManifestResourceStream("InternalMExRuntimeConfig.xsd"))
            {
                MExConfiguration.InternalSchemas.Add(null, SafeXmlFactory.CreateSafeXmlTextReader(manifestResourceStream2));
            }
            MExConfiguration.Schemas.Compile();
            MExConfiguration.InternalSchemas.Compile();
        }
 // Token: 0x060014D4 RID: 5332 RVA: 0x0007EAB0 File Offset: 0x0007CCB0
 internal static void Initialize()
 {
     if (!File.Exists(UIExtensionManager.FullExtensionFileName))
     {
         return;
     }
     try
     {
         using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(UIExtensionManager.FullExtensionFileName))
         {
             xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
             while (xmlTextReader.Read())
             {
                 if (xmlTextReader.NodeType == XmlNodeType.Element)
                 {
                     if (xmlTextReader.Name == "MainNavigationBarExtensions")
                     {
                         UIExtensionManager.ParseNavigationBarEntries(xmlTextReader, UIExtensionManager.navigationBarEntries);
                     }
                     else if (xmlTextReader.Name == "NewItemMenuEntries")
                     {
                         UIExtensionManager.ParseNewItemMenuEntries(xmlTextReader, UIExtensionManager.menuItemEntries);
                     }
                     else if (xmlTextReader.Name == "RightClickMenuExtensions")
                     {
                         UIExtensionManager.ParseRightClickMenuItemEntries(xmlTextReader, UIExtensionManager.contextMenuItemEntries);
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
         OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomizationUIExtensionParseError, string.Empty, new object[]
         {
             UIExtensionManager.FullExtensionFileName
         });
         UIExtensionManager.navigationBarEntries.Clear();
         UIExtensionManager.menuItemEntries.Clear();
         UIExtensionManager.contextMenuItemEntries.Clear();
     }
 }
        internal static AirSyncUserSecurityContext Deserialize(Stream input)
        {
            XmlTextReader xmlTextReader = null;
            AirSyncUserSecurityContext result;

            try
            {
                xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(input);
                xmlTextReader.WhitespaceHandling = WhitespaceHandling.All;
                AirSyncUserSecurityContext airSyncUserSecurityContext = AirSyncUserSecurityContext.Deserialize(xmlTextReader);
                result = airSyncUserSecurityContext;
            }
            finally
            {
                if (xmlTextReader != null)
                {
                    xmlTextReader.Close();
                }
            }
            return(result);
        }
Exemplo n.º 11
0
 private XmlTextReader EndGetUsers(ICancelableAsyncResult asyncResult, out Exception exception)
 {
     try
     {
         exception = null;
         DownloadResult downloadResult = this.httpClient.EndDownload(asyncResult);
         if (!downloadResult.IsSucceeded)
         {
             WebException ex = downloadResult.Exception as WebException;
             if (ex != null)
             {
                 exception = new SharePointException((this.httpClient.LastKnownRequestedUri != null) ? this.httpClient.LastKnownRequestedUri.AbsoluteUri : string.Empty, ex, true);
             }
             else
             {
                 exception = downloadResult.Exception;
             }
         }
         else
         {
             if (downloadResult.ResponseStream == null)
             {
                 exception = new SharePointException((this.httpClient.LastKnownRequestedUri != null) ? this.httpClient.LastKnownRequestedUri.AbsoluteUri : string.Empty, ServerStrings.ErrorTeamMailboxGetUsersNullResponse);
                 return(null);
             }
             downloadResult.ResponseStream.Position = 0L;
             return(SafeXmlFactory.CreateSafeXmlTextReader(downloadResult.ResponseStream));
         }
     }
     finally
     {
         if (this.httpSessionConfig.RequestStream != null)
         {
             this.httpSessionConfig.RequestStream.Flush();
             this.httpSessionConfig.RequestStream.Dispose();
             this.httpSessionConfig.RequestStream = null;
         }
     }
     return(null);
 }
Exemplo n.º 12
0
        private static XmlTextReader InitializeXmlTextReader(string xmlFilePath)
        {
            ExTraceGlobals.SmallIconCallTracer.TraceDebug <string>(0L, "InitializeXmlTextReader: XmlFilePath = '{0}'", xmlFilePath);
            if (!File.Exists(xmlFilePath))
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_SmallIconsFileNotFound, string.Empty, new object[]
                {
                    xmlFilePath
                });
                throw new OwaSmallIconManagerInitializationException("SmallIcon XML file is not found: '" + xmlFilePath + "'");
            }
            XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlFilePath);

            xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
            xmlTextReader.NameTable.Add("SmallIconMappings");
            xmlTextReader.NameTable.Add("Mapping");
            xmlTextReader.NameTable.Add("ItemClass");
            xmlTextReader.NameTable.Add("IconFlag");
            xmlTextReader.NameTable.Add("SmallIcon");
            xmlTextReader.NameTable.Add("PrefixMatch");
            xmlTextReader.NameTable.Add("Alt");
            return(xmlTextReader);
        }
Exemplo n.º 13
0
        internal void Load(string registryFile, string folder)
        {
            ExTraceGlobals.FormsRegistryCallTracer.TraceDebug <string, string>((long)this.GetHashCode(), "FormsRegistryParser.Load  registry file = {0}, folder = {1}", registryFile, folder);
            this.registryFile = registryFile;
            bool   flag           = false;
            string name           = string.Empty;
            string inheritsFrom   = string.Empty;
            string baseExperience = string.Empty;
            bool   isRichClient   = false;

            try
            {
                this.reader = SafeXmlFactory.CreateSafeXmlTextReader(registryFile);
                this.reader.WhitespaceHandling = WhitespaceHandling.None;
                this.registry = new FormsRegistry();
                this.reader.Read();
                if (this.reader.Name != FormsRegistryParser.nameTableValues[0])
                {
                    this.ThrowExpectedElementException(FormsRegistryParser.NameTableValues.Registry);
                }
                if (!this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[1]))
                {
                    this.ThrowExpectedAttributeException(FormsRegistryParser.NameTableValues.Name);
                }
                name = this.reader.Value;
                if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[3]))
                {
                    inheritsFrom = this.reader.Value;
                    if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[2]))
                    {
                        this.ThrowParserException("BaseExperience is not valid when inheriting from another registry. The BaseExperience from the inherited registry is used instead", ClientsEventLogConstants.Tuple_FormsRegistryInvalidUserOfBaseExperience, new object[]
                        {
                            registryFile,
                            this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                            this.reader.LinePosition.ToString(CultureInfo.InvariantCulture)
                        });
                    }
                }
                else if (this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[2]))
                {
                    baseExperience = this.reader.Value;
                }
                else
                {
                    this.ThrowParserException("Expected BaseExperience or InheritsFrom attribute", ClientsEventLogConstants.Tuple_FormsRegistryExpectedBaseExperienceOrInheritsFrom, new object[]
                    {
                        registryFile,
                        this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                        this.reader.LinePosition.ToString(CultureInfo.InvariantCulture)
                    });
                }
                if (!this.reader.MoveToAttribute(FormsRegistryParser.nameTableValues[4]))
                {
                    this.ThrowExpectedAttributeException(FormsRegistryParser.NameTableValues.IsRichClient);
                }
                try
                {
                    isRichClient = bool.Parse(this.reader.Value);
                }
                catch (FormatException)
                {
                    this.ThrowParserException("Expected a valid boolean value in IsRichClient property", ClientsEventLogConstants.Tuple_FormsRegistryInvalidUserOfIsRichClient, new object[]
                    {
                        registryFile,
                        this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                        this.reader.LinePosition.ToString(CultureInfo.InvariantCulture),
                        this.reader.Value
                    });
                }
                try
                {
                    this.registry.Initialize(name, baseExperience, inheritsFrom, folder, isRichClient);
                    goto IL_33E;
                }
                catch (OwaInvalidInputException ex)
                {
                    OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_FormsRegistryParseError, ex.Message, new object[]
                    {
                        registryFile,
                        this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                        this.reader.LinePosition.ToString(CultureInfo.InvariantCulture),
                        ex.Message
                    });
                    throw ex;
                }
IL_2D4:
                XmlNodeType nodeType = this.reader.NodeType;
                if (nodeType != XmlNodeType.Element)
                {
                    if (nodeType == XmlNodeType.EndElement)
                    {
                        if (this.reader.Name == FormsRegistryParser.nameTableValues[0])
                        {
                            flag = true;
                        }
                    }
                }
                else if (this.reader.Name == FormsRegistryParser.nameTableValues[5])
                {
                    this.clientMappings.AddRange(this.ParseExperience());
                }
                else
                {
                    this.ThrowExpectedElementException(FormsRegistryParser.NameTableValues.Experience);
                }
IL_33E:
                if (!flag && this.reader.Read())
                {
                    goto IL_2D4;
                }
            }
            catch (XmlException ex2)
            {
                this.ThrowParserException(ex2.Message, ClientsEventLogConstants.Tuple_FormsRegistryParseError, new object[]
                {
                    registryFile,
                    this.reader.LineNumber.ToString(CultureInfo.InvariantCulture),
                    this.reader.LinePosition.ToString(CultureInfo.InvariantCulture),
                    ex2.Message
                });
            }
            finally
            {
                if (this.reader != null)
                {
                    this.reader.Close();
                }
            }
        }
Exemplo n.º 14
0
        private static void ParseThemeInfoFile(string themeInfoFilePath, string folderName, out string displayName, out int sortOrder)
        {
            XmlTextReader xmlTextReader = null;

            displayName = null;
            sortOrder   = int.MaxValue;
            try
            {
                xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(themeInfoFilePath);
                xmlTextReader.WhitespaceHandling = WhitespaceHandling.All;
                if (!xmlTextReader.Read() || xmlTextReader.NodeType != XmlNodeType.Element || !string.Equals("Theme", xmlTextReader.Name, StringComparison.OrdinalIgnoreCase))
                {
                    Theme.ThrowParserException(xmlTextReader, folderName, string.Format("Expected root element '{0}' not found.", "Theme"), ClientsEventLogConstants.Tuple_ThemeInfoExpectedElement, new object[]
                    {
                        "themeinfo.xml",
                        folderName,
                        "Theme"
                    });
                }
                if (xmlTextReader.MoveToFirstAttribute())
                {
                    do
                    {
                        if (string.Equals("DisplayName", xmlTextReader.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            if (displayName != null)
                            {
                                Theme.ThrowParserException(xmlTextReader, folderName, string.Format("Duplicated attribute '{0}' found.", "DisplayName"), ClientsEventLogConstants.Tuple_ThemeInfoDuplicatedAttribute, new object[]
                                {
                                    "themeinfo.xml",
                                    folderName,
                                    "DisplayName",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                    xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                                });
                            }
                            displayName = xmlTextReader.Value;
                            if (string.IsNullOrEmpty(displayName))
                            {
                                Theme.ThrowParserException(xmlTextReader, folderName, string.Format("Empty attribute '{0}' not allowed.", "DisplayName"), ClientsEventLogConstants.Tuple_ThemeInfoEmptyAttribute, new object[]
                                {
                                    "themeinfo.xml",
                                    folderName,
                                    "DisplayName",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                    xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                                });
                            }
                            if (displayName.Length > 512)
                            {
                                Theme.ThrowParserException(xmlTextReader, folderName, string.Format("Attribute '{0}' exceeds the maximum limit of {1} characters.", "DisplayName", 512), ClientsEventLogConstants.Tuple_ThemeInfoAttributeExceededMaximumLength, new object[]
                                {
                                    "themeinfo.xml",
                                    folderName,
                                    "DisplayName",
                                    512,
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                    xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                                });
                            }
                        }
                        if (string.Equals("SortOrder", xmlTextReader.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                sortOrder = int.Parse(xmlTextReader.Value);
                            }
                            catch
                            {
                                Theme.ThrowParserException(xmlTextReader, folderName, string.Format("Attribute '{0}' is not a valid integer.", "SortOrder"), ClientsEventLogConstants.Tuple_ThemeInfoErrorParsingXml, new object[]
                                {
                                    "themeinfo.xml",
                                    folderName,
                                    "SortOrder",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                    xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                                });
                            }
                        }
                    }while (xmlTextReader.MoveToNextAttribute());
                    if (displayName == null)
                    {
                        Theme.ThrowParserException(xmlTextReader, folderName, string.Format("Attribute '{0}' was not found.", "DisplayName"), ClientsEventLogConstants.Tuple_ThemeInfoMissingAttribute, new object[]
                        {
                            "themeinfo.xml",
                            folderName,
                            "DisplayName",
                            xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                            xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                        });
                    }
                }
            }
            catch (XmlException ex)
            {
                Theme.ThrowParserException(xmlTextReader, folderName, string.Format("XML parser error. {0}", ex.Message), ClientsEventLogConstants.Tuple_ThemeInfoErrorParsingXml, new object[]
                {
                    "themeinfo.xml",
                    folderName,
                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                    xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                });
            }
            finally
            {
                if (xmlTextReader != null)
                {
                    xmlTextReader.Close();
                }
            }
        }
        // Token: 0x06000EBE RID: 3774 RVA: 0x0005D958 File Offset: 0x0005BB58
        protected override Hashtable ParseParameters()
        {
            Stream inputStream = base.EventHandler.HttpContext.Request.InputStream;

            if (inputStream.Length <= 0L)
            {
                return(base.ParameterTable);
            }
            try
            {
                this.reader = SafeXmlFactory.CreateSafeXmlTextReader(inputStream);
                this.reader.WhitespaceHandling = WhitespaceHandling.All;
                this.paramInfo = null;
                this.itemArray = null;
                this.state     = OwaEventXmlParser.XmlParseState.Start;
                while (this.state != OwaEventXmlParser.XmlParseState.Finished && this.reader.Read())
                {
                    switch (this.state)
                    {
                    case OwaEventXmlParser.XmlParseState.Start:
                        this.ParseStart();
                        break;

                    case OwaEventXmlParser.XmlParseState.Root:
                        this.ParseRoot();
                        break;

                    case OwaEventXmlParser.XmlParseState.Child:
                        this.ParseChild();
                        break;

                    case OwaEventXmlParser.XmlParseState.ChildText:
                        this.ParseChildText();
                        break;

                    case OwaEventXmlParser.XmlParseState.ChildEnd:
                        this.ParseChildEnd();
                        break;

                    case OwaEventXmlParser.XmlParseState.Item:
                        this.ParseItem();
                        break;

                    case OwaEventXmlParser.XmlParseState.ItemText:
                        this.ParseItemText();
                        break;

                    case OwaEventXmlParser.XmlParseState.ItemEnd:
                        this.ParseItemEnd();
                        break;
                    }
                }
            }
            catch (XmlException ex)
            {
                ExTraceGlobals.OehTracer.TraceDebug <string>(0L, "Parser threw an XML exception: {0}'", ex.Message);
                throw new OwaInvalidRequestException(ex.Message, ex, this);
            }
            finally
            {
                this.reader.Close();
            }
            return(base.ParameterTable);
        }
Exemplo n.º 16
0
        // Token: 0x060006D2 RID: 1746 RVA: 0x0003540C File Offset: 0x0003360C
        internal static void Initialize(string directory)
        {
            string text = directory + "\\customadproperties.xml";

            if (!File.Exists(text))
            {
                return;
            }
            XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(text);

            xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
            ADCustomPropertyParser.customPropertyDictionary = new Dictionary <string, PropertyDefinition>();
            try
            {
                xmlTextReader.Read();
                if (xmlTextReader.NodeType == XmlNodeType.XmlDeclaration)
                {
                    xmlTextReader.Read();
                }
                if (!xmlTextReader.Name.Equals("CustomProperties") || xmlTextReader.NodeType != XmlNodeType.Element)
                {
                    OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomPropertiesRootElementNotFound, string.Empty, new object[]
                    {
                        "customadproperties.xml",
                        xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture)
                    });
                }
                else
                {
                    while (xmlTextReader.Read())
                    {
                        if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.Name.Equals("CustomProperty"))
                        {
                            if (xmlTextReader.AttributeCount != 2)
                            {
                                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_InvalidCustomPropertiesAttributeCount, string.Empty, new object[]
                                {
                                    "customadproperties.xml",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture)
                                });
                                break;
                            }
                            if (!xmlTextReader.MoveToAttribute("DisplayName"))
                            {
                                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomPropertiesAttributeNotFound, string.Empty, new object[]
                                {
                                    "DisplayName",
                                    "customadproperties.xml",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                    "First"
                                });
                                break;
                            }
                            string value = xmlTextReader.Value;
                            if (string.IsNullOrEmpty(value))
                            {
                                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomPropertiesInvalidAttibuteValue, string.Empty, new object[]
                                {
                                    "DisplayName",
                                    "customadproperties.xml",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture)
                                });
                                break;
                            }
                            if (!xmlTextReader.MoveToAttribute("LdapDisplayName"))
                            {
                                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomPropertiesAttributeNotFound, string.Empty, new object[]
                                {
                                    "LdapDisplayName",
                                    "customadproperties.xml",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                    "Second"
                                });
                                break;
                            }
                            string value2 = xmlTextReader.Value;
                            if (string.IsNullOrEmpty(value2))
                            {
                                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomPropertiesInvalidAttibuteValue, string.Empty, new object[]
                                {
                                    "LdapDisplayName",
                                    "customadproperties.xml",
                                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture)
                                });
                                break;
                            }
                            ADPropertyDefinition value3 = new ADPropertyDefinition(value, ExchangeObjectVersion.Exchange2003, typeof(string), value2, ADPropertyDefinitionFlags.None, string.Empty, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, null, null);
                            ADCustomPropertyParser.customPropertyDictionary.Add(value, value3);
                        }
                        else if (xmlTextReader.NodeType != XmlNodeType.EndElement || !xmlTextReader.Name.Equals("CustomProperties"))
                        {
                            OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_InvalidElementInCustomPropertiesFile, string.Empty, new object[]
                            {
                                "customadproperties.xml",
                                xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                                xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture)
                            });
                            break;
                        }
                    }
                }
            }
            catch (XmlException ex)
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_CustomPropertiesParseError, string.Empty, new object[]
                {
                    "customadproperties.xml",
                    xmlTextReader.LineNumber.ToString(CultureInfo.InvariantCulture),
                    xmlTextReader.LinePosition.ToString(CultureInfo.InvariantCulture),
                    ex.Message
                });
            }
            finally
            {
                if (xmlTextReader != null)
                {
                    xmlTextReader.Close();
                }
            }
        }
        public ResultsLoaderProfile GetProfile(string profileName)
        {
            Stream        manifestResource = WinformsHelper.GetManifestResource(this.dataDrivenCategory);
            XmlTextReader reader           = SafeXmlFactory.CreateSafeXmlTextReader(manifestResource);
            XElement      po = XElement.Load(reader);
            DataTable     inputTable;
            var <>        f__AnonymousType = (from dataSource in po.Elements("ResultsLoader")
                                              where (string)dataSource.Attribute("Name") == profileName
                                              select new
            {
                Configuration = this.CreateUIPresentationProfile(po, dataSource.Element("Configuration")),
                DataTable = (from dataTable in dataSource.Elements("DataColumns")
                             select new
                {
                    DataColumns = dataTable.Elements("Column").Union(dataTable.Elements("RefColumns").SelectMany((XElement r) => (from c in po.Element("RefColumnsSection").Elements("RefColumns")
                                                                                                                                  where c.Attribute("Name").Value == r.Attribute("Name").Value
                                                                                                                                  select c).Elements("Column"))),
                    PrimaryKey = (this.HasValue(dataTable.Attribute("PrimaryKey")) ? dataTable.Attribute("PrimaryKey").Value.Split(new char[]
                    {
                        ','
                    }) : new string[0]),
                    NameProperty = (this.HasValue(dataTable.Attribute("NameProperty")) ? dataTable.Attribute("NameProperty").Value : "Name"),
                    DataColumnsCalculator = (IDataColumnsCalculator)(this.HasValue(dataTable.Attribute("DataColumnsCalculator")) ? ObjectPickerProfileLoader.CreateObject(dataTable.Attribute("DataColumnsCalculator").Value) : null),
                    WholeObjectProperty = (this.HasValue(dataTable.Attribute("WholeObjectProperty")) ? dataTable.Attribute("WholeObjectProperty").Value : string.Empty),
                    DistinguishIdentity = (this.HasValue(dataTable.Attribute("DistinguishIdentity")) ? dataTable.Attribute("DistinguishIdentity").Value : string.Empty)
                }).First(),
                InputTable = (this.HasValue(dataSource.Element("InputColumns")) ? (from inputTable in dataSource.Elements("InputColumns")
                                                                                   select new
                {
                    DataColumns = inputTable.Elements("Column").Union(inputTable.Elements("RefColumns").SelectMany((XElement r) => (from c in po.Element("RefColumnsSection").Elements("RefColumns")
                                                                                                                                    where c.Attribute("Name").Value == r.Attribute("Name").Value
                                                                                                                                    select c).Elements("Column"))),
                    PartialOrderComparer = (IPartialOrderComparer)(this.HasValue(inputTable.Attribute("PartialOrderComparer")) ? ObjectPickerProfileLoader.CreateObject(inputTable.Attribute("PartialOrderComparer").Value) : null)
                }).First() : null),
                DataReader = (from dataReader in dataSource.Elements("DataTableFillers")
                              select new
                {
                    DataTableFillers = dataReader.Elements(),
                    BatchSize = (this.HasValue(dataReader.Attribute("BatchSize")) ? dataReader.Attribute("BatchSize").Value : ResultsLoaderProfile.DefaultBatchSize.ToString()),
                    FillType = (this.HasValue(dataReader.Attribute("FillType")) ? ((FillType)Enum.Parse(typeof(FillType), dataReader.Attribute("FillType").Value)) : 0),
                    LoadableFromProfilePredicate = (ILoadableFromProfile)(this.HasValue(dataReader.Attribute("LoadableFromProfilePredicate")) ? ObjectPickerProfileLoader.CreateObject(dataReader.Attribute("LoadableFromProfilePredicate").Value) : null),
                    PostRefreshAction = (PostRefreshActionBase)(this.HasValue(dataReader.Attribute("PostRefreshAction")) ? ObjectPickerProfileLoader.CreateObject(dataReader.Attribute("PostRefreshAction").Value) : null)
                }).First()
            }).First();
            DataTable resultTable = this.GetTableSchema(< > f__AnonymousType.DataTable.DataColumns, true);

            resultTable.PrimaryKey = (from c in < > f__AnonymousType.DataTable.PrimaryKey
                                      select resultTable.Columns[c]).ToArray <DataColumn>();
            resultTable.TableName = profileName;
            inputTable            = ((< > f__AnonymousType.InputTable != null) ? this.GetTableSchema(< > f__AnonymousType.InputTable.DataColumns, false) : new DataTable());
            ResultsLoaderProfile resultsLoaderProfile = new ResultsLoaderProfile(< > f__AnonymousType.Configuration, inputTable, resultTable)
            {
                Name = profileName,
                InputTablePartialOrderComparer = ((< > f__AnonymousType.InputTable == null) ? null : < > f__AnonymousType.InputTable.PartialOrderComparer),
                WholeObjectProperty            = < > f__AnonymousType.DataTable.WholeObjectProperty,
                NameProperty                 = < > f__AnonymousType.DataTable.NameProperty,
                DataColumnsCalculator        = < > f__AnonymousType.DataTable.DataColumnsCalculator,
                LoadableFromProfilePredicate = < > f__AnonymousType.DataReader.LoadableFromProfilePredicate,
                PostRefreshAction            = < > f__AnonymousType.DataReader.PostRefreshAction,
                BatchSize           = ((string.Compare(< > f__AnonymousType.DataReader.BatchSize, "MaxValue", true) == 0) ? int.MaxValue : int.Parse(< > f__AnonymousType.DataReader.BatchSize)),
                DistinguishIdentity = < > f__AnonymousType.DataTable.DistinguishIdentity,
                FillType            = < > f__AnonymousType.DataReader.FillType
            };

            this.AddFillerCollection(resultsLoaderProfile, <> f__AnonymousType.DataReader.DataTableFillers);
            return(resultsLoaderProfile);
        }
 private static XmlReader InternalGetXmlReader(TextReader reader)
 {
     return(SafeXmlFactory.CreateSafeXmlTextReader(reader));
 }
Exemplo n.º 19
0
 private static XmlReader InternalGetXmlReader(Stream stream)
 {
     return(SafeXmlFactory.CreateSafeXmlTextReader(stream));
 }
Exemplo n.º 20
0
        internal void Load(Dictionary <string, StoreDriverParameterHandler> keyHandlerCollection)
        {
            if (keyHandlerCollection == null)
            {
                return;
            }
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            string   text = Path.Combine(Path.GetDirectoryName(executingAssembly.Location), "StoreDriver.config");

            if (!File.Exists(text))
            {
                StoreDriverParameters.diag.TraceError <string>(0L, "The config file {0} does not exist.", text);
                return;
            }
            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();

            try
            {
                using (Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("StoreDriverParameters.xsd"))
                {
                    if (manifestResourceStream == null)
                    {
                        StoreDriverParameters.diag.TraceDebug <string>(0L, "The schema resource {0} does not exist.", "StoreDriverParameters.xsd");
                        return;
                    }
                    xmlSchemaSet.Add(null, SafeXmlFactory.CreateSafeXmlTextReader(manifestResourceStream));
                }
            }
            catch (FileLoadException arg)
            {
                StoreDriverParameters.diag.TraceError <string, FileLoadException>(0L, "Failed to load the manifest resource stream {0}. Error {1}", "StoreDriverParameters.xsd", arg);
                return;
            }
            catch (FileNotFoundException arg2)
            {
                StoreDriverParameters.diag.TraceError <string, FileNotFoundException>(0L, "Failed to find the manifest resource stream {0}.Error: {1}", text, arg2);
                return;
            }
            Exception ex = null;

            try
            {
                xmlSchemaSet.Compile();
                XmlDocument xmlDocument = new SafeXmlDocument();
                xmlDocument.Schemas = xmlSchemaSet;
                using (FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    xmlDocument.Load(fileStream);
                    XmlNodeList xmlNodeList = xmlDocument.SelectNodes("/configuration/storeDriver/parameters/add");
                    foreach (object obj in xmlNodeList)
                    {
                        XmlNode xmlNode = (XmlNode)obj;
                        if (xmlNode != null && xmlNode is XmlElement)
                        {
                            this.currentNodeValid = true;
                            xmlDocument.Validate(delegate(object sender, ValidationEventArgs args)
                            {
                                StoreDriverParameters.diag.TraceDebug <string>(0L, "The parameter or value is invalid: {0}.", args.Message);
                                this.currentNodeValid = false;
                            }, xmlNode);
                            if (this.currentNodeValid)
                            {
                                string value  = xmlNode.Attributes.GetNamedItem("key").Value;
                                string value2 = xmlNode.Attributes.GetNamedItem("value").Value;
                                if (value != null && value2 != null && keyHandlerCollection.ContainsKey(value))
                                {
                                    keyHandlerCollection[value](value, value2);
                                }
                            }
                        }
                    }
                }
            }
            catch (XmlSchemaException ex2)
            {
                ex = ex2;
            }
            catch (SecurityException ex3)
            {
                ex = ex3;
            }
            catch (IOException ex4)
            {
                ex = ex4;
            }
            catch (XmlException ex5)
            {
                ex = ex5;
            }
            catch (XPathException ex6)
            {
                ex = ex6;
            }
            if (ex != null)
            {
                StoreDriverParameters.diag.TraceError <Exception>(0L, "Failed to load parameters from storedriver config. Will use default values. Error: {0}", ex);
            }
        }
        internal static void ParseProxyLanguagePostBody(Stream bodyStream, out CultureInfo culture, out string timeZoneKeyName, out bool isOptimized, out string destination, out SerializedClientSecurityContext serializedContext)
        {
            ExTraceGlobals.ProxyCallTracer.TraceDebug(0L, "ProxyLanguagePostRequest.ParseProxyLanguagePostBody");
            culture           = null;
            timeZoneKeyName   = string.Empty;
            isOptimized       = false;
            destination       = string.Empty;
            serializedContext = null;
            XmlTextReader xmlTextReader = null;

            try
            {
                xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(bodyStream);
                xmlTextReader.WhitespaceHandling = WhitespaceHandling.All;
                if (!xmlTextReader.Read() || XmlNodeType.Element != xmlTextReader.NodeType || StringComparer.OrdinalIgnoreCase.Compare(xmlTextReader.Name, ProxyLanguagePostRequest.rootElementName) != 0)
                {
                    ProxyLanguagePostRequest.ThrowParserException(xmlTextReader, "Missing or invalid root node");
                }
                if (xmlTextReader.MoveToFirstAttribute())
                {
                    do
                    {
                        if (StringComparer.OrdinalIgnoreCase.Compare(xmlTextReader.Name, ProxyLanguagePostRequest.timeZoneKeyNameAttributeName) == 0)
                        {
                            if (DateTimeUtilities.IsValidTimeZoneKeyName(xmlTextReader.Value))
                            {
                                timeZoneKeyName = xmlTextReader.Value;
                                ExTraceGlobals.ProxyDataTracer.TraceDebug <string>(0L, "Found timeZoneKeyName={0}", timeZoneKeyName);
                            }
                            else
                            {
                                ProxyLanguagePostRequest.ThrowParserException(xmlTextReader, "Invalid time zone id");
                            }
                        }
                        else if (StringComparer.OrdinalIgnoreCase.Compare(xmlTextReader.Name, ProxyLanguagePostRequest.localeIdAttributeName) == 0)
                        {
                            int num = -1;
                            if (int.TryParse(xmlTextReader.Value, out num) && Culture.IsSupportedCulture(num))
                            {
                                culture = Culture.GetCultureInfoInstance(num);
                                ExTraceGlobals.ProxyDataTracer.TraceDebug <int>(0L, "Found localeId={0}", num);
                            }
                            else
                            {
                                ProxyLanguagePostRequest.ThrowParserException(xmlTextReader, "Invalid locale id");
                            }
                        }
                        else if (StringComparer.OrdinalIgnoreCase.Compare(xmlTextReader.Name, ProxyLanguagePostRequest.isOptimizedAttributeName) == 0)
                        {
                            int num2 = -1;
                            if (int.TryParse(xmlTextReader.Value, out num2))
                            {
                                isOptimized = (num2 == 1);
                                ExTraceGlobals.ProxyDataTracer.TraceDebug <bool>(0L, "Found isOptimized={0}", isOptimized);
                            }
                            else
                            {
                                ProxyLanguagePostRequest.ThrowParserException(xmlTextReader, "Invalid is-optimized value");
                            }
                        }
                        else if (StringComparer.OrdinalIgnoreCase.Compare(xmlTextReader.Name, ProxyLanguagePostRequest.destinationAttributeName) == 0)
                        {
                            destination = xmlTextReader.Value;
                        }
                        else
                        {
                            ExTraceGlobals.ProxyTracer.TraceDebug(0L, "ProxyLanguagePostRequest.ParseProxyLanguagePostBody - Found invalid attribute, ignoring it.");
                        }
                    }while (xmlTextReader.MoveToNextAttribute());
                }
                ExTraceGlobals.ProxyTracer.TraceDebug(0L, "Deserializing client context...");
                serializedContext = SerializedClientSecurityContext.Deserialize(xmlTextReader);
                if (!xmlTextReader.Read() || XmlNodeType.EndElement != xmlTextReader.NodeType || StringComparer.OrdinalIgnoreCase.Compare(xmlTextReader.Name, ProxyLanguagePostRequest.rootElementName) != 0)
                {
                    ProxyLanguagePostRequest.ThrowParserException(xmlTextReader, "Missing or invalid root node");
                }
            }
            catch (XmlException ex)
            {
                ProxyLanguagePostRequest.ThrowParserException(xmlTextReader, string.Format("Parser threw an XML exception: {0}", ex.Message));
            }
            finally
            {
                xmlTextReader.Close();
            }
        }
Exemplo n.º 22
0
        private static Dictionary <Guid, StoreTagData> Deserialize(Stream xmlStream, IExchangePrincipal mailboxOwner, out List <Guid> deletedTags, out RetentionHoldData retentionHoldData, bool returnRetentionHoldData, out Dictionary <Guid, StoreTagData> defaultArchiveTagData, out bool fullCrawlRequired)
        {
            fullCrawlRequired = false;
            Dictionary <Guid, StoreTagData> dictionary = new Dictionary <Guid, StoreTagData>();

            defaultArchiveTagData = new Dictionary <Guid, StoreTagData>();
            retentionHoldData     = default(RetentionHoldData);
            deletedTags           = new List <Guid>();
            if (xmlStream.Length == 0L)
            {
                MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0} has empty config message.", mailboxOwner);
                return(dictionary);
            }
            using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream))
            {
                Exception ex = null;
                try
                {
                    xmlTextReader.MoveToContent();
                    if (returnRetentionHoldData)
                    {
                        if (!xmlTextReader.ReadToFollowing("RetentionHold"))
                        {
                            MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Config item exists, but there is no RetentionHold node in it.", mailboxOwner);
                        }
                        else
                        {
                            if (xmlTextReader.MoveToAttribute("Enabled"))
                            {
                                retentionHoldData.HoldEnabled = bool.Parse(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("RetentionComment"))
                            {
                                retentionHoldData.Comment = xmlTextReader.Value;
                            }
                            if (xmlTextReader.MoveToAttribute("RetentionUrl"))
                            {
                                retentionHoldData.Url = xmlTextReader.Value;
                            }
                            MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. Config item exists, and there is a RetentionHold node in it. HoldEnabled: {1}. Comment: {2}. Url: {3}", new object[]
                            {
                                mailboxOwner,
                                retentionHoldData.HoldEnabled,
                                retentionHoldData.Comment,
                                retentionHoldData.Url
                            });
                        }
                    }
                    while (!MrmFaiFormatter.IsTagNode(xmlTextReader) && !MrmFaiFormatter.IsArchiveSyncNode(xmlTextReader) && xmlTextReader.Read())
                    {
                    }
                    if (string.CompareOrdinal(xmlTextReader.Name, "ArchiveSync") == 0)
                    {
                        if (xmlTextReader.MoveToAttribute("FullCrawlRequired"))
                        {
                            fullCrawlRequired = bool.Parse(xmlTextReader.Value);
                        }
                        while (!MrmFaiFormatter.IsTagNode(xmlTextReader))
                        {
                            if (!xmlTextReader.Read())
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Config item exists, but there is no ArchiveSync node in it.", mailboxOwner);
                    }
                    for (;;)
                    {
                        bool flag  = string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0;
                        bool flag2 = string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0;
                        bool flag3 = string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0;
                        bool flag4 = string.CompareOrdinal(xmlTextReader.Name, "DeletedTag") == 0;
                        if (!flag && !flag2 && !flag3 && !flag4)
                        {
                            break;
                        }
                        MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Found at least 1 tag in Config item.", mailboxOwner);
                        if (flag4)
                        {
                            Guid empty = System.Guid.Empty;
                            if (xmlTextReader.MoveToAttribute("Guid"))
                            {
                                empty = new Guid(xmlTextReader.Value);
                            }
                            deletedTags.Add(empty);
                            xmlTextReader.Read();
                        }
                        else
                        {
                            StoreTagData storeTagData = new StoreTagData();
                            storeTagData.Tag = new RetentionTag();
                            storeTagData.Tag.IsArchiveTag = flag2;
                            if (xmlTextReader.MoveToAttribute("ObjectGuid"))
                            {
                                storeTagData.Tag.Guid = new Guid(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("Guid"))
                            {
                                storeTagData.Tag.RetentionId = new Guid(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("Name"))
                            {
                                storeTagData.Tag.Name = xmlTextReader.Value;
                            }
                            if (xmlTextReader.MoveToAttribute("Comment"))
                            {
                                storeTagData.Tag.Comment = xmlTextReader.Value;
                            }
                            if (xmlTextReader.MoveToAttribute("Type"))
                            {
                                storeTagData.Tag.Type = (ElcFolderType)Enum.Parse(typeof(ElcFolderType), xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("MustDisplayComment"))
                            {
                                storeTagData.Tag.MustDisplayCommentEnabled = bool.Parse(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("IsVisible"))
                            {
                                storeTagData.IsVisible = bool.Parse(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("OptedInto"))
                            {
                                storeTagData.OptedInto = bool.Parse(xmlTextReader.Value);
                            }
                            xmlTextReader.Read();
                            if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedName") == 0)
                            {
                                storeTagData.Tag.LocalizedRetentionPolicyTagName = MrmFaiFormatter.ReadLocalizedStrings(xmlTextReader, "Name");
                            }
                            if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedComment") == 0)
                            {
                                storeTagData.Tag.LocalizedComment = MrmFaiFormatter.ReadLocalizedStrings(xmlTextReader, "Comment");
                            }
                            MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. Done reading the tag. Name: {1}. Type: {2}. IsVisible: {3}. OptedInto: {4}", new object[]
                            {
                                mailboxOwner,
                                storeTagData.Tag.Name,
                                storeTagData.Tag.Type,
                                storeTagData.IsVisible,
                                storeTagData.OptedInto
                            });
                            while (string.CompareOrdinal(xmlTextReader.Name, "ContentSettings") == 0)
                            {
                                ContentSetting contentSetting = new ContentSetting();
                                Guid           key;
                                if (xmlTextReader.MoveToAttribute("Guid"))
                                {
                                    key = new Guid(xmlTextReader.Value);
                                }
                                else
                                {
                                    key = default(Guid);
                                }
                                if (xmlTextReader.MoveToAttribute("ExpiryAgeLimit"))
                                {
                                    contentSetting.AgeLimitForRetention = new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays(double.Parse(xmlTextReader.Value)));
                                }
                                contentSetting.RetentionEnabled = true;
                                if (xmlTextReader.MoveToAttribute("MessageClass"))
                                {
                                    contentSetting.MessageClass = xmlTextReader.Value;
                                }
                                if (xmlTextReader.MoveToAttribute("RetentionAction"))
                                {
                                    contentSetting.RetentionAction = (RetentionActionType)Enum.Parse(typeof(RetentionActionType), xmlTextReader.Value, true);
                                }
                                storeTagData.ContentSettings[key] = contentSetting;
                                MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. Done reading the content setting. RetentionEnabled: {1}. MessageClass: {2}. RetentionAction: {3}", new object[]
                                {
                                    mailboxOwner,
                                    contentSetting.RetentionEnabled,
                                    contentSetting.MessageClass,
                                    contentSetting.RetentionAction
                                });
                                xmlTextReader.Read();
                            }
                            if (!flag3)
                            {
                                dictionary[storeTagData.Tag.RetentionId] = storeTagData;
                            }
                            else
                            {
                                defaultArchiveTagData[storeTagData.Tag.RetentionId] = storeTagData;
                            }
                        }
                        if ((string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DeletedTag") == 0) && xmlTextReader.NodeType == XmlNodeType.EndElement)
                        {
                            xmlTextReader.Read();
                        }
                    }
                    MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Found no MTA or retention or DefaultArchive or Deleted tag in Config item.", mailboxOwner);
                }
                catch (XmlException ex2)
                {
                    ex = ex2;
                }
                catch (ArgumentException ex3)
                {
                    ex = ex3;
                }
                catch (FormatException ex4)
                {
                    ex = ex4;
                }
                if (ex != null)
                {
                    xmlStream.Position = 0L;
                    string text = new StreamReader(xmlStream).ReadToEnd();
                    MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal, string, Exception>(0L, "Mailbox:{0}. Config item is corrupt. Config item: '{1}'. Exception: '{2}'", mailboxOwner, text, ex);
                    Globals.ELCLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptTagConfigItem, null, new object[]
                    {
                        mailboxOwner,
                        text,
                        ex.ToString()
                    });
                }
            }
            return(dictionary);
        }
Exemplo n.º 23
0
        internal static PolicyTagList GetPolicyTakListFromXmlStream(RetentionActionType type, Stream xmlStream, string sessionCultureName)
        {
            PolicyTagList policyTagList = new PolicyTagList();

            if (xmlStream.Length == 0L)
            {
                return(policyTagList);
            }
            using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream))
            {
                try
                {
                    xmlTextReader.MoveToContent();
                    while ((xmlTextReader.NodeType != XmlNodeType.Element || (string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") != 0 && string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") != 0 && string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") != 0)) && xmlTextReader.Read())
                    {
                    }
                    for (;;)
                    {
                        bool flag  = string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0;
                        bool flag2 = string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0;
                        if (!flag && !flag2)
                        {
                            break;
                        }
                        PolicyTag policyTag = new PolicyTag();
                        policyTag.IsArchive = flag2;
                        if (xmlTextReader.MoveToAttribute("Guid"))
                        {
                            policyTag.PolicyGuid = new Guid(xmlTextReader.Value);
                        }
                        if (xmlTextReader.MoveToAttribute("Name"))
                        {
                            policyTag.Name = xmlTextReader.Value;
                        }
                        if (xmlTextReader.MoveToAttribute("Comment"))
                        {
                            policyTag.Description = xmlTextReader.Value;
                        }
                        if (xmlTextReader.MoveToAttribute("Type"))
                        {
                            string value;
                            switch (value = xmlTextReader.Value)
                            {
                            case "Calendar":
                                policyTag.Type = ElcFolderType.Calendar;
                                goto IL_341;

                            case "Contacts":
                                policyTag.Type = ElcFolderType.Contacts;
                                goto IL_341;

                            case "DeletedItems":
                                policyTag.Type = ElcFolderType.DeletedItems;
                                goto IL_341;

                            case "Drafts":
                                policyTag.Type = ElcFolderType.Drafts;
                                goto IL_341;

                            case "Inbox":
                                policyTag.Type = ElcFolderType.Inbox;
                                goto IL_341;

                            case "JunkEmail":
                                policyTag.Type = ElcFolderType.JunkEmail;
                                goto IL_341;

                            case "Journal":
                                policyTag.Type = ElcFolderType.Journal;
                                goto IL_341;

                            case "Notes":
                                policyTag.Type = ElcFolderType.Notes;
                                goto IL_341;

                            case "Outbox":
                                policyTag.Type = ElcFolderType.Outbox;
                                goto IL_341;

                            case "SentItems":
                                policyTag.Type = ElcFolderType.SentItems;
                                goto IL_341;

                            case "Tasks":
                                policyTag.Type = ElcFolderType.Tasks;
                                goto IL_341;

                            case "All":
                                policyTag.Type = ElcFolderType.All;
                                goto IL_341;

                            case "ManagedCustomFolder":
                                policyTag.Type = ElcFolderType.ManagedCustomFolder;
                                goto IL_341;

                            case "RssSubscriptions":
                                policyTag.Type = ElcFolderType.RssSubscriptions;
                                goto IL_341;

                            case "SyncIssues":
                                policyTag.Type = ElcFolderType.SyncIssues;
                                goto IL_341;

                            case "ConversationHistory":
                                policyTag.Type = ElcFolderType.ConversationHistory;
                                goto IL_341;
                            }
                            policyTag.Type = ElcFolderType.Personal;
                        }
IL_341:
                        if (xmlTextReader.MoveToAttribute("IsVisible"))
                        {
                            policyTag.IsVisible = bool.Parse(xmlTextReader.Value);
                        }
                        if (xmlTextReader.MoveToAttribute("OptedInto"))
                        {
                            policyTag.OptedInto = bool.Parse(xmlTextReader.Value);
                        }
                        while (string.CompareOrdinal(xmlTextReader.Name, "ContentSettings") != 0 && string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") != 0 && string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") != 0)
                        {
                            if (string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0)
                            {
                                break;
                            }
                            if (!xmlTextReader.Read())
                            {
                                break;
                            }
                            if (!string.IsNullOrEmpty(sessionCultureName))
                            {
                                if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedName") == 0)
                                {
                                    xmlTextReader.Read();
                                    bool flag3 = false;
                                    while (string.CompareOrdinal(xmlTextReader.Name, "LocalizedName") != 0)
                                    {
                                        if (!flag3 && !string.IsNullOrEmpty(xmlTextReader.Value))
                                        {
                                            string stringFromLocalizedStringPair = PolicyTagList.GetStringFromLocalizedStringPair(sessionCultureName, xmlTextReader.Value);
                                            if (stringFromLocalizedStringPair != null)
                                            {
                                                policyTag.Name = stringFromLocalizedStringPair;
                                                flag3          = true;
                                            }
                                        }
                                        if (!xmlTextReader.Read())
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedComment") == 0)
                                {
                                    xmlTextReader.Read();
                                    bool flag4 = false;
                                    while (string.CompareOrdinal(xmlTextReader.Name, "LocalizedComment") != 0)
                                    {
                                        if (!flag4 && !string.IsNullOrEmpty(xmlTextReader.Value))
                                        {
                                            string stringFromLocalizedStringPair2 = PolicyTagList.GetStringFromLocalizedStringPair(sessionCultureName, xmlTextReader.Value);
                                            if (stringFromLocalizedStringPair2 != null)
                                            {
                                                policyTag.Description = stringFromLocalizedStringPair2;
                                                flag4 = true;
                                            }
                                        }
                                        if (!xmlTextReader.Read())
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        while (string.CompareOrdinal(xmlTextReader.Name, "ContentSettings") == 0)
                        {
                            if (xmlTextReader.MoveToAttribute("ExpiryAgeLimit"))
                            {
                                policyTag.TimeSpanForRetention = EnhancedTimeSpan.FromDays(double.Parse(xmlTextReader.Value));
                            }
                            if (xmlTextReader.MoveToAttribute("RetentionAction"))
                            {
                                policyTag.RetentionAction = (RetentionActionType)Enum.Parse(typeof(RetentionActionType), xmlTextReader.Value, true);
                            }
                            xmlTextReader.Read();
                        }
                        if (type == (RetentionActionType)0 || (type == RetentionActionType.MoveToArchive && flag2) || (type != (RetentionActionType)0 && type != RetentionActionType.MoveToArchive && flag))
                        {
                            policyTagList[policyTag.PolicyGuid] = policyTag;
                        }
                        if ((string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0) && xmlTextReader.NodeType == XmlNodeType.EndElement)
                        {
                            xmlTextReader.Read();
                        }
                    }
                }
                catch (XmlException ex)
                {
                }
                catch (ArgumentException ex2)
                {
                }
                catch (FormatException ex3)
                {
                }
            }
            return(policyTagList);
        }