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
        // 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);
        }
Example #3
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);
        }
        // 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);
        }
        // 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 #6
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);
        }
Example #7
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);
        }
        // Token: 0x06000885 RID: 2181 RVA: 0x00032498 File Offset: 0x00030698
        internal XmlDocument ConstructErrorXml(StatusCode statusCode)
        {
            base.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, (int)statusCode);
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement(this.CommandXmlTag, "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);
        }
Example #9
0
        private XmlDocument CreateXmlDocument()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            xmlDocument.InsertBefore(xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null), xmlDocument.DocumentElement);
            xmlDocument.AppendChild(xmlDocument.CreateElement("configuration"));
            XmlElement xmlElement = xmlDocument.CreateElement("mexRuntime");

            xmlDocument.DocumentElement.PrependChild(xmlElement);
            XmlElement xmlElement2 = xmlDocument.CreateElement("monitoring");

            xmlElement.AppendChild(xmlElement2);
            XmlElement xmlElement3 = xmlDocument.CreateElement("agentExecution");

            xmlElement3.SetAttribute("timeLimitInMilliseconds", this.monitoringOptions.AgentExecutionLimitInMilliseconds.ToString(CultureInfo.InvariantCulture));
            xmlElement2.AppendChild(xmlElement3);
            if (!this.monitoringOptions.MessageSnapshotEnabled)
            {
                XmlElement xmlElement4 = xmlDocument.CreateElement("messageSnapshot");
                xmlElement4.SetAttribute("enabled", "false");
                xmlElement2.AppendChild(xmlElement4);
            }
            XmlElement xmlElement5 = xmlDocument.CreateElement("agentList");

            xmlElement.AppendChild(xmlElement5);
            foreach (AgentInfo agentInfo in this.agentList)
            {
                if (!agentInfo.IsInternal)
                {
                    XmlElement xmlElement6 = xmlDocument.CreateElement("agent");
                    xmlElement6.SetAttribute("name", agentInfo.AgentName);
                    xmlElement6.SetAttribute("baseType", agentInfo.BaseTypeName);
                    xmlElement6.SetAttribute("classFactory", agentInfo.FactoryTypeName);
                    xmlElement6.SetAttribute("assemblyPath", agentInfo.FactoryAssemblyPath);
                    xmlElement6.SetAttribute("enabled", agentInfo.Enabled.ToString().ToLower(CultureInfo.InvariantCulture));
                    xmlElement5.AppendChild(xmlElement6);
                }
            }
            XmlElement xmlElement7 = xmlDocument.CreateElement("settings");

            if (!this.disposeAgents)
            {
                XmlElement xmlElement8 = xmlDocument.CreateElement("disposeAgents");
                xmlElement8.InnerText = "false";
                xmlElement7.AppendChild(xmlElement8);
            }
            xmlElement.AppendChild(xmlElement7);
            return(xmlDocument);
        }
Example #10
0
        private XmlDocument BuildXmlResponse()
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("Search", "Search:");

            xmlDocument.AppendChild(xmlNode);
            XmlNode xmlNode2 = xmlDocument.CreateElement("Status", "Search:");

            xmlNode2.InnerText = 1.ToString(CultureInfo.InvariantCulture);
            xmlNode.AppendChild(xmlNode2);
            XmlNode xmlNode3 = xmlDocument.CreateElement("Response", "Search:");

            xmlNode.AppendChild(xmlNode3);
            this.respStoreNode = xmlDocument.CreateElement("Store", "Search:");
            xmlNode3.AppendChild(this.respStoreNode);
            return(xmlDocument);
        }
