Example #1
0
        internal static void RegisterCounters(string installationPath)
        {
            string          filename        = Path.Combine(installationPath, "Microsoft.Exchange.Diagnostics.Service.Common.EdsPerformanceCounters.xml");
            SafeXmlDocument safeXmlDocument = new SafeXmlDocument();

            safeXmlDocument.Load(filename);
            string text = LoadEdsPerformanceCounters.ReadStringElement(safeXmlDocument, "Category/Name");

            Logger.LogInformationMessage("Found performance counter category {0}", new object[]
            {
                text
            });
            if (!LoadEdsPerformanceCounters.SafeExists(text))
            {
                Logger.LogInformationMessage("Registering EDS performance counters.", new object[0]);
                CounterCreationDataCollection counterCreationDataCollection = new CounterCreationDataCollection();
                XmlNodeList xmlNodeList = safeXmlDocument.SelectNodes("Category/Counters/Counter");
                using (xmlNodeList)
                {
                    for (int i = 0; i < xmlNodeList.Count; i++)
                    {
                        string text2 = LoadEdsPerformanceCounters.ReadStringElement(xmlNodeList[i], "Name");
                        PerformanceCounterType counterType = (PerformanceCounterType)Enum.Parse(typeof(PerformanceCounterType), LoadEdsPerformanceCounters.ReadStringElement(xmlNodeList[i], "Type"), true);
                        counterCreationDataCollection.Add(new CounterCreationData(text2, string.Empty, counterType));
                        Logger.LogInformationMessage("Loaded counter {0}", new object[]
                        {
                            text2
                        });
                    }
                }
                LoadEdsPerformanceCounters.SafeCreate(text, counterCreationDataCollection);
                return;
            }
            Logger.LogInformationMessage("Counters are already registered.", new object[0]);
        }
    void Sign(MemoryStream memoryStream)
    {
        memoryStream.Position = 0;

        SafeXmlDocument document = new SafeXmlDocument();

        document.PreserveWhitespace = true;
        document.Load(memoryStream);

        WSSecurityUtilityIdSignedXml signedXml = new WSSecurityUtilityIdSignedXml(document);

        signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;

        //signedXml.AddReference("/soap:Envelope/soap:Header/t:ExchangeImpersonation");
        signedXml.AddReference("/soap:Envelope/soap:Header/wsse:Security/wsu:Timestamp");

        signedXml.KeyInfo.AddClause(this.keyInfoNode);

        {
            signedXml.ComputeSignature(hashedAlgorithm);
        }

        XmlElement signature = signedXml.GetXml();

        XmlNode wssecurityNode = document.SelectSingleNode(
            "/soap:Envelope/soap:Header/wsse:Security",
            WSSecurityBasedCredentials.NamespaceManager);

        wssecurityNode.AppendChild(signature);

        memoryStream.Position = 0;
        document.Save(memoryStream);
    }
        private void LoadConfigFile(string configPath)
        {
            SafeXmlDocument safeXmlDocument = new SafeXmlDocument();

            if (!File.Exists(configPath))
            {
                ReportingWebServiceEventLogConstants.Tuple_LoadReportingschemaFailed.LogEvent(new object[]
                {
                    Strings.ErrorSchemaConfigurationFileMissing(configPath)
                });
                ServiceDiagnostics.ThrowError(ReportingErrorCode.ErrorSchemaInitializationFail, Strings.ErrorSchemaInitializationFail);
            }
            safeXmlDocument.Load(configPath);
            try
            {
                Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]> reportPropertyCmdletParamMapping = this.LoadRbacMapping(safeXmlDocument);
                this.LoadEntityNodes(safeXmlDocument, reportPropertyCmdletParamMapping);
            }
            catch (ReportingSchema.SchemaLoadException ex)
            {
                ReportingWebServiceEventLogConstants.Tuple_LoadReportingschemaFailed.LogEvent(new object[]
                {
                    ex.Message
                });
                ServiceDiagnostics.ThrowError(ReportingErrorCode.ErrorSchemaInitializationFail, Strings.ErrorSchemaInitializationFail, ex);
            }
        }
