public static SmtpAddress Decrypt(XmlElement encryptedSharingKey, SymmetricSecurityKey symmetricSecurityKey)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            try
            {
                xmlDocument.AppendChild(xmlDocument.ImportNode(encryptedSharingKey, true));
            }
            catch (XmlException)
            {
                SharingKeyHandler.Tracer.TraceError <string>(0L, "Unable to import XML element of sharing key: {0}", encryptedSharingKey.OuterXml);
                return(SmtpAddress.Empty);
            }
            EncryptedXml encryptedXml = new EncryptedXml(xmlDocument);

            encryptedXml.AddKeyNameMapping("key", symmetricSecurityKey.GetSymmetricAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"));
            try
            {
                encryptedXml.DecryptDocument();
            }
            catch (CryptographicException)
            {
                SharingKeyHandler.Tracer.TraceError <string>(0L, "Unable to decrypt XML element sharing key: {0}", encryptedSharingKey.OuterXml);
                return(SmtpAddress.Empty);
            }
            return(new SmtpAddress(xmlDocument.DocumentElement.InnerText));
        }
Example #2
0
        public MarkupParser()
        {
            SafeXmlDocument safeXmlDocument = new SafeXmlDocument();

            safeXmlDocument.LoadXml("<linkLabel></linkLabel>");
            this.xml = safeXmlDocument.DocumentElement;
        }
        // Token: 0x0600079F RID: 1951 RVA: 0x0001C338 File Offset: 0x0001A538
        internal static ResponseContent GetResponseInformation(string responseXml)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            try
            {
                xmlDocument.LoadXml(responseXml);
            }
            catch (Exception innerException)
            {
                throw new PswsProxyException(Strings.PswsResponseIsnotXMLError(responseXml), innerException);
            }
            ResponseContent     responseContent        = new ResponseContent();
            XmlNamespaceManager pswsNamespaceManager   = ObjectTransfer.GetPswsNamespaceManager(xmlDocument);
            XmlElement          xmlElementMustExisting = ObjectTransfer.GetXmlElementMustExisting(xmlDocument, "/rt:entry/rt:content/m:properties", pswsNamespaceManager);

            responseContent.Id             = ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "ID").InnerText;
            responseContent.Command        = ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Command").InnerText;
            responseContent.Status         = (ExecutionStatus)Enum.Parse(typeof(ExecutionStatus), ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Status").InnerText);
            responseContent.OutputXml      = ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Output").InnerText;
            responseContent.Error          = ObjectTransfer.GetErrorRecord(ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Errors"));
            responseContent.ExpirationTime = DateTime.Parse(ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "ExpirationTime").InnerText);
            responseContent.WaitMsec       = int.Parse(ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "WaitMsec").InnerText);
            return(responseContent);
        }
        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);
            }
        }
        protected override XmlDocument WindowsLiveIdMethod(LiveIdInstanceType liveIdInstanceType)
        {
            XmlDocument xmlDocument = null;

            using (AppIDServiceAPISoapServer appIDServiceAPISoapServer = LiveServicesHelper.ConnectToAppIDService(liveIdInstanceType))
            {
                base.WriteVerbose(Strings.AppIDServiceUrl(appIDServiceAPISoapServer.Url.ToString()));
                if (!string.IsNullOrEmpty(this.Uri))
                {
                    new Uri(this.Uri, UriKind.RelativeOrAbsolute);
                    string      text         = string.Format(GetWindowsLiveIdApplicationIdentity.AppIDFindTemplate, this.Uri);
                    string      xml          = appIDServiceAPISoapServer.FindApplication(text);
                    XmlDocument xmlDocument2 = new SafeXmlDocument();
                    xmlDocument2.LoadXml(xml);
                    XmlNode xmlNode = xmlDocument2.SelectSingleNode("AppidData/Application/ID");
                    if (xmlNode == null)
                    {
                        base.WriteVerbose(Strings.AppIdElementIsEmpty);
                        throw new LiveServicesException(Strings.AppIdElementIsEmpty);
                    }
                    base.WriteVerbose(Strings.FoundAppId(xmlNode.InnerText));
                    this.AppId = xmlNode.InnerText;
                }
                if (!string.IsNullOrEmpty(this.AppId))
                {
                    xmlDocument = new SafeXmlDocument();
                    xmlDocument.LoadXml(appIDServiceAPISoapServer.GetApplicationEntity(new tagPASSID(), this.AppId));
                }
            }
            return(xmlDocument);
        }
