Ejemplo n.º 1
0
 // Token: 0x0600001B RID: 27 RVA: 0x0000220C File Offset: 0x0000040C
 public string ObjectToXml(object obj, out Exception ex)
 {
     ex = null;
     if (obj == null)
     {
         return(null);
     }
     try
     {
         using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
         {
             XmlSerializer xmlSerializer = new SafeXmlSerializer(obj.GetType());
             xmlSerializer.Serialize(stringWriter, obj);
             return(stringWriter.ToString());
         }
     }
     catch (InvalidOperationException ex2)
     {
         ex = ex2;
     }
     catch (IOException ex3)
     {
         ex = ex3;
     }
     return(null);
 }
        // Token: 0x060009BF RID: 2495 RVA: 0x00025E50 File Offset: 0x00024050
        internal string Serialize()
        {
            if (this.ImageBase64 == null)
            {
                this.ImageBase64 = string.Empty;
            }
            if (this.EmailText == null)
            {
                this.EmailText = string.Empty;
            }
            if (this.PortalText == null)
            {
                this.PortalText = string.Empty;
            }
            if (this.DisclaimerText == null)
            {
                this.DisclaimerText = string.Empty;
            }
            string result;

            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(base.GetType());
                safeXmlSerializer.Serialize(stringWriter, this);
                stringWriter.Flush();
                result = stringWriter.ToString();
            }
            return(result);
        }
Ejemplo n.º 3
0
 // Token: 0x0600001D RID: 29 RVA: 0x000022B4 File Offset: 0x000004B4
 public object XmlToObject(string xmlText, Type objType, out Exception ex)
 {
     ex = null;
     if (xmlText == null || xmlText.Length == 0)
     {
         return(null);
     }
     try
     {
         using (StringReader stringReader = new StringReader(xmlText))
         {
             XmlSerializer xmlSerializer = new SafeXmlSerializer(objType);
             return(xmlSerializer.Deserialize(stringReader));
         }
     }
     catch (InvalidOperationException ex2)
     {
         ex = ex2;
     }
     catch (IOException ex3)
     {
         ex = ex3;
     }
     return(null);
 }
Ejemplo n.º 4
0
        // Token: 0x06000166 RID: 358 RVA: 0x00006518 File Offset: 0x00004718
        protected void LoadDetailSchemaMappings(MasterSchemaMappingEntry masterSchemaMappingEntry)
        {
            ExTraceGlobals.SchemaManagerTracer.Information <string>((long)this.GetHashCode(), "SchemaManager::LoadDetailSchemaMappings - retrieving info from detail schema mapping XML file {0}.", (masterSchemaMappingEntry == null) ? "null" : masterSchemaMappingEntry.SchemaFileName);
            string schemaFileName = masterSchemaMappingEntry.SchemaFileName;

            this.schemaMappingEntryArray = (SchemaMappingEntry[])SchemaManager.schemaMappingEntryArrayHashTable[schemaFileName];
            if (this.schemaMappingEntryArray == null)
            {
                lock (typeof(SchemaManager))
                {
                    string   dataSourceManagerAssemblyName = masterSchemaMappingEntry.DataSourceManagerAssemblyName;
                    Assembly assembly = (Assembly)SchemaManager.dsmAssemblyHashTable[dataSourceManagerAssemblyName];
                    if (null == assembly)
                    {
                        string assemblyString = dataSourceManagerAssemblyName;
                        if (Path.GetExtension(dataSourceManagerAssemblyName).ToLower() == ".dll")
                        {
                            assemblyString = Path.GetFileNameWithoutExtension(dataSourceManagerAssemblyName);
                        }
                        try
                        {
                            assembly = Assembly.Load(assemblyString);
                        }
                        catch (FileNotFoundException)
                        {
                        }
                        if (assembly == null)
                        {
                            string assemblyFile = Path.Combine(ConfigurationContext.Setup.BinPath, dataSourceManagerAssemblyName);
                            assembly = Assembly.LoadFrom(assemblyFile);
                        }
                        SchemaManager.dsmAssemblyHashTable[dataSourceManagerAssemblyName] = assembly;
                    }
                    List <Type> list = new List <Type>();
                    foreach (Type type in assembly.GetTypes())
                    {
                        if (type.IsSubclassOf(typeof(SchemaMappingEntry)))
                        {
                            list.Add(type);
                        }
                    }
                    Assembly executingAssembly = Assembly.GetExecutingAssembly();
                    foreach (Type type2 in executingAssembly.GetTypes())
                    {
                        if (type2.IsSubclassOf(typeof(SchemaMappingEntry)))
                        {
                            list.Add(type2);
                        }
                    }
                    Type[]            extraTypes        = list.ToArray();
                    SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(SchemaMappingEntry[]), extraTypes);
                    Stream            schemaXmlDocument = SchemaManager.GetSchemaXmlDocument(masterSchemaMappingEntry.SchemaFileName);
                    using (schemaXmlDocument)
                    {
                        this.schemaMappingEntryArray = (SchemaMappingEntry[])safeXmlSerializer.Deserialize(schemaXmlDocument);
                        SchemaManager.schemaMappingEntryArrayHashTable[masterSchemaMappingEntry.SchemaFileName] = this.schemaMappingEntryArray;
                    }
                }
            }
        }
            public override void GenerateRequest(string url, string emailAddress, Stream requestStream)
            {
                SafeXmlSerializer      safeXmlSerializer = new SafeXmlSerializer(typeof(AutoDiscoverRequestXML));
                AutoDiscoverRequestXML o = AutoDiscoverRequestXML.NewRequest(emailAddress);

                safeXmlSerializer.Serialize(requestStream, o);
            }