Example #4
0
 private void InitializeTuples()
 {
     string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
     foreach (string text in manifestResourceNames)
     {
         if (text.EndsWith("EventLog.xml"))
         {
             SafeXmlDocument safeXmlDocument = new SafeXmlDocument();
             safeXmlDocument.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream(text));
             Dictionary <string, short> dictionary = new Dictionary <string, short>();
             foreach (object obj in safeXmlDocument.SelectNodes("/root/category"))
             {
                 XmlElement xmlElement = (XmlElement)obj;
                 string     attribute  = xmlElement.GetAttribute("name");
                 short      value      = short.Parse(xmlElement.SelectSingleNode("number").InnerText);
                 dictionary.Add(attribute, value);
             }
             foreach (object obj2 in safeXmlDocument.SelectNodes("/root/data"))
             {
                 XmlElement xmlElement2 = (XmlElement)obj2;
                 string     attribute2  = xmlElement2.GetAttribute("name");
                 uint       eventId     = (uint)Enum.Parse(typeof(MSExchangeDiagnosticsEventLogConstants.Message), attribute2);
                 string     innerText   = xmlElement2.SelectSingleNode("category").InnerText;
                 string     innerText2  = xmlElement2.SelectSingleNode("stringvalue").InnerText;
                 short      categoryId  = dictionary[innerText];
                 string     innerText3  = xmlElement2.SelectSingleNode("eventtype").InnerText;
                 string     component   = string.Empty;
                 XmlNode    xmlNode     = xmlElement2.SelectSingleNode("component");
                 if (xmlNode != null)
                 {
                     component = EventLogger.FormatString(xmlNode.InnerText);
                 }
                 string  tag      = string.Empty;
                 XmlNode xmlNode2 = xmlElement2.SelectSingleNode("tag");
                 if (xmlNode2 != null)
                 {
                     tag = EventLogger.FormatString(xmlNode2.InnerText);
                 }
                 string  exception = string.Empty;
                 XmlNode xmlNode3  = xmlElement2.SelectSingleNode("exception");
                 if (xmlNode3 != null)
                 {
                     exception = EventLogger.FormatString(xmlNode3.InnerText);
                 }
                 EventLogEntryType      enumValue  = EventLogger.GetEnumValue <EventLogEntryType>(xmlElement2, "eventtype");
                 ExEventLog.EventLevel  enumValue2 = EventLogger.GetEnumValue <ExEventLog.EventLevel>(xmlElement2, "level");
                 ExEventLog.EventPeriod enumValue3 = EventLogger.GetEnumValue <ExEventLog.EventPeriod>(xmlElement2, "period");
                 ExEventLog.EventTuple  tuple      = new ExEventLog.EventTuple(eventId, categoryId, enumValue, enumValue2, enumValue3);
                 this.tuples.Add(attribute2, new EventLogger.EventData(tuple, component, tag, exception));
                 string text2 = EventLogger.FormatString(innerText2);
                 if (!TriggerHandler.Triggers.ContainsKey(attribute2))
                 {
                     TriggerHandler.Triggers.Add(attribute2, new TriggerHandler.TriggerData(innerText3, text2));
                 }
             }
         }
     }
 }