Example #11
0
        // Token: 0x06000C2E RID: 3118 RVA: 0x0003FCD4 File Offset: 0x0003DED4
        private XmlDocument BuildXmlResponse(string statusCode)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();
            XmlNode     xmlNode     = xmlDocument.CreateElement("ItemOperations", "ItemOperations:");

            xmlDocument.AppendChild(xmlNode);
            XmlNode xmlNode2 = xmlDocument.CreateElement("Status", "ItemOperations:");

            xmlNode2.InnerText = statusCode;
            xmlNode.AppendChild(xmlNode2);
            this.responseNode = xmlDocument.CreateElement("Response", "ItemOperations:");
            if (statusCode == 1.ToString(CultureInfo.InvariantCulture))
            {
                xmlNode.AppendChild(this.responseNode);
            }
            return(xmlDocument);
        }
 // Token: 0x06000886 RID: 2182 RVA: 0x00032504 File Offset: 0x00030704
 internal override Command.ExecutionState ExecuteCommand()
 {
     try
     {
         FolderCommand.FolderRequest folderRequest = this.ParseRequest();
         XmlDocument xmlDocument = new SafeXmlDocument();
         XmlNode     newChild    = xmlDocument.CreateElement(base.XmlRequest.LocalName, base.XmlRequest.NamespaceURI);
         xmlDocument.AppendChild(newChild);
         try
         {
             base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.ClientSyncKey, folderRequest.SyncKey);
             this.LoadSyncState(folderRequest.SyncKey);
             this.ConvertSyncIdsToXsoIds(folderRequest);
             this.folderHierarchySync = this.folderHierarchySyncState.GetFolderHierarchySync(new ChangeTrackingDelegate(FolderCommand.ComputeChangeTrackingHash));
             if (folderRequest.SyncKey != 0)
             {
                 if (!this.folderHierarchySyncState.Contains(CustomStateDatumType.SyncKey))
                 {
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "I");
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "RecoveryNotAllowed");
                     throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                 }
                 int data  = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.SyncKey, -1);
                 int data2 = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.RecoverySyncKey, -1);
                 if (folderRequest.SyncKey != data && (!this.allowRecovery || folderRequest.SyncKey != data2))
                 {
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "I");
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidSyncKey");
                     throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                 }
                 FolderIdMapping folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
                 if (folderRequest.SyncKey == data)
                 {
                     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Committing folderIdMapping.");
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "S");
                     folderIdMapping.CommitChanges();
                     this.folderHierarchySync.AcknowledgeServerOperations();
                 }
                 else
                 {
                     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Clearing changes on folderIdMapping.");
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "R");
                     folderIdMapping.ClearChanges();
                     this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree];
                 }
             }
             else
             {
                 base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "F");
                 base.SendServerUpgradeHeader = true;
             }
             this.ProcessCommand(folderRequest, xmlDocument);
             if (this.folderHierarchySyncState != null)
             {
                 int data3 = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.AirSyncProtocolVersion, -1);
                 if (base.Version > data3)
                 {
                     AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, this, "Changing sync state protocol version from {0} to {1}.", data3, base.Version);
                     this.folderHierarchySyncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data(base.Version);
                     this.syncStateChanged = true;
                 }
             }
             if (this.syncStateChanged)
             {
                 if (this.folderHierarchySyncState != null)
                 {
                     this.folderHierarchySyncState.CustomVersion = new int?(5);
                     this.folderHierarchySyncState.Commit();
                 }
                 if (this.folderIdMappingSyncState != null)
                 {
                     FolderIdMapping folderIdMapping2 = this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] as FolderIdMapping;
                     FolderTree      folderTree       = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree] as FolderTree;
                     if (folderIdMapping2.IsDirty || folderTree.IsDirty)
                     {
                         this.folderIdMappingSyncState.Commit();
                     }
                 }
             }
         }
         finally
         {
             if (this.folderIdMappingSyncState != null)
             {
                 this.folderIdMappingSyncState.Dispose();
             }
             if (this.folderHierarchySyncState != null)
             {
                 this.folderHierarchySyncState.Dispose();
             }
         }
         base.XmlResponse = xmlDocument;
     }
     catch (ObjectNotFoundException innerException)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderNotFound");
         throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, this.ConstructErrorXml(StatusCode.Sync_ProtocolError), innerException, false);
     }
     catch (CorruptDataException ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CorruptData");
         AirSyncDiagnostics.TraceDebug <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "Corrupted data found, replacing error with wrongsynckey error to force client to refresh.\r\n{0}", arg);
         throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), ex, false);
     }
     catch (QuotaExceededException)
     {
         throw;
     }
     catch (StoragePermanentException ex2)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, ex2.GetType().ToString());
         throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, this.ConstructErrorXml(StatusCode.Sync_ClientServerConversion), ex2, false);
     }
     catch (ArgumentException innerException2)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ArgumentException");
         throw new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, this.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException2, false);
     }
     catch (FormatException innerException3)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FormatException");
         throw new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, this.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException3, false);
     }
     return(Command.ExecutionState.Complete);
 }