Ejemplo n.º 6
0
        private HttpWebRequest SendRequest(ICredentials credentials)
        {
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(this.url);

            AutoDiscoverClient.AddOutlook14Cookie(httpWebRequest);
            httpWebRequest.Method          = "POST";
            httpWebRequest.ContentType     = "text/xml; charset=utf-8";
            httpWebRequest.Credentials     = credentials;
            httpWebRequest.PreAuthenticate = true;
            httpWebRequest.Headers.Set(HttpRequestHeader.Pragma, "no-cache");
            foreach (string text in this.additionalHeaders.Keys)
            {
                httpWebRequest.Headers.Add(text, this.additionalHeaders[text]);
            }
            httpWebRequest.UserAgent = string.Format("{0}/{1}/{2}", Environment.MachineName, this.componentId, this.emailAddress);
            CertificateValidationManager.SetComponentId(httpWebRequest, this.componentId);
            this.TraceHeaders(httpWebRequest.Headers);
            using (Stream requestStream = httpWebRequest.GetRequestStream())
            {
                SafeXmlSerializer      safeXmlSerializer = new SafeXmlSerializer(typeof(AutoDiscoverRequestXML));
                AutoDiscoverRequestXML o = AutoDiscoverRequestXML.NewRequest(this.emailAddress);
                safeXmlSerializer.Serialize(requestStream, o);
            }
            return(httpWebRequest);
        }