Example #5
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            string text = null;

            try
            {
                string text2 = "Exchange-" + this.ShortNameForRole + ".xml";
                string text3 = Path.Combine(ConfigurationContext.Setup.BinPath, text2);
                string text4 = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, this.ShortNameForRole + "Prereqs.log");
                string text5 = text3;
                if (this.ADToolsNeeded)
                {
                    SafeXmlDocument safeXmlDocument = new SafeXmlDocument();
                    safeXmlDocument.Load(text3);
                    XmlNode    documentElement = safeXmlDocument.DocumentElement;
                    XmlElement xmlElement      = safeXmlDocument.CreateElement("Feature", documentElement.NamespaceURI);
                    xmlElement.SetAttribute("Id", "RSAT-ADDS");
                    documentElement.AppendChild(xmlElement);
                    string text6 = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, "temp" + text2);
                    safeXmlDocument.Save(text6);
                    text5 = text6;
                    text  = text6;
                }
                base.Args = string.Concat(new string[]
                {
                    "-inputPath \"",
                    text5,
                    "\" -logPath \"",
                    text4,
                    "\""
                });
                base.InternalProcessRecord();
            }
            catch (IOException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidOperation, null);
            }
            catch (UnauthorizedAccessException exception2)
            {
                base.WriteError(exception2, ErrorCategory.SecurityError, null);
            }
            finally
            {
                if (text != null)
                {
                    try
                    {
                        File.Delete(text);
                    }
                    catch
                    {
                    }
                }
            }
            TaskLogger.LogExit();
        }
Example #6
0
    /// <summary>
    /// Helper to convert to xml dcouemnt from the current value.
    /// </summary>
    /// <param name="reader">the reader.</param>
    /// <returns>The xml document</returns>
    static SafeXmlDocument ReadToXmlDocument(EwsServiceXmlReader reader)
    {
        {
            reader.ReadBase64ElementValue(stream);
            stream.Position = 0;

            SafeXmlDocument manifest = new SafeXmlDocument();
            manifest.Load(stream);
            return(manifest);
        }
    }
        private bool UpdateSetting(string filePath)
        {
            Exception ex     = null;
            bool      result = false;

            try
            {
                SafeXmlDocument safeXmlDocument = new SafeXmlDocument();
                safeXmlDocument.Load(filePath);
                XmlNode documentElement = safeXmlDocument.DocumentElement;
                if (documentElement == null)
                {
                    TaskLogger.Trace("The aspnet.config file at {0} does not contain a root element. Skipping the file.", new object[]
                    {
                        filePath
                    });
                    return(result);
                }
                XmlNode xmlNode = documentElement.SelectSingleNode("descendant::runtime/legacyImpersonationPolicy");
                if (xmlNode == null || xmlNode.Attributes == null || xmlNode.Attributes.Count <= 0)
                {
                    TaskLogger.Trace("The aspnet.config file at {0} does not contain a valid legacyImpersonationPolicy setting. Skipping the file.", new object[]
                    {
                        filePath
                    });
                    return(result);
                }
                xmlNode.Attributes[0].Value = "false";
                safeXmlDocument.Save(filePath);
                TaskLogger.Trace("Successfully changed the legacyImpersonationPolicy setting to false in aspnet.config file at {0}.", new object[]
                {
                    filePath
                });
                result = true;
            }
            catch (XPathException ex2)
            {
                ex = ex2;
            }
            catch (XmlException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                TaskLogger.Trace("Failed to parse the aspnet.config file at {0}. Skipping the file. Exception: {1}.", new object[]
                {
                    filePath,
                    ex
                });
            }
            return(result);
        }
Example #8
0
        private void LoadPublicAgents(string filePath, out List <AgentInfo> publicAgents)
        {
            int num = 20;

            if (string.IsNullOrEmpty(filePath))
            {
                publicAgents = new List <AgentInfo>();
                return;
            }
            for (;;)
            {
                XmlDocument xmlDocument = new SafeXmlDocument();
                xmlDocument.Schemas = MExConfiguration.Schemas;
                try
                {
                    using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        xmlDocument.Load(fileStream);
                        xmlDocument.Validate(delegate(object sender, ValidationEventArgs args)
                        {
                            throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile(filePath), args.Exception);
                        });
                        this.LoadSettings(xmlDocument.SelectSingleNode("/configuration/mexRuntime/settings"));
                        this.LoadMonitoringOptions(xmlDocument.SelectSingleNode("/configuration/mexRuntime/monitoring"));
                        publicAgents = this.LoadAgentList(xmlDocument.SelectSingleNode("/configuration/mexRuntime/agentList"), false);
                    }
                }
                catch (XmlException innerException)
                {
                    throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile(filePath), innerException);
                }
                catch (FormatException innerException2)
                {
                    throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile(filePath), innerException2);
                }
                catch (UnauthorizedAccessException innerException3)
                {
                    throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile(filePath), innerException3);
                }
                catch (IOException innerException4)
                {
                    if (num <= 0)
                    {
                        throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile(filePath), innerException4);
                    }
                    num--;
                    Thread.Sleep(50);
                    continue;
                }
                break;
            }
        }