Example #6
0
 public static bool TryExtractDecryptionCertificateSKIFromEncryptedXml(string encryptedData, out string requiredCertificateSKI, out Exception exception)
 {
     RmsUtil.ThrowIfParameterNull(encryptedData, "encryptedData");
     requiredCertificateSKI = null;
     exception = null;
     try
     {
         XmlDocument xmlDocument = new SafeXmlDocument();
         xmlDocument.LoadXml(encryptedData);
         using (XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("X509SKI"))
         {
             if (elementsByTagName.Count > 0)
             {
                 byte[] value = Convert.FromBase64String(elementsByTagName[0].InnerText);
                 requiredCertificateSKI = BitConverter.ToString(value);
                 return(true);
             }
         }
         exception = new XmlException("X509SKI node not found in encrypted XML document");
     }
     catch (FormatException ex)
     {
         exception = ex;
     }
     catch (XmlException ex2)
     {
         exception = ex2;
     }
     return(false);
 }
    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);
    }
Example #8
0
        private string TryFormatXml(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return(content);
            }
            string result;

            try
            {
                XmlDocument xmlDocument = new SafeXmlDocument();
                xmlDocument.LoadXml(content);
                StringBuilder stringBuilder = new StringBuilder();
                using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, new XmlWriterSettings
                {
                    Indent = true,
                    Encoding = Encoding.UTF8
                }))
                {
                    xmlDocument.WriteTo(xmlWriter);
                }
                result = stringBuilder.ToString();
            }
            catch (XmlException)
            {
                result = content;
            }
            return(result);
        }
Example #9
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]);
        }
        // Token: 0x06000A7A RID: 2682 RVA: 0x00028ED0 File Offset: 0x000270D0
        internal static SafeXmlDocument GetManifest(SafeXmlDocument xmlDoc)
        {
            if (ExtensionDataHelper.xmlSchemaSet.Count == 0)
            {
                ExtensionDataHelper.xmlSchemaSet = new XmlSchemaSet();
                foreach (string text in SchemaConstants.SchemaNamespaceUriToFile.Keys)
                {
                    string schemaUri = Path.Combine(ExchangeSetupContext.InstallPath, "bin", SchemaConstants.SchemaNamespaceUriToFile[text]);
                    ExtensionDataHelper.xmlSchemaSet.Add(text, schemaUri);
                }
            }
            xmlDoc.Schemas = ExtensionDataHelper.xmlSchemaSet;
            xmlDoc.Validate(new ValidationEventHandler(ExtensionDataHelper.InvalidManifestEventHandler));
            string uri;
            string text2;

            if (!ExtensionDataHelper.TryGetOfficeAppSchemaInfo(xmlDoc, "http://schemas.microsoft.com/office/appforoffice/", out uri, out text2))
            {
                throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonManifestSchemaUnknown));
            }
            XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);

            xmlNamespaceManager.AddNamespace("owe", uri);
            SafeXmlDocument safeXmlDocument = null;
            string          xpath           = "//owe:OfficeApp";
            XmlNode         xmlNode         = xmlDoc.SelectSingleNode(xpath, xmlNamespaceManager);

            if (xmlNode != null)
            {
                safeXmlDocument = new SafeXmlDocument();
                safeXmlDocument.PreserveWhitespace = true;
                safeXmlDocument.LoadXml(xmlNode.OuterXml);
            }
            return(safeXmlDocument);
        }