Ejemplo n.º 7
0
        private AutoDiscoverResponseXML GetResponse(WebResponse response)
        {
            this.TraceHeaders(response.Headers);
            AutoDiscoverResponseXML result;

            using (Stream responseStream = response.GetResponseStream())
            {
                try
                {
                    SafeXmlSerializer       safeXmlSerializer       = new SafeXmlSerializer(typeof(AutoDiscoverResponseXML));
                    AutoDiscoverResponseXML autoDiscoverResponseXML = safeXmlSerializer.Deserialize(responseStream) as AutoDiscoverResponseXML;
                    if (this.url.StartsWith("http:", StringComparison.OrdinalIgnoreCase))
                    {
                        this.TraceVerbose(Strings.TowsDomainNotSsl(this.url));
                    }
                    result = autoDiscoverResponseXML;
                }
                catch (InvalidOperationException ex)
                {
                    if (ex.InnerException == null || !(ex.InnerException is XmlException))
                    {
                        throw;
                    }
                    result = null;
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        public static SharedFolderData DeserializeFromXmlELement(XmlElement xmlElement)
        {
            new SharedFolderData();
            XmlNodeReader     reader            = new XmlNodeReader(xmlElement);
            SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(SharedFolderData));

            return(safeXmlSerializer.Deserialize(reader) as SharedFolderData);
        }
Ejemplo n.º 9
0
        public static RpcAssociationReplicatorRunNowParameters Parse(string input, IRecipientSession adSession)
        {
            SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(List <MailboxLocatorType>));
            RpcAssociationReplicatorRunNowParameters result;

            using (StringReader stringReader = new StringReader(input))
            {
                List <MailboxLocatorType> locators = safeXmlSerializer.Deserialize(stringReader) as List <MailboxLocatorType>;
                result = RpcAssociationReplicatorRunNowParameters.Instantiate(locators, adSession);
            }
            return(result);
        }
        // Token: 0x060009C0 RID: 2496 RVA: 0x00025EF4 File Offset: 0x000240F4
        internal static EncryptionConfigurationData Deserialize(string serializedXML)
        {
            EncryptionConfigurationData result;

            using (StringReader stringReader = new StringReader(serializedXML))
            {
                SafeXmlSerializer           safeXmlSerializer           = new SafeXmlSerializer(typeof(EncryptionConfigurationData));
                EncryptionConfigurationData encryptionConfigurationData = (EncryptionConfigurationData)safeXmlSerializer.Deserialize(stringReader);
                result = encryptionConfigurationData;
            }
            return(result);
        }
Ejemplo n.º 11
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);
        }
        private static TrustedDocDomain DecryptTrustedDocDomainData(EncryptedTrustedDocDomain encryptedData, SecureString password)
        {
            IPrivateKeyDecryptor privateKeyDecryptor = new OnPremisePrivateKeyDecryptor(password);

            byte[] buffer = null;
            try
            {
                buffer = privateKeyDecryptor.Decrypt(encryptedData.m_strTrustedDocDomainInfo);
            }
            catch (PrivateKeyDecryptionFailedException innerException)
            {
                throw new TrustedPublishingDomainParser.ParseFailedException("OnPremisePrivateKeyDecryptor.Decrypt() failed", innerException);
            }
            TrustedDocDomain result;

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                try
                {
                    SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(ArrayList), new Type[]
                    {
                        typeof(TrustedDocDomain[])
                    });
                    ArrayList arrayList = safeXmlSerializer.Deserialize(memoryStream) as ArrayList;
                    if (arrayList == null || arrayList.Count != 1)
                    {
                        throw new TrustedPublishingDomainParser.ParseFailedException("DecryptedTPD_NoORMoreThanOneElements");
                    }
                    TrustedDocDomain trustedDocDomain = arrayList[0] as TrustedDocDomain;
                    if (trustedDocDomain == null)
                    {
                        throw new TrustedPublishingDomainParser.ParseFailedException("DecryptedTPD_NotOfType_TrustedDocDomain");
                    }
                    trustedDocDomain.m_ttdki.strEncryptedPrivateKey = encryptedData.m_strKeyData;
                    result = trustedDocDomain;
                }
                catch (InvalidOperationException innerException2)
                {
                    throw new TrustedPublishingDomainParser.ParseFailedException("DecryptedTPD_XmlDeserializationFailed", innerException2);
                }
                catch (XmlException innerException3)
                {
                    throw new TrustedPublishingDomainParser.ParseFailedException("DecryptedTPD_XmlDeserializationFailed", innerException3);
                }
            }
            return(result);
        }
        // Token: 0x060001D5 RID: 469 RVA: 0x0000BCF4 File Offset: 0x00009EF4
        public static string ToString <T>(object data)
        {
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent             = true,
                OmitXmlDeclaration = true,
                CheckCharacters    = false
            };
            StringBuilder stringBuilder = new StringBuilder();

            using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, settings))
            {
                SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(T));
                safeXmlSerializer.Serialize(xmlWriter, data);
            }
            return(stringBuilder.ToString());
        }
        public static TrustedDocDomain Parse(SecureString password, byte[] rawData)
        {
            if (password == null)
            {
                throw new ArgumentNullException("password");
            }
            if (rawData == null || rawData.Length == 0)
            {
                throw new ArgumentNullException("rawData");
            }
            EncryptedTrustedDocDomain encryptedTrustedDocDomain = null;

            using (MemoryStream memoryStream = new MemoryStream(rawData))
            {
                try
                {
                    SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(ArrayList), new Type[]
                    {
                        typeof(EncryptedTrustedDocDomain[])
                    });
                    ArrayList arrayList = safeXmlSerializer.Deserialize(memoryStream) as ArrayList;
                    if (arrayList == null || arrayList.Count != 1)
                    {
                        throw new TrustedPublishingDomainParser.ParseFailedException("EncryptedTPD_NoOrMoreThanOneElementsIn");
                    }
                    encryptedTrustedDocDomain = (arrayList[0] as EncryptedTrustedDocDomain);
                    if (encryptedTrustedDocDomain == null)
                    {
                        throw new TrustedPublishingDomainParser.ParseFailedException("EncryptedTPD_NotOfType_EncryptedTrustedDocDomain");
                    }
                }
                catch (InvalidOperationException innerException)
                {
                    throw new TrustedPublishingDomainParser.ParseFailedException("EncryptedTPD_XmlDeserializationFailed", innerException);
                }
                catch (XmlException innerException2)
                {
                    throw new TrustedPublishingDomainParser.ParseFailedException("EncryptedTPD_XmlDeserializationFailed", innerException2);
                }
            }
            if (string.IsNullOrEmpty(encryptedTrustedDocDomain.m_strTrustedDocDomainInfo))
            {
                throw new TrustedPublishingDomainParser.ParseFailedException("EncryptedTPD_NoTrustedDocDomainInfo");
            }
            return(TrustedPublishingDomainParser.DecryptTrustedDocDomainData(encryptedTrustedDocDomain, password));
        }