Example #9
0
        public XmlElement SerializeToXmlElement()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            using (MemoryStream memoryStream = new MemoryStream())
            {
                SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(SharedFolderData));
                safeXmlSerializer.Serialize(memoryStream, this);
                memoryStream.Seek(0L, SeekOrigin.Begin);
                xmlDocument.Load(memoryStream);
            }
            return(xmlDocument.DocumentElement);
        }
Example #10
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         string text = Path.Combine(Path.Combine(this.ExchangeInstallPath, this.XmlFileRelativePath), this.XmlFileName);
         base.WriteVerbose(Strings.VerboseTaskParameters(this.ExchangeInstallPath, this.XmlFileRelativePath, text, this.XmlNodeNameToRemove));
         SafeXmlDocument safeXmlDocument = new SafeXmlDocument();
         safeXmlDocument.Load(text);
         XmlNode xmlNode = safeXmlDocument.DocumentElement.SelectSingleNode(this.XmlNodeNameToRemove);
         if (xmlNode != null)
         {
             safeXmlDocument.DocumentElement.RemoveChild(xmlNode);
             safeXmlDocument.Save(text);
         }
     }
     catch (XmlException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidOperation, null);
     }
     catch (XPathException exception2)
     {
         base.WriteError(exception2, ErrorCategory.InvalidOperation, null);
     }
     catch (IOException exception3)
     {
         base.WriteError(exception3, ErrorCategory.InvalidOperation, null);
     }
     catch (UnauthorizedAccessException exception4)
     {
         base.WriteError(exception4, ErrorCategory.InvalidOperation, null);
     }
     catch (NotSupportedException exception5)
     {
         base.WriteError(exception5, ErrorCategory.InvalidOperation, null);
     }
     catch (SecurityException exception6)
     {
         base.WriteError(exception6, ErrorCategory.InvalidOperation, null);
     }
     catch (ArgumentException exception7)
     {
         base.WriteError(exception7, ErrorCategory.InvalidArgument, null);
     }
     TaskLogger.LogExit();
 }
        public ObjectSchemaLoader(DataDrivenCategory dataDrivenCategory, string xPath, string schema)
        {
            Stream          manifestResource = WinformsHelper.GetManifestResource(dataDrivenCategory);
            SafeXmlDocument safeXmlDocument  = new SafeXmlDocument();

            safeXmlDocument.Load(manifestResource);
            foreach (object obj in safeXmlDocument.SelectNodes(xPath))
            {
                XmlNode xmlNode   = (XmlNode)obj;
                XmlNode namedItem = xmlNode.Attributes.GetNamedItem("Name");
                if (namedItem.Value.Equals(schema))
                {
                    this.objectDefinition = xmlNode;
                    break;
                }
            }
        }