Example #11
0
        // Token: 0x06000261 RID: 609 RVA: 0x0000837C File Offset: 0x0000657C
        internal XmlDocument ReadXmlDocument()
        {
            this.ReadHeader();
            XmlDocument result;

            try
            {
                bool   flag;
                bool   flag2;
                int    tag       = this.ReadTag(out flag, out flag2);
                string name      = WBXmlBase.Schema.GetName(tag);
                string nameSpace = WBXmlBase.Schema.GetNameSpace(tag);
                if (name == null || nameSpace == null)
                {
                    result = WBXmlReader.ErrorDocument;
                }
                else
                {
                    XmlDocument xmlDocument = new SafeXmlDocument();
                    bool        flag3       = WBXmlBase.Schema.IsTagSecure(tag);
                    bool        flag4       = WBXmlBase.Schema.IsTagAnOpaqueBlob(tag);
                    XmlElement  xmlElement;
                    if (flag3)
                    {
                        xmlElement = new WBXmlSecureStringNode(null, name, nameSpace, xmlDocument);
                    }
                    else if (flag4)
                    {
                        xmlElement = new WBxmlBlobNode(null, name, nameSpace, xmlDocument);
                    }
                    else
                    {
                        xmlElement = xmlDocument.CreateElement(name, nameSpace);
                    }
                    xmlDocument.AppendChild(xmlElement);
                    if (flag)
                    {
                        this.SkipAttributes();
                    }
                    if (flag2 && !this.FillXmlElement(xmlElement, 0, flag3, flag4))
                    {
                        result = WBXmlReader.ErrorDocument;
                    }
                    else
                    {
                        result = xmlDocument;
                    }
                }
            }
            catch (IndexOutOfRangeException innerException)
            {
                throw new EasWBXmlTransientException("Invalid WBXML code/codepage from client", innerException);
            }
            catch (ArgumentOutOfRangeException innerException2)
            {
                throw new EasWBXmlTransientException("Invalid WBXML code from client", innerException2);
            }
            return(result);
        }
        // Token: 0x06000D07 RID: 3335 RVA: 0x00046F88 File Offset: 0x00045188
        private XmlDocument InitializeXmlResponse()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            this.moveitemsNode = xmlDocument.CreateElement("MoveItems", "Move:");
            xmlDocument.AppendChild(this.moveitemsNode);
            return(xmlDocument);
        }
Example #13
0
        internal virtual ExtensionData GetExtensionDataForInstall(IRecipientSession adRecipientSession)
        {
            SafeXmlDocument safeXmlDocument = new SafeXmlDocument();

            safeXmlDocument.PreserveWhitespace = true;
            safeXmlDocument.LoadXml(this.ManifestXml);
            return(ExtensionData.CreateForXmlStorage(this.AppId, this.MarketplaceAssetID, this.MarketplaceContentMarket, this.Type, this.Scope, this.Enabled, this.AppVersion, DisableReasonType.NotDisabled, safeXmlDocument, this.AppStatus, this.Etoken));
        }
Example #14
0
        // Token: 0x06000CE1 RID: 3297 RVA: 0x00044C34 File Offset: 0x00042E34
        internal XmlDocument InitializeXmlResponse()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            this.meetingResponseNode = xmlDocument.CreateElement("MeetingResponse", "MeetingResponse:");
            xmlDocument.AppendChild(this.meetingResponseNode);
            return(xmlDocument);
        }