Ejemplo n.º 15
0
        private void OnSerializeCustomSoapHeaders(XmlWriter writer)
        {
            object obj = null;

            if (this.logonType != null)
            {
                obj = EwsHelper.CreateSpecialLogonAuthenticationHeader(this.Mailbox, this.logonType.Value, this.budgetType, this.RequiredServerVersion);
            }
            else if (this.securityAccessToken != null)
            {
                obj = EwsHelper.CreateSerializedSecurityContext(this.Mailbox, this.securityAccessToken);
            }
            if (obj != null)
            {
                SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(obj.GetType());
                safeXmlSerializer.Serialize(writer, obj);
            }
        }
Ejemplo n.º 16
0
        public override string ToString()
        {
            List <MailboxLocatorType> list = new List <MailboxLocatorType>(this.SlaveMailboxes.Count);

            foreach (IMailboxLocator locator in this.SlaveMailboxes)
            {
                list.Add(EwsAssociationDataConverter.Convert(locator));
            }
            SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(list.GetType());
            string            result;

            using (StringWriter stringWriter = new StringWriter())
            {
                safeXmlSerializer.Serialize(stringWriter, list);
                result = stringWriter.ToString();
            }
            return(result);
        }
Ejemplo n.º 17
0
 public static string Initialize(TextReader reader)
 {
     if (!SuppressingPiiProperty.Initialized)
     {
         lock (SuppressingPiiProperty.syncObject)
         {
             if (!SuppressingPiiProperty.Initialized)
             {
                 SuppressingPiiProperty.Initialized = true;
                 SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(typeof(SuppressingPiiConfig));
                 SuppressingPiiProperty.piiDataRedaction = (SuppressingPiiConfig)safeXmlSerializer.Deserialize(reader);
             }
         }
     }
     if (SuppressingPiiProperty.piiDataRedaction != null)
     {
         return(SuppressingPiiProperty.piiDataRedaction.DeserializationError);
     }
     return(null);
 }