Example #12
0
 private void LoadInternalAgents(out List <AgentInfo> preExecutionInternalAgents, out List <AgentInfo> postExecutionInternalAgents)
 {
     preExecutionInternalAgents  = new List <AgentInfo>();
     postExecutionInternalAgents = new List <AgentInfo>();
     try
     {
         XmlDocument xmlDocument = new SafeXmlDocument();
         xmlDocument.Schemas = MExConfiguration.InternalSchemas;
         Assembly executingAssembly = Assembly.GetExecutingAssembly();
         using (Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("internalAgents.config"))
         {
             xmlDocument.Load(manifestResourceStream);
             xmlDocument.Validate(delegate(object sender, ValidationEventArgs args)
             {
                 throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile("internalAgents.config"), args.Exception);
             });
             string xmlMarkups = this.GetXmlMarkups(this.exchangeSku, this.transportProcessRole);
             if (xmlMarkups != null)
             {
                 preExecutionInternalAgents  = this.LoadAgentList(xmlDocument.SelectSingleNode("/internalConfiguration/internalMexRuntime/" + xmlMarkups + "/preExecution"), true);
                 postExecutionInternalAgents = this.LoadAgentList(xmlDocument.SelectSingleNode("/internalConfiguration/internalMexRuntime/" + xmlMarkups + "/postExecution"), true);
             }
         }
     }
     catch (XmlException innerException)
     {
         throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile("internalAgents.config"), innerException);
     }
     catch (UnauthorizedAccessException innerException2)
     {
         throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile("internalAgents.config"), innerException2);
     }
     catch (IOException innerException3)
     {
         throw new ExchangeConfigurationException(MExRuntimeStrings.InvalidConfigurationFile("internalAgents.config"), innerException3);
     }
 }
Example #13
0
 private static Uri GetRootSiteUrlFromServiceInfo(AADClient aadClient)
 {
     string[] array = null;
     try
     {
         array = aadClient.GetServiceInfo("SharePoint/");
     }
     catch (AADException arg)
     {
         SharePointUrl.Tracer.TraceError <AADException>(0L, "GetServiceInfo failed: {0}", arg);
     }
     if (array == null)
     {
         return(null);
     }
     foreach (string s in array)
     {
         using (StringReader stringReader = new StringReader(s))
         {
             try
             {
                 XmlDocument xmlDocument = new SafeXmlDocument();
                 xmlDocument.Load(stringReader);
                 Uri rootSiteUrlFromServiceInfo = ServiceInfoParser.GetRootSiteUrlFromServiceInfo(xmlDocument, SharePointUrl.Tracer);
                 if (rootSiteUrlFromServiceInfo != null && !string.IsNullOrWhiteSpace(rootSiteUrlFromServiceInfo.ToString()))
                 {
                     return(rootSiteUrlFromServiceInfo);
                 }
             }
             catch (XmlException arg2)
             {
                 SharePointUrl.Tracer.TraceError <XmlException>(0L, "Failed to get SPO_RootSiteUrl from ServiceInfo: {0}", arg2);
             }
         }
     }
     return(null);
 }
        // Token: 0x06000AF8 RID: 2808 RVA: 0x000474D0 File Offset: 0x000456D0
        protected override void BuildSmsMessage()
        {
            string text = string.Empty;

            base.BuildSmsMessage();
            int num = base.RemainingChar;

            if (num <= 0)
            {
                return;
            }
            try
            {
                string text2;
                if (ObjectClass.IsOfClass(base.Item.ClassName, "IPM.Note.rpmsg.Microsoft.Voicemail.UM.CA") || ObjectClass.IsOfClass(base.Item.ClassName, "IPM.Note.rpmsg.Microsoft.Voicemail.UM"))
                {
                    text2 = Strings.SMSProtectedVoicemail.ToString(base.GetMailboxCulture());
                }
                else
                {
                    using (Stream stream = base.Item.OpenPropertyStream(MessageItemSchema.AsrData, PropertyOpenMode.ReadOnly))
                    {
                        using (StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
                        {
                            XmlDocument xmlDocument = new SafeXmlDocument();
                            xmlDocument.Load(streamReader);
                            XmlNode documentElement         = xmlDocument.DocumentElement;
                            float   transcriptionConfidence = SmsVoicemailNotification.GetTranscriptionConfidence(documentElement);
                            text2 = ((transcriptionConfidence > 0.3f) ? this.RenderVoiceMailPreview(documentElement) : Strings.SMSLowConfidenceTranscription.ToString(base.GetMailboxCulture()));
                            ExTraceGlobals.MWITracer.TraceDebug <float, string>((long)this.GetHashCode(), "Confidence: {0}. Text: {1}", transcriptionConfidence, text2);
                        }
                    }
                }
                num--;
                if (text2.Length > num)
                {
                    num -= "...".Length;
                    if (num > 0)
                    {
                        text  = " ";
                        text += text2.Substring(0, num);
                        text += "...";
                    }
                }
                else
                {
                    text  = " ";
                    text += text2;
                }
                base.Body += text;
            }
            catch (ObjectNotFoundException ex)
            {
                ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "ObjectNotFoundException occured while trying to add EVM Text to the SMS. Exception: {0}", ex.Message);
            }
            catch (IOException ex2)
            {
                ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "IOException occured while trying to add EVM Text to the SMS. Exception: {0}", ex2.Message);
            }
            catch (XmlException ex3)
            {
                ExTraceGlobals.MWITracer.TraceDebug <string>((long)this.GetHashCode(), "XmlException occured while trying to add EVM Text to the SMS. Exception: {0}", ex3.Message);
            }
        }