Example #15
0
 private void LoadEntityNodes(SafeXmlDocument doc, Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]> reportPropertyCmdletParamMapping)
 {
     using (XmlNodeList xmlNodeList = doc.SelectNodes("/Configuration/Reports/Report"))
     {
         HashSet <string> hashSet = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
         foreach (object obj in xmlNodeList)
         {
             XmlNode xmlNode = (XmlNode)obj;
             ReportingSchema.CheckCondition(!string.IsNullOrWhiteSpace(xmlNode.Attributes["Name"].Value) && !string.IsNullOrWhiteSpace(xmlNode.Attributes["Snapin"].Value) && !string.IsNullOrWhiteSpace(xmlNode.Attributes["Cmdlet"].Value), string.Format("Attributes {0}, {1}, {2} of entity should not be empty.", "Name", "Cmdlet", "Snapin"));
             hashSet.Add(xmlNode.Attributes["Snapin"].Value.Trim());
         }
         using (IPSCommandResolver ipscommandResolver = DependencyFactory.CreatePSCommandResolver(hashSet))
         {
             foreach (object obj2 in xmlNodeList)
             {
                 XmlNode xmlNode2   = (XmlNode)obj2;
                 string  text       = xmlNode2.Attributes["Name"].Value.Trim();
                 string  text2      = xmlNode2.Attributes["Cmdlet"].Value.Trim();
                 string  snapinName = xmlNode2.Attributes["Snapin"].Value.Trim();
                 ReportingSchema.CheckCondition(!this.entities.ContainsKey(text), "Duplicate entity in the config file");
                 Dictionary <string, string> dictionary = null;
                 using (XmlNodeList xmlNodeList2 = xmlNode2.SelectNodes("CmdletParameters/CmdletParameter"))
                 {
                     if (xmlNodeList2.Count > 0)
                     {
                         dictionary = new Dictionary <string, string>(xmlNodeList2.Count);
                         foreach (object obj3 in xmlNodeList2)
                         {
                             XmlNode xmlNode3 = (XmlNode)obj3;
                             ReportingSchema.CheckCondition(!string.IsNullOrWhiteSpace(xmlNode3.Attributes["Name"].Value) && !string.IsNullOrWhiteSpace(xmlNode3.Attributes["Value"].Value), "cmdlet parameter name and value should not be empty.");
                             string key   = xmlNode3.Attributes["Name"].Value.Trim();
                             string value = xmlNode3.Attributes["Value"].Value.Trim();
                             dictionary.Add(key, value);
                         }
                     }
                 }
                 Dictionary <string, List <string> > dictionary2 = null;
                 if (reportPropertyCmdletParamMapping.ContainsKey(text2))
                 {
                     dictionary2 = new Dictionary <string, List <string> >(reportPropertyCmdletParamMapping[text2].Length);
                     foreach (ReportingSchema.ReportPropertyCmdletParamMapping reportPropertyCmdletParamMapping2 in reportPropertyCmdletParamMapping[text2])
                     {
                         if (!dictionary2.ContainsKey(reportPropertyCmdletParamMapping2.ReportObjectProperty))
                         {
                             dictionary2.Add(reportPropertyCmdletParamMapping2.ReportObjectProperty, new List <string>());
                         }
                         dictionary2[reportPropertyCmdletParamMapping2.ReportObjectProperty].Add(reportPropertyCmdletParamMapping2.CmdletParameter);
                     }
                 }
                 XmlNode           annotationNode = ReportingSchema.SelectSingleNode(xmlNode2, "Annotation");
                 IReportAnnotation annotation     = DependencyFactory.CreateReportAnnotation(annotationNode);
                 IEntity           entity         = DependencyFactory.CreateEntity(text, new TaskInvocationInfo(text2, snapinName, dictionary), dictionary2, annotation);
                 entity.Initialize(ipscommandResolver);
                 this.entities.Add(text, entity);
             }
         }
     }
 }
Example #16
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 #17
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();
        }
        private void SetTimeZoneDefinitionHeader(Service service)
        {
            XmlDocument        xmlDocument        = new SafeXmlDocument();
            XmlElement         xmlElement         = xmlDocument.CreateElement("TimeZoneDefinitionType", "http://schemas.microsoft.com/exchange/services/2006/types");
            TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(this.clientContext.TimeZone);

            timeZoneDefinition.Render(xmlElement, "ext", "http://schemas.microsoft.com/exchange/services/2006/types", "TimeZoneDefinition", true, this.clientContext.ClientCulture ?? CultureInfo.InvariantCulture);
            service.TimeZoneDefinitionContextValue = new TimeZoneContext();
            service.TimeZoneDefinitionContextValue.TimeZoneDefinitionValue = (xmlElement.FirstChild as XmlElement);
        }