Ejemplo n.º 18
0
            public override Exception ValidateResponse(Stream responseStream, out string ewsUrl, out string oabUrl)
            {
                ewsUrl = null;
                oabUrl = null;
                SafeXmlSerializer       safeXmlSerializer       = new SafeXmlSerializer(typeof(AutoDiscoverResponseXML));
                AutoDiscoverResponseXML autoDiscoverResponseXML = null;
                XDocument xdocument = null;

                try
                {
                    autoDiscoverResponseXML = (AutoDiscoverResponseXML)safeXmlSerializer.Deserialize(responseStream);
                    responseStream.Seek(0L, SeekOrigin.Begin);
                    using (StreamReader streamReader = new StreamReader(responseStream))
                    {
                        xdocument = XDocument.Load(streamReader);
                    }
                }
                catch (XmlException innerException)
                {
                    return(new ServiceValidatorException(Strings.ErrorInvalidResponseFormat, innerException));
                }
                if (autoDiscoverResponseXML.ErrorResponse != null)
                {
                    if (autoDiscoverResponseXML.ErrorResponse.Error == null)
                    {
                        return(new ServiceValidatorException(Strings.ErrorInvalidResponseXml(xdocument.ToString())));
                    }
                    return(new ServiceValidatorException(Strings.ErrorResponseContainsError(autoDiscoverResponseXML.ErrorResponse.Error.ErrorCode, autoDiscoverResponseXML.ErrorResponse.Error.Message)));
                }
                else
                {
                    if (autoDiscoverResponseXML.DataResponse == null || autoDiscoverResponseXML.DataResponse.Account == null || autoDiscoverResponseXML.DataResponse.Account.Action == null)
                    {
                        return(new ServiceValidatorException(Strings.ErrorInvalidResponseXml(xdocument.ToString())));
                    }
                    if (autoDiscoverResponseXML.DataResponse.Account.Action.Equals("redirectAddr", StringComparison.OrdinalIgnoreCase))
                    {
                        string redirectAddr = autoDiscoverResponseXML.DataResponse.Account.RedirectAddr;
                        return(new ServiceValidatorException(Strings.ErrorAutoDiscoverValidatorRequiresRedirection(redirectAddr)));
                    }
                    if (autoDiscoverResponseXML.DataResponse.Account.Protocol == null)
                    {
                        return(new ServiceValidatorException(Strings.ErrorInvalidResponseXml(xdocument.ToString())));
                    }
                    AutoDiscoverProtocol[] protocol = autoDiscoverResponseXML.DataResponse.Account.Protocol;
                    string[] array = new string[]
                    {
                        "EXCH",
                        "EXPR"
                    };
                    for (int i = 0; i < array.Length; i++)
                    {
                        string protocolType = array[i];
                        AutoDiscoverProtocol autoDiscoverProtocol = Array.Find <AutoDiscoverProtocol>(protocol, (AutoDiscoverProtocol p) => p.Type.Equals(protocolType, StringComparison.OrdinalIgnoreCase));
                        if (autoDiscoverProtocol != null)
                        {
                            if (!string.IsNullOrEmpty(autoDiscoverProtocol.EwsUrl))
                            {
                                ewsUrl = autoDiscoverProtocol.EwsUrl;
                            }
                            if (!string.IsNullOrEmpty(autoDiscoverProtocol.OABUrl))
                            {
                                oabUrl = autoDiscoverProtocol.OABUrl;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(ewsUrl))
                    {
                        return(new ServiceValidatorException(Strings.ErrorAutoDiscoverValidatorEwsNotFound(xdocument.ToString())));
                    }
                    if (string.IsNullOrEmpty(oabUrl))
                    {
                        return(new ServiceValidatorException(Strings.ErrorAutoDiscoverValidatorOabNotFound(xdocument.ToString())));
                    }
                    return(null);
                }
                Exception result;

                return(result);
            }
Ejemplo n.º 19
0
        // Token: 0x060001A1 RID: 417 RVA: 0x0000B7BC File Offset: 0x000099BC
        private static void Serialize(Type type, object content, XmlWriter writer)
        {
            SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(type);

            safeXmlSerializer.Serialize(writer, content);
        }
Ejemplo n.º 20
0
        // Token: 0x060001A0 RID: 416 RVA: 0x0000B7A0 File Offset: 0x000099A0
        public static object Deserialize(Type type, XmlReader xmlReader)
        {
            SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(type);

            return(safeXmlSerializer.Deserialize(xmlReader));
        }