Example #15
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);
            }
        }
Example #16
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            SafeXmlDocument safeXmlDocument = new SafeXmlDocument();

            try
            {
                int num = 0;
                try
                {
IL_0D:
                    safeXmlDocument.Load(this.ConfigFileFullPath);
                    XmlElement xmlElement = this.FindOrCreateElement(safeXmlDocument, base.ParameterSetName != "Remove");
                    if (xmlElement == null)
                    {
                        if (base.ParameterSetName == "Remove")
                        {
                            this.WriteWarning(Strings.ElementNotFound(this.Element));
                        }
                        return;
                    }
                    string parameterSetName;
                    if ((parameterSetName = base.ParameterSetName) != null)
                    {
                        if (parameterSetName == "AppSettingKey")
                        {
                            this.AddAppSettingEntry(xmlElement);
                            goto IL_F3;
                        }
                        if (parameterSetName == "Attribute")
                        {
                            this.AddAttribute(xmlElement);
                            goto IL_F3;
                        }
                        if (parameterSetName == "ListValues")
                        {
                            this.AddListValues(xmlElement);
                            goto IL_F3;
                        }
                        if (parameterSetName == "Remove")
                        {
                            this.RemoveElementOrAppSettingEntry(xmlElement);
                            goto IL_F3;
                        }
                        if (parameterSetName == "XmlNode")
                        {
                            this.SetXmlNode(safeXmlDocument, xmlElement);
                            goto IL_F3;
                        }
                    }
                    base.WriteError(new InvalidOperationException("invalid parameter set name"), (ErrorCategory)1003, null);
IL_F3:
                    safeXmlDocument.Save(this.ConfigFileFullPath);
                }
                catch (IOException exception)
                {
                    num++;
                    if (num > 3)
                    {
                        base.WriteError(exception, (ErrorCategory)1003, null);
                    }
                    else
                    {
                        this.WriteWarning(Strings.AppConfigIOException(this.ConfigFileFullPath, 3, 3));
                        Thread.Sleep(3000);
                    }
                    goto IL_0D;
                }
            }
            catch (XmlException exception2)
            {
                base.WriteError(exception2, (ErrorCategory)1003, null);
            }
            catch (ArgumentException exception3)
            {
                base.WriteError(exception3, (ErrorCategory)1003, null);
            }
            catch (UnauthorizedAccessException exception4)
            {
                base.WriteError(exception4, (ErrorCategory)1003, null);
            }
            catch (NotSupportedException exception5)
            {
                base.WriteError(exception5, (ErrorCategory)1003, null);
            }
            catch (SecurityException exception6)
            {
                base.WriteError(exception6, (ErrorCategory)1003, null);
            }
            TaskLogger.LogExit();
        }
        // Token: 0x06000BB5 RID: 2997 RVA: 0x0002FB58 File Offset: 0x0002DD58
        protected override void ParseResponse(byte[] responseBuffer, int responseBufferSize)
        {
            Dictionary <string, string> dictionary  = new Dictionary <string, string>();
            Dictionary <string, string> dictionary2 = new Dictionary <string, string>();

            try
            {
                using (MemoryStream memoryStream = new MemoryStream(responseBuffer, 0, responseBuffer.Length))
                {
                    SafeXmlDocument safeXmlDocument = new SafeXmlDocument();
                    safeXmlDocument.PreserveWhitespace = true;
                    safeXmlDocument.Load(memoryStream);
                    XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(safeXmlDocument.NameTable);
                    xmlNamespaceManager.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
                    XmlNodeList xmlNodeList = safeXmlDocument.SelectNodes("/o:assets/o:asset", xmlNamespaceManager);
                    foreach (object obj in xmlNodeList)
                    {
                        XmlNode xmlNode = (XmlNode)obj;
                        string  attributeStringValue  = ExtensionData.GetAttributeStringValue(xmlNode, "o:cm");
                        string  attributeStringValue2 = ExtensionData.GetAttributeStringValue(xmlNode, "o:assetid");
                        string  value = HttpUtility.UrlEncode(HttpUtility.HtmlDecode(ExtensionData.GetAttributeStringValue(xmlNode, "o:etok")));
                        bool    flag  = false;
                        string  optionalAttributeStringValue = ExtensionData.GetOptionalAttributeStringValue(xmlNode, "o:status", string.Empty);
                        foreach (TokenRenewRequestAsset tokenRenewRequestAsset in this.extensionTokenRenewList)
                        {
                            if (string.Equals(tokenRenewRequestAsset.MarketplaceAssetID, attributeStringValue2, StringComparison.OrdinalIgnoreCase) && string.Equals(tokenRenewRequestAsset.MarketplaceContentMarket, attributeStringValue, StringComparison.OrdinalIgnoreCase))
                            {
                                tokenRenewRequestAsset.IsResponseFound = true;
                                if ("1".Equals(optionalAttributeStringValue, StringComparison.OrdinalIgnoreCase))
                                {
                                    dictionary.Add(tokenRenewRequestAsset.ExtensionID, value);
                                }
                                else if ("6".Equals(optionalAttributeStringValue, StringComparison.OrdinalIgnoreCase))
                                {
                                    dictionary2.Add(tokenRenewRequestAsset.ExtensionID, "2.1");
                                }
                                else
                                {
                                    dictionary2.Add(tokenRenewRequestAsset.ExtensionID, "2.0");
                                }
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            BaseAsyncCommand.Tracer.TraceError <string, string, string>(0L, "The returned token does not match the asset and marketplace in the request. Asset id: {0} Marketplace: {1} Status code: {2}.", attributeStringValue2, attributeStringValue, optionalAttributeStringValue);
                            ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_MismatchedReturnedToken, attributeStringValue2, new object[]
                            {
                                this.scenario,
                                this.requestId,
                                base.GetLoggedMailboxIdentifier(),
                                attributeStringValue2,
                                attributeStringValue,
                                optionalAttributeStringValue
                            });
                        }
                    }
                    foreach (TokenRenewRequestAsset tokenRenewRequestAsset2 in this.extensionTokenRenewList)
                    {
                        if (!tokenRenewRequestAsset2.IsResponseFound)
                        {
                            dictionary2.Add(tokenRenewRequestAsset2.ExtensionID, "2.0");
                        }
                    }
                }
            }
            catch (XmlException exception)
            {
                this.InternalFailureCallback(exception, null);
                return;
            }
            base.LogResponseParsed();
            this.successCallback(dictionary, dictionary2);
        }