Example #19
0
 public SchemaParser(SafeXmlDocument xmlDoc, ExtensionInstallScope extensionInstallScope)
 {
     this.xmlDoc = xmlDoc;
     this.extensionInstallScope = extensionInstallScope;
     this.namespaceManager      = new XmlNamespaceManager(xmlDoc.NameTable);
     this.namespaceManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
     this.namespaceManager.AddNamespace(this.GetOweNamespacePrefix(), this.GetOweNamespaceUri());
     this.xpathPrefix = "//" + this.GetOweNamespacePrefix() + ":";
     this.oweNameSpacePrefixWithSemiColon = this.GetOweNamespacePrefix() + ":";
 }
        protected virtual XmlDocument DecryptKeyBlobXml(string encryptedXmlString)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            xmlDocument.LoadXml(encryptedXmlString);
            EncryptedXml encryptedXml = new EncryptedXml(xmlDocument);

            encryptedXml.DecryptDocument();
            this.ThrowIfKeyBlobXmlFailsSchemaValidation(xmlDocument);
            return(xmlDocument);
        }
Example #21
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);
        }
    }
        : super(securityToken, true /* addTimestamp */)
    {
        EwsUtilities.ValidateParam(securityToken, "securityToken");
        EwsUtilities.ValidateParam(securityTokenReference, "securityTokenReference");

        SafeXmlDocument doc = new SafeXmlDocument();

        doc.PreserveWhitespace = true;
        doc.LoadXml(securityTokenReference);
        this.keyInfoNode = new KeyInfoNode(doc.DocumentElement);
    }
Example #23
0
        internal static XmlNode GenerateQueryCAML(QueryFilter query)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("Query");

            if (query != null)
            {
                xmlNode.AppendChild(xmlDocument.CreateElement("Where"));
                xmlNode.ChildNodes[0].AppendChild(SharepointHelpers.GenerateQueryCAMLHelper(query, xmlDocument, 0));
            }
            return(xmlNode);
        }
Example #24
0
        public static XmlElement Decrypt(XmlElement xmlElement, SymmetricSecurityKey symmetricSecurityKey)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     newChild    = xmlDocument.ImportNode(xmlElement, true);

            xmlDocument.AppendChild(newChild);
            EncryptedXml encryptedXml = new EncryptedXml(xmlDocument);

            encryptedXml.AddKeyNameMapping("key", symmetricSecurityKey.GetSymmetricAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"));
            encryptedXml.DecryptDocument();
            return(xmlDocument.DocumentElement);
        }
        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);
        }
        // Token: 0x060009C0 RID: 2496 RVA: 0x00039620 File Offset: 0x00037820
        private XmlDocument CreateXmlResponse(object[][] folders)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlElement  xmlElement  = xmlDocument.CreateElement("Folders", "FolderHierarchy:");

            xmlDocument.AppendChild(xmlElement);
            for (int i = 0; i < folders.Length; i++)
            {
                this.WriteFolderXml(xmlDocument, xmlElement, folders[i]);
            }
            return(xmlDocument);
        }
Example #27
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 #28
0
        // Token: 0x06000493 RID: 1171 RVA: 0x0001C3D8 File Offset: 0x0001A5D8
        internal static XmlDocument ConstructErrorXml(StatusCode statusCode)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("Response", "FolderHierarchy:");
            XmlNode     xmlNode2    = xmlDocument.CreateElement("Status", "FolderHierarchy:");
            XmlNode     xmlNode3    = xmlNode2;
            int         num         = (int)statusCode;

            xmlNode3.InnerText = num.ToString(CultureInfo.InvariantCulture);
            xmlDocument.AppendChild(xmlNode);
            xmlNode.AppendChild(xmlNode2);
            return(xmlDocument);
        }
        public static XmlElement Encrypt(SmtpAddress externalId, SymmetricSecurityKey symmetricSecurityKey)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlElement  xmlElement  = xmlDocument.CreateElement("SharingKey");

            xmlElement.InnerText = externalId.ToString();
            EncryptedXml encryptedXml = new EncryptedXml();

            encryptedXml.AddKeyNameMapping("key", symmetricSecurityKey.GetSymmetricAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"));
            EncryptedData encryptedData = encryptedXml.Encrypt(xmlElement, "key");

            return(encryptedData.GetXml());
        }
Example #30
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);
        }