// Token: 0x0600075A RID: 1882 RVA: 0x00028D88 File Offset: 0x00026F88
 public static bool IsBlockedHostName(string hostName)
 {
     AirSyncDiagnostics.Assert(!string.IsNullOrEmpty(hostName));
     if (DocumentLibraryUtility.RemoteDocumentsBlockedServers != null)
     {
         foreach (string b in DocumentLibraryUtility.RemoteDocumentsBlockedServers)
         {
             if (string.Equals(hostName, b, StringComparison.OrdinalIgnoreCase))
             {
                 return(true);
             }
         }
     }
     if (DocumentLibraryUtility.RemoteDocumentsAllowedServers != null)
     {
         foreach (string b2 in DocumentLibraryUtility.RemoteDocumentsAllowedServers)
         {
             if (string.Equals(hostName, b2, StringComparison.OrdinalIgnoreCase))
             {
                 return(false);
             }
         }
     }
     return(DocumentLibraryUtility.RemoteDocumentsActionForUnknownServers == RemoteDocumentsActions.Block);
 }
        // Token: 0x06000757 RID: 1879 RVA: 0x00028C74 File Offset: 0x00026E74
        public static bool IsInternalUri(Uri uri)
        {
            AirSyncDiagnostics.Assert(uri != null);
            string host = uri.Host;

            if (DocumentLibraryUtility.RemoteDocumentsInternalDomainSuffixList != null)
            {
                foreach (string value in DocumentLibraryUtility.RemoteDocumentsInternalDomainSuffixList)
                {
                    if (host.EndsWith(value, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }
            IPAddress ipaddress = new IPAddress(0L);
            bool      result;

            try
            {
                result = (!IPAddress.TryParse(host, out ipaddress) && host.IndexOf('.') < 0);
            }
            catch (ArgumentException)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, null, "Invalid Uri Format in internal URI determination");
                result = false;
            }
            return(result);
        }
示例#3
0
 // Token: 0x060008E5 RID: 2277 RVA: 0x00035170 File Offset: 0x00033370
 public void Delete(params ISyncItemId[] mailboxIds)
 {
     AirSyncDiagnostics.Assert(mailboxIds != null);
     for (int i = 0; i < mailboxIds.Length; i++)
     {
         if (this.mailboxIdToSyncIdTable.ContainsKey(mailboxIds[i]))
         {
             string item = this.mailboxIdToSyncIdTable[mailboxIds[i]];
             if (this.usingWriteBuffer)
             {
                 if (!this.deletedItems.Contains(item) && !this.deletedItemsWriteBuffer.Contains(item))
                 {
                     this.deletedItemsWriteBuffer.Add(item);
                 }
             }
             else if (!this.deletedItems.Contains(item))
             {
                 this.deletedItems.Add(item);
                 this.dirty = true;
             }
         }
         else if (this.usingWriteBuffer && this.addedItemsWriteBufferReversed.ContainsKey(mailboxIds[i]))
         {
             this.addedItemsWriteBuffer.Remove(this.addedItemsWriteBufferReversed[mailboxIds[i]]);
             this.addedItemsWriteBufferReversed.Remove(mailboxIds[i]);
         }
         else
         {
             AirSyncDiagnostics.Assert(false, "Id '{0}' is not found in the mapping", new object[]
             {
                 mailboxIds[i]
             });
         }
     }
 }
示例#4
0
 // Token: 0x060008E6 RID: 2278 RVA: 0x00035274 File Offset: 0x00033474
 public void Delete(params string[] syncIds)
 {
     AirSyncDiagnostics.Assert(syncIds != null);
     for (int i = 0; i < syncIds.Length; i++)
     {
         if (this.syncIdToMailboxIdTable.ContainsKey(syncIds[i]))
         {
             if (this.usingWriteBuffer)
             {
                 if (!this.deletedItems.Contains(syncIds[i]) && !this.deletedItemsWriteBuffer.Contains(syncIds[i]))
                 {
                     this.deletedItemsWriteBuffer.Add(syncIds[i]);
                 }
             }
             else if (!this.deletedItems.Contains(syncIds[i]))
             {
                 this.deletedItems.Add(syncIds[i]);
                 this.dirty = true;
             }
         }
         else if (this.usingWriteBuffer && this.addedItemsWriteBuffer.ContainsKey(syncIds[i]))
         {
             this.addedItemsWriteBufferReversed.Remove(this.addedItemsWriteBuffer[syncIds[i]]);
             this.addedItemsWriteBuffer.Remove(syncIds[i]);
         }
         else
         {
             AirSyncDiagnostics.Assert(false, "Id '{0}' is not found in the mapping", new object[]
             {
                 syncIds[i]
             });
         }
     }
 }
示例#5
0
        private void BuildPolicyResponse(XmlNode provisionNode)
        {
            AirSyncDiagnostics.Assert(this.responseProvisionStatus != ProvisionCommand.ProvisionStatusCode.NotPresent);
            XmlNode xmlNode  = this.owningCommand.XmlResponse.CreateElement("Status", "Provision:");
            XmlNode xmlNode2 = xmlNode;
            int     num      = (int)this.responseProvisionStatus;

            xmlNode2.InnerText = num.ToString(CultureInfo.InvariantCulture);
            provisionNode.AppendChild(xmlNode);
            this.owningCommand.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, (int)this.responseProvisionStatus);
            if (this.responseProvisionStatus == ProvisionCommand.ProvisionStatusCode.Success && this.responsePolicyType != null)
            {
                XmlNode xmlNode3 = this.owningCommand.XmlResponse.CreateElement("Policies", "Provision:");
                provisionNode.AppendChild(xmlNode3);
                XmlNode xmlNode4 = this.owningCommand.XmlResponse.CreateElement("Policy", "Provision:");
                xmlNode3.AppendChild(xmlNode4);
                XmlNode xmlNode5 = this.owningCommand.XmlResponse.CreateElement("PolicyType", "Provision:");
                xmlNode5.InnerText = this.responsePolicyType;
                xmlNode4.AppendChild(xmlNode5);
                AirSyncDiagnostics.Assert(this.responsePolicyStatus != ProvisionCommand.PolicyStatusCode.NotPresent);
                XmlNode xmlNode6 = this.owningCommand.XmlResponse.CreateElement("Status", "Provision:");
                XmlNode xmlNode7 = xmlNode6;
                int     num2     = (int)this.responsePolicyStatus;
                xmlNode7.InnerText = num2.ToString(CultureInfo.InvariantCulture);
                xmlNode4.AppendChild(xmlNode6);
                if (this.responsePolicyKey != null)
                {
                    XmlNode xmlNode8 = this.owningCommand.XmlResponse.CreateElement("PolicyKey", "Provision:");
                    xmlNode8.InnerText = this.responsePolicyKey.ToString();
                    xmlNode4.AppendChild(xmlNode8);
                }
            }
        }
 public void ParseOptions(XmlElement optionsNode)
 {
     if (optionsNode != null)
     {
         XmlNode xmlNode = optionsNode["Range", "Search:"];
         if (xmlNode != null)
         {
             string[] array = xmlNode.InnerText.Split(new char[]
             {
                 '-'
             });
             AirSyncDiagnostics.Assert(array.Length == 2);
             this.minRange = int.Parse(array[0], CultureInfo.InvariantCulture);
             this.maxRange = int.Parse(array[1], CultureInfo.InvariantCulture);
             if (this.minRange > this.maxRange || (this.protocolVersion < 120 && this.minRange != 0))
             {
                 throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false)
                       {
                           ErrorStringForProtocolLogger = "MinMoreThanMaxinGalSearch"
                       };
             }
             this.rangeSpecified = true;
         }
         XmlNode pictureOptionsNode = optionsNode["Picture", "Search:"];
         this.pictureOptions = PictureOptions.Parse(pictureOptionsNode, StatusCode.Sync_ProtocolVersionMismatch);
     }
     this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.PictureRequested, (this.pictureOptions != null) ? 1 : 0);
 }
示例#7
0
 private static void AppendToLogInternal(StringBuilder logString, string prefix, object objectToLog)
 {
     logString.Append(prefix);
     if (objectToLog != null)
     {
         string text = objectToLog as string;
         if (text != null)
         {
             logString.Append(':');
             string text2 = HttpUtility.UrlEncode(text);
             text2 = text2.Replace("_", "%5F");
             logString.Append(text2);
         }
         else if (objectToLog is ExDateTime)
         {
             logString.Append(((ExDateTime)objectToLog).ToString("HH:mm:ss.FFFFFFF"));
         }
         else if (objectToLog is int || objectToLog is uint || objectToLog is long)
         {
             logString.Append(objectToLog.ToString());
         }
         else if (objectToLog is ProviderSyncType)
         {
             logString.Append(objectToLog.ToString().Replace(", ", "-"));
         }
         else
         {
             AirSyncDiagnostics.Assert(false, "Cannot log objects of this type", new object[0]);
         }
     }
     logString.Append('_');
 }
        // Token: 0x06000759 RID: 1881 RVA: 0x00028D5C File Offset: 0x00026F5C
        public static bool IsWssAccessEnabled(IAirSyncUser user)
        {
            AirSyncDiagnostics.Assert(user != null);
            PolicyData policyData = ADNotificationManager.GetPolicyData(user);

            return(policyData == null || policyData.WSSAccessEnabled);
        }
示例#9
0
        public string Add(ISyncItemId mailboxItemId)
        {
            AirSyncDiagnostics.Assert(mailboxItemId != null);
            if (mailboxItemId != null && mailboxItemId.NativeId != null)
            {
                StoreObjectId storeObjectId = mailboxItemId.NativeId as StoreObjectId;
                if (storeObjectId != null && storeObjectId.ObjectType == StoreObjectType.CalendarItemOccurrence)
                {
                    AirSyncDiagnostics.TraceDebug <ISyncItemId>(ExTraceGlobals.RequestsTracer, this, "CalendarItemOccurrence ItemId is being added to the ItemIdMapping! Id:{0}.", mailboxItemId);
                }
            }
            string text;

            if (base.OldIds.ContainsKey(mailboxItemId))
            {
                text = base.OldIds[mailboxItemId];
            }
            else
            {
                text = this.parentSyncId + ":" + base.UniqueCounter.ToString(CultureInfo.InvariantCulture);
            }
            AirSyncDiagnostics.Assert(text.Length <= 64);
            base.Add(mailboxItemId, text);
            return(text);
        }
示例#10
0
 // Token: 0x0600073F RID: 1855 RVA: 0x00026AC4 File Offset: 0x00024CC4
 public void ParseOptions(XmlElement optionsNode)
 {
     if (optionsNode != null)
     {
         int     num     = 0;
         XmlNode xmlNode = optionsNode["Range", "Search:"];
         if (xmlNode != null)
         {
             string[] array = xmlNode.InnerText.Split(new char[]
             {
                 '-'
             });
             AirSyncDiagnostics.Assert(array.Length == 2);
             this.minRange = int.Parse(array[0], CultureInfo.InvariantCulture);
             this.maxRange = int.Parse(array[1], CultureInfo.InvariantCulture);
             AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, this, "Search command minRange is {0} and maxRange is {1}.", this.minRange, this.maxRange);
             if (this.minRange > this.maxRange)
             {
                 this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MinMoreThanMaxOnDocSearch");
                 throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false);
             }
             this.rangeSpecified = true;
             num++;
         }
         XmlNode xmlNode2 = optionsNode["UserName", "Search:"];
         if (xmlNode2 != null)
         {
             AirSyncSecureStringXmlNode airSyncSecureStringXmlNode = optionsNode["Password", "Search:"] as AirSyncSecureStringXmlNode;
             if (airSyncSecureStringXmlNode == null)
             {
                 this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadCredsOnDocSearch");
                 throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false);
             }
             this.userName     = xmlNode2.InnerText;
             this.userPassword = airSyncSecureStringXmlNode.DetachSecureData();
             AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Search command userName is {0}.", this.userName);
             num += 2;
         }
         if (num != optionsNode.ChildNodes.Count)
         {
             this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadOptionsInDocSearch");
             throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false);
         }
         if (!string.Equals(this.user.Identity.AuthenticationType, "Basic", StringComparison.OrdinalIgnoreCase) && this.userPassword == null)
         {
             if (GlobalSettings.EnableCredentialRequest && this.user.Context.Request.Version >= 121)
             {
                 this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NeedPromptForCredsToProxy");
                 throw new AirSyncPermanentException(StatusCode.Sync_InvalidWaitTime, false);
             }
             this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NeedCredsToProxy");
             throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.AccessDenied, null, false);
         }
     }
 }
        private void BuildResponse(XmlNode provisionNode)
        {
            if (this.responseProvisionStatus == ProvisionCommand.ProvisionStatusCode.NotPresent)
            {
                AirSyncDiagnostics.Assert(this.responseProvisionStatus != ProvisionCommand.ProvisionStatusCode.NotPresent, "[ProvisionCommandPhaseOne.BuildResponse] ReponseProvisionStatus should NOT be NotPresent.", new object[0]);
            }
            XmlNode xmlNode  = this.owningCommand.XmlResponse.CreateElement("Status", "Provision:");
            XmlNode xmlNode2 = xmlNode;
            int     num      = (int)this.responseProvisionStatus;

            xmlNode2.InnerText = num.ToString(CultureInfo.InvariantCulture);
            provisionNode.AppendChild(xmlNode);
            this.owningCommand.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, (int)this.responseProvisionStatus);
            if (this.responseProvisionStatus == ProvisionCommand.ProvisionStatusCode.Success && this.responsePolicyType != null)
            {
                XmlNode xmlNode3 = this.owningCommand.XmlResponse.CreateElement("Policies", "Provision:");
                provisionNode.AppendChild(xmlNode3);
                XmlNode xmlNode4 = this.owningCommand.XmlResponse.CreateElement("Policy", "Provision:");
                xmlNode3.AppendChild(xmlNode4);
                XmlNode xmlNode5 = this.owningCommand.XmlResponse.CreateElement("PolicyType", "Provision:");
                xmlNode5.InnerText = this.responsePolicyType;
                xmlNode4.AppendChild(xmlNode5);
                AirSyncDiagnostics.Assert(this.responsePolicyStatus != ProvisionCommand.PolicyStatusCode.NotPresent);
                XmlNode xmlNode6 = this.owningCommand.XmlResponse.CreateElement("Status", "Provision:");
                XmlNode xmlNode7 = xmlNode6;
                int     num2     = (int)this.responsePolicyStatus;
                xmlNode7.InnerText = num2.ToString(CultureInfo.InvariantCulture);
                xmlNode4.AppendChild(xmlNode6);
                if (this.responsePolicyKey != null)
                {
                    XmlNode xmlNode8 = this.owningCommand.XmlResponse.CreateElement("PolicyKey", "Provision:");
                    xmlNode8.InnerText = this.responsePolicyKey.ToString();
                    xmlNode4.AppendChild(xmlNode8);
                }
                if (this.responsePolicyData != null)
                {
                    XmlNode xmlNode9 = this.owningCommand.XmlResponse.CreateElement("Data", "Provision:");
                    xmlNode4.AppendChild(xmlNode9);
                    if (string.Equals(this.responsePolicyType, "MS-WAP-Provisioning-XML", StringComparison.OrdinalIgnoreCase))
                    {
                        xmlNode9.InnerText = this.responsePolicyData;
                    }
                    else if (string.Equals(this.responsePolicyType, "MS-EAS-Provisioning-WBXML", StringComparison.OrdinalIgnoreCase))
                    {
                        xmlNode9.InnerXml = this.responsePolicyData;
                    }
                    else
                    {
                        AirSyncDiagnostics.Assert(false, "Unknown policy type", new object[0]);
                    }
                }
            }
            base.GenerateRemoteWipeIfNeeded(provisionNode);
        }
 // Token: 0x06000756 RID: 1878 RVA: 0x00028C34 File Offset: 0x00026E34
 public static bool IsTrustedProtocol(string protocol)
 {
     AirSyncDiagnostics.Assert(!string.IsNullOrEmpty(protocol));
     for (int i = 0; i < DocumentLibraryUtility.trustedProtocols.Length; i++)
     {
         if (string.Equals(protocol, DocumentLibraryUtility.trustedProtocols[i], StringComparison.OrdinalIgnoreCase))
         {
             return(true);
         }
     }
     return(false);
 }
示例#13
0
        internal static ActiveSyncMiniRecipient TryGetADUser(IAirSyncUser user, ProtocolLogger logger)
        {
            ADUserCache.< > c__DisplayClass1 CS$ < > 8__locals1 = new ADUserCache.< > c__DisplayClass1();
            AirSyncDiagnostics.Assert(user != null, "IAirSyncUser cannot be null in GetADUser", new object[0]);
            CS$ < > 8__locals1.sid2 = user.ClientSecurityContextWrapper.UserSid;
            ActiveSyncMiniRecipient activeSyncMiniRecipient = null;

            if (!GlobalSettings.DisableCaching && ADUserCache.TryGetADUser(CS$ < > 8__locals1.sid2.Value, out activeSyncMiniRecipient))
            {
                return(activeSyncMiniRecipient);
            }
            string value = user.Name;

            if (GlobalSettings.IsWindowsLiveIDEnabled)
            {
                value = user.WindowsLiveId;
            }
            if (string.IsNullOrEmpty(value))
            {
                logger.SetValue(ProtocolLoggerData.Error, "BadAuthUsername");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUser:: user IdentityType {0}", user.Identity.GetType().FullName);
            ADSessionSettings       sessionSettings  = ADUserCache.GetSessionSettings(GlobalSettings.IsMultiTenancyEnabled ? (user.Identity as LiveIDIdentity).UserOrganizationId : OrganizationId.ForestWideOrgId, logger);
            IRecipientSession       recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, 0, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 124, "TryGetADUser", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADUserCache.cs");
            ActiveSyncMiniRecipient recipient        = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                recipient = recipientSession.FindMiniRecipientBySid <ActiveSyncMiniRecipient>(CS$ < > 8__locals1.sid2, ObjectSchema.GetInstance <ClientAccessRulesRecipientFilterSchema>().AllProperties);
            });
            logger.SetValue(ProtocolLoggerData.DomainController, recipientSession.LastUsedDc);
            if (recipient == null)
            {
                AirSyncDiagnostics.TraceDebug <SecurityIdentifier>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUserFromSid can't find ActiveSyncMiniRecipient for sid {0}", CS$ < > 8__locals1.sid2);
                return(null);
            }
            activeSyncMiniRecipient = ((recipient.RecipientType == RecipientType.UserMailbox || recipient.RecipientType == RecipientType.MailUser) ? recipient : null);
            if (activeSyncMiniRecipient == null)
            {
                AirSyncDiagnostics.TraceDebug <RecipientType>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUserFromSid recipient type is {0} when expected UserMailbox/MailUser", recipient.RecipientType);
                return(null);
            }
            if (!GlobalSettings.DisableCaching)
            {
                ADUserCache.AddADUserToCache(CS$ < > 8__locals1.sid2.Value, activeSyncMiniRecipient);
            }
            return(activeSyncMiniRecipient);
        }
示例#14
0
 internal static ADSessionSettings GetSessionSettings(OrganizationId orgId, ProtocolLogger logger)
 {
     AirSyncDiagnostics.Assert(orgId != null);
     if (GlobalSettings.IsMultiTenancyEnabled)
     {
         AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "organizationID :{0}", orgId.ToString());
         ADSessionSettings result = null;
         ADNotificationAdapter.RunADOperation(delegate()
         {
             result = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId);
         });
         return(result);
     }
     return(ADSessionSettings.FromRootOrgScopeSet());
 }
示例#15
0
        public string Add(ISyncItemId mailboxFolderId)
        {
            AirSyncDiagnostics.Assert(mailboxFolderId != null);
            string text;

            if (base.OldIds.ContainsKey(mailboxFolderId))
            {
                text = base.OldIds[mailboxFolderId];
            }
            else
            {
                text = base.UniqueCounter.ToString(CultureInfo.InvariantCulture);
            }
            base.Add(mailboxFolderId, text);
            return(text);
        }
示例#16
0
 // Token: 0x060008EC RID: 2284 RVA: 0x00035640 File Offset: 0x00033840
 protected void Add(ISyncItemId mailboxId, string syncId)
 {
     AirSyncDiagnostics.Assert(mailboxId != null);
     AirSyncDiagnostics.Assert(syncId != null);
     if (this.syncIdToMailboxIdTable.ContainsKey(syncId))
     {
         ISyncItemId syncItemId = this.syncIdToMailboxIdTable[syncId];
         if (syncItemId.Equals(mailboxId))
         {
             return;
         }
         throw new InvalidOperationException("SyncId has already been mapped to a different MailboxId");
     }
     else if (this.usingWriteBuffer && this.addedItemsWriteBuffer.ContainsKey(syncId))
     {
         ISyncItemId syncItemId2 = this.addedItemsWriteBuffer[syncId];
         if (syncItemId2.Equals(mailboxId))
         {
             return;
         }
         throw new InvalidOperationException("SyncId has already been mapped to a different MailboxId");
     }
     else
     {
         if (this.mailboxIdToSyncIdTable.ContainsKey(mailboxId) || (this.usingWriteBuffer && this.addedItemsWriteBufferReversed.ContainsKey(mailboxId)))
         {
             throw new InvalidOperationException("MailboxId has already been mapped to a different SyncId");
         }
         if (this.usingWriteBuffer)
         {
             this.addedItemsWriteBuffer[syncId]            = mailboxId;
             this.addedItemsWriteBufferReversed[mailboxId] = syncId;
             this.uniqueCounter += 1L;
             return;
         }
         this.syncIdToMailboxIdTable.Add(syncId, mailboxId);
         this.mailboxIdToSyncIdTable.Add(mailboxId, syncId);
         this.addedItems.Add(syncId);
         this.uniqueCounter += 1L;
         this.dirty          = true;
         return;
     }
 }
        // Token: 0x06000D08 RID: 3336 RVA: 0x00046FC0 File Offset: 0x000451C0
        private void AppendItemXmlNode(string srcMsgId, string status, string dstMsgId)
        {
            AirSyncDiagnostics.Assert(base.XmlResponse != null);
            XmlElement xmlElement = base.XmlResponse.CreateElement("Response", "Move:");

            this.moveitemsNode.AppendChild(xmlElement);
            XmlElement xmlElement2 = base.XmlResponse.CreateElement("SrcMsgId", "Move:");

            xmlElement2.InnerText = srcMsgId;
            xmlElement.AppendChild(xmlElement2);
            XmlElement xmlElement3 = base.XmlResponse.CreateElement("Status", "Move:");

            xmlElement3.InnerText = status;
            xmlElement.AppendChild(xmlElement3);
            if (dstMsgId != null)
            {
                XmlElement xmlElement4 = base.XmlResponse.CreateElement("DstMsgId", "Move:");
                xmlElement4.InnerText = dstMsgId;
                xmlElement.AppendChild(xmlElement4);
            }
        }
示例#18
0
 public int?[] UpdateChangeTrackingInformation(XmlNode xmlItemRoot, int?[] oldChangeTrackingInformation)
 {
     this.seenNodes = new XmlNode[this.changeTrackingNodes.Values.Count];
     this.newChangeTrackingInformation    = new int?[this.changeTrackingNodes.Values.Count];
     this.newChangeTrackingInformation[0] = this.ComputeHash(xmlItemRoot, true);
     if (this.fillInMissingHashes && oldChangeTrackingInformation != null)
     {
         AirSyncDiagnostics.Assert(this.newChangeTrackingInformation.Length >= oldChangeTrackingInformation.Length, "newChangeTrackingInformation.Length = {0}, oldChangeTrackingInformation.Length = {1}", new object[]
         {
             this.newChangeTrackingInformation.Length,
             oldChangeTrackingInformation.Length
         });
         int num = 0;
         while (num < this.changeTrackingNodes.Values.Count && num < oldChangeTrackingInformation.Length)
         {
             if (this.newChangeTrackingInformation[num] == null)
             {
                 this.newChangeTrackingInformation[num] = oldChangeTrackingInformation[num];
             }
             num++;
         }
     }
     return(this.newChangeTrackingInformation);
 }
示例#19
0
 public void BuildResponse(XmlElement responseNode)
 {
     try
     {
         int num = 0;
         this.numberResponses = 0;
         XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Status", "Search:");
         responseNode.AppendChild(xmlNode);
         xmlNode.InnerText = 1.ToString(CultureInfo.InvariantCulture);
         int num2 = this.minRange;
         while (this.addressBookObjects != null && num2 <= this.maxRange && num2 < this.addressBookObjects.Count)
         {
             ABObject abobject = this.addressBookObjects[num2];
             if (abobject != null)
             {
                 ABContact abcontact = abobject as ABContact;
                 XmlNode   xmlNode2  = responseNode.OwnerDocument.CreateElement("Result", "Search:");
                 XmlNode   xmlNode3  = responseNode.OwnerDocument.CreateElement("Properties", "Search:");
                 xmlNode2.AppendChild(xmlNode3);
                 for (int i = 0; i < GalSearchProvider.schema.Length; i++)
                 {
                     string abproperty;
                     if (abcontact == null)
                     {
                         abproperty = GalSearchProvider.GetABProperty(abobject, GalSearchProvider.schema[i]);
                     }
                     else
                     {
                         abproperty = GalSearchProvider.GetABProperty(abcontact, GalSearchProvider.schema[i]);
                     }
                     if (!string.IsNullOrEmpty(abproperty))
                     {
                         XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement(GalSearchProvider.schema[i], "Gal:");
                         xmlNode4.InnerText = abproperty;
                         xmlNode3.AppendChild(xmlNode4);
                     }
                 }
                 if (this.pictureOptions != null && abcontact != null)
                 {
                     StatusCode statusCode = StatusCode.Success;
                     byte[]     array      = null;
                     if (this.user.Features.IsEnabled(EasFeature.HDPhotos) && this.user.Context.Request.Version >= 160)
                     {
                         array = this.photoRetriever.EndGetThumbnailPhotoFromMailbox(abcontact.EmailAddress, GlobalSettings.MaxRequestExecutionTime - ExDateTime.Now.Subtract(Command.CurrentCommand.Context.RequestTime), this.pictureOptions.PhotoSize);
                         AirSyncDiagnostics.TraceDebug <bool, int>(ExTraceGlobals.RequestsTracer, this, "GalSearch Requesting user's HD picture. WasRetrived:{0}, size:{1}", array != null, (array == null) ? 0 : array.Length);
                     }
                     if (statusCode != StatusCode.Success || array == null)
                     {
                         AirSyncDiagnostics.TraceDebug <bool, int, StatusCode>(ExTraceGlobals.RequestsTracer, this, "User's HD photo is either null or was not requested, Using contact's picture from AD. :FeatureEnabled:{0}, RequestVersion:{1}, statusCode:{2}", this.user.Features.IsEnabled(EasFeature.HDPhotos), this.user.Context.Request.Version, statusCode);
                         array = abcontact.Picture;
                     }
                     bool    flag;
                     XmlNode newChild = this.pictureOptions.CreatePictureNode(responseNode.OwnerDocument, "Gal:", array, num >= this.pictureOptions.MaxPictures, out flag);
                     xmlNode3.AppendChild(newChild);
                     if (flag)
                     {
                         num++;
                     }
                 }
                 responseNode.AppendChild(xmlNode2);
                 this.numberResponses++;
             }
             num2++;
         }
         if (this.numberResponses == 0)
         {
             XmlNode newChild2 = responseNode.OwnerDocument.CreateElement("Result", "Search:");
             responseNode.AppendChild(newChild2);
         }
         else if (this.rangeSpecified)
         {
             XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("Range", "Search:");
             XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("Total", "Search:");
             xmlNode5.InnerText = this.minRange.ToString(CultureInfo.InvariantCulture) + "-" + (this.minRange + this.numberResponses - 1).ToString(CultureInfo.InvariantCulture);
             responseNode.AppendChild(xmlNode5);
             AirSyncDiagnostics.Assert(this.addressBookObjects.Count <= GlobalSettings.MaxGALSearchResults);
             xmlNode6.InnerText = this.addressBookObjects.Count.ToString(CultureInfo.InvariantCulture);
             responseNode.AppendChild(xmlNode6);
         }
     }
     finally
     {
         if (this.photoRetriever != null)
         {
             this.photoRetriever.Dispose();
             this.photoRetriever = null;
         }
     }
 }
        // Token: 0x0600074D RID: 1869 RVA: 0x00027EFC File Offset: 0x000260FC
        public void Execute()
        {
            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "DocumentLibrary Fetch command received. Processing request...");
            Uri uri = null;

            try
            {
                uri = new Uri(this.linkId);
            }
            catch (UriFormatException innerException)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "ItemOperationsFetchProvider: Bad document Uri {0} was specified!", new object[]
                {
                    this.linkId
                }));
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadLinkInDocFetch");
                throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, innerException, false);
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Processing Fetch command with Uri {0}.", uri.AbsoluteUri);
            if (!DocumentLibraryUtility.IsTrustedProtocol(uri.Scheme))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "ItemOperationsFetchProvider: untrusted protocol: {0}!", new object[]
                {
                    uri.Scheme
                }));
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadProtocolInDocFetch");
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false);
            }
            if (!DocumentLibraryUtility.IsInternalUri(uri))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "ItemOperationsFetchProvider: Uri must be internal: {0}!", new object[]
                {
                    uri.Host
                }));
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ExternalProtocolInDocFetch");
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false);
            }
            AuthenticationContext authenticationContext = new AuthenticationContext();

            try
            {
                IPrincipal principal;
                if (this.userPassword == null)
                {
                    principal = this.user.WindowsPrincipal;
                    if (principal == null)
                    {
                        if (GlobalSettings.EnableCredentialRequest && this.user.Context.Request.Version >= 121)
                        {
                            this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NeedPromptForCredsToProxy2");
                            throw new AirSyncPermanentException(StatusCode.ItemOperations_CredentialsRequired, false);
                        }
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NeedCredsToProxy2");
                        throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.AccessDenied, null, false);
                    }
                }
                else
                {
                    SecurityStatus securityStatus = authenticationContext.LogonUser(this.userName, this.userPassword);
                    this.userPassword.Dispose();
                    this.userPassword = null;
                    if (securityStatus != SecurityStatus.OK)
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "ItemOperationsFetchProvider: Authentication failed with status {0}.", new object[]
                        {
                            securityStatus
                        }));
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, string.Format(CultureInfo.InvariantCulture, "AuthenticationErrorStatus{0}", new object[]
                        {
                            securityStatus
                        }));
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ServerError, null, false);
                    }
                    principal = new WindowsPrincipal(authenticationContext.Identity);
                }
                ClassifyResult classifyResult = LinkClassifier.ClassifyLinks(principal, new Uri[]
                {
                    uri
                })[0];
                if (classifyResult.Error != ClassificationError.None)
                {
                    AirSyncDiagnostics.TraceDebug <string, ClassificationError>(ExTraceGlobals.RequestsTracer, this, "The LinkClassifier failed to classify the link {0}, returned {1}", this.linkId, classifyResult.Error);
                    switch (classifyResult.Error)
                    {
                    case ClassificationError.ConnectionFailed:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassConnFailedInDocFetch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_Conflict, null, false);

                    case ClassificationError.AccessDenied:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassDeniedInDocFetch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ServerError, null, false);

                    case ClassificationError.ObjectNotFound:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassNotFoundInDocFetch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ClientServerConversion, null, false);

                    case ClassificationError.UriTypeNotSupported:
                    case ClassificationError.InvalidUri:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassBadUriInDocFetch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ProtocolError, null, false);
                    }
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassFailureInDocFetch");
                    throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, false);
                }
                IDocument         document          = null;
                UncSession        uncSession        = null;
                SharepointSession sharepointSession = null;
                if ((classifyResult.UriFlags & UriFlags.UncDocument) == UriFlags.UncDocument)
                {
                    if (!DocumentLibraryUtility.IsUncAccessEnabled(this.user))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AccessDeniedInDocFetch");
                        throw new AirSyncPermanentException(StatusCode.Sync_Retry, false);
                    }
                    if (DocumentLibraryUtility.IsBlockedHostName(uri.Host))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "HostBlockedInDocFetch");
                        throw new AirSyncPermanentException(StatusCode.Sync_Retry, false);
                    }
                    uncSession = UncSession.Open(classifyResult.ObjectId, principal);
                }
                else
                {
                    if ((classifyResult.UriFlags & UriFlags.SharepointDocument) != UriFlags.SharepointDocument)
                    {
                        AirSyncDiagnostics.TraceDebug <string, UriFlags>(ExTraceGlobals.RequestsTracer, this, "The Uri {0} of type {1} is not supported for Fetch", this.linkId, classifyResult.UriFlags);
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadLinkInDocFetch2");
                        throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, false);
                    }
                    if (!DocumentLibraryUtility.IsWssAccessEnabled(this.user))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "WssDeniedInDocFetch");
                        throw new AirSyncPermanentException(StatusCode.Sync_Retry, false);
                    }
                    if (DocumentLibraryUtility.IsBlockedHostName(uri.Host))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "HostBlockedInDocFetch2");
                        throw new AirSyncPermanentException(StatusCode.Sync_Retry, false);
                    }
                    this.user.Context.ProtocolLogger.IncrementValue(ProtocolLoggerData.SharePointDocs);
                    sharepointSession = SharepointSession.Open(classifyResult.ObjectId, principal);
                }
                try
                {
                    if (uncSession != null)
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Reading UNC document...");
                        document = UncDocument.Read(uncSession, classifyResult.ObjectId);
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Reading Sharepoint document...");
                        AirSyncDiagnostics.Assert(sharepointSession != null);
                        document = SharepointDocument.Read(sharepointSession, classifyResult.ObjectId);
                    }
                }
                catch (ObjectNotFoundException innerException2)
                {
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NotFoundInDocFetch");
                    throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException2, false);
                }
                catch (AccessDeniedException innerException3)
                {
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AccessDeniedInDocFetch2");
                    throw new AirSyncPermanentException(StatusCode.Sync_ServerError, innerException3, false);
                }
                this.documentSize = (int)document.Size;
                if (this.documentSize == 0)
                {
                    AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "The file {0} was found to be empty!", this.linkId);
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EmptyDocInDocFetch");
                    throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_NotificationGUID, null, false);
                }
                object obj = document.TryGetProperty(DocumentLibraryItemSchema.LastModifiedDate);
                if (obj is PropertyError)
                {
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "GeneralErrorInDocFetch");
                    throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, false);
                }
                ExDateTime exDateTime;
                if (obj is DateTime)
                {
                    exDateTime = new ExDateTime(ExTimeZone.UtcTimeZone, (DateTime)obj);
                }
                else
                {
                    exDateTime = (ExDateTime)obj;
                }
                this.version = exDateTime.ToString("yyyy-MM-dd\\THH:mm:ss.fff\\Z", CultureInfo.InvariantCulture);
                if (this.rangeSpecified && this.minRange >= this.documentSize)
                {
                    AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, this, "The minimum range specified {0} is greater than the document size {1}", this.minRange, this.documentSize);
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadMinSizeInDocFetch");
                    throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ObjectNotFound, null, false);
                }
                using (Stream document2 = document.GetDocument())
                {
                    int num;
                    if (this.rangeSpecified)
                    {
                        num = this.maxRange - this.minRange + 1;
                    }
                    else
                    {
                        num = this.documentSize;
                    }
                    if (uncSession != null)
                    {
                        this.user.Context.ProtocolLogger.IncrementValue(ProtocolLoggerData.UNCFiles);
                        this.user.Context.ProtocolLogger.IncrementValueBy(ProtocolLoggerData.UNCBytes, num);
                    }
                    if (sharepointSession != null)
                    {
                        this.user.Context.ProtocolLogger.IncrementValue(ProtocolLoggerData.SharePointDocs);
                        this.user.Context.ProtocolLogger.IncrementValueBy(ProtocolLoggerData.SharePointBytes, num);
                    }
                    this.outStream = new MemoryStream(num);
                    if (num > GlobalSettings.MaxDocumentDataSize)
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DocTooBigInDocFetch");
                        throw new AirSyncPermanentException(StatusCode.Sync_NotificationsNotProvisioned, false);
                    }
                    try
                    {
                        StreamHelper.CopyStream(document2, this.outStream, this.minRange, num);
                    }
                    catch (IOException innerException4)
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "IOErrorInDocFetch");
                        throw new AirSyncPermanentException(StatusCode.Sync_FolderHierarchyRequired, innerException4, false);
                    }
                }
            }
            catch (UnknownErrorException innerException5)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "IOErrorInDocFetch2");
                throw new AirSyncPermanentException(StatusCode.Sync_FolderHierarchyRequired, innerException5, false);
            }
            catch (DocumentModifiedException innerException6)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "IOErrorInDocFetch3");
                throw new AirSyncPermanentException(StatusCode.Sync_FolderHierarchyRequired, innerException6, false);
            }
            catch (DocumentStreamAccessDeniedException innerException7)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AccessDeniedInDocFetch3");
                throw new AirSyncPermanentException(StatusCode.Sync_ServerError, innerException7, false);
            }
            catch (ObjectMovedOrDeletedException innerException8)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NotFoundInDocFetch2");
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException8, false);
            }
            catch (DocumentLibraryException innerException9)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "GeneralErrorInDocFetch2");
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, innerException9, false);
            }
            finally
            {
                if (authenticationContext != null)
                {
                    authenticationContext.Dispose();
                    authenticationContext = null;
                }
            }
        }
示例#21
0
        // Token: 0x06000C29 RID: 3113 RVA: 0x0003F778 File Offset: 0x0003D978
        internal override Command.ExecutionState ExecuteCommand()
        {
            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ItemOperationsCommand received. Processing the command...");
            try
            {
                XmlDocument xmlDocument = null;
                XmlNode     xmlRequest  = base.XmlRequest;
                if (xmlRequest.ChildNodes.Count > GlobalSettings.MaxRetrievedItems)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CapReached");
                    string message = string.Format("ItemOperations cap is reached, Cap = {0}, ChildNode = {1}", GlobalSettings.MaxRetrievedItems, xmlRequest.ChildNodes.Count);
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, message);
                    xmlDocument = this.BuildXmlResponse(11.ToString(CultureInfo.InvariantCulture));
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, 11);
                }
                else
                {
                    xmlDocument = this.BuildXmlResponse(1.ToString(CultureInfo.InvariantCulture));
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, 1);
                    int i = 0;
                    while (i < xmlRequest.ChildNodes.Count)
                    {
                        XmlNode xmlNode = xmlRequest.ChildNodes[i];
                        string  localName;
                        if ((localName = xmlNode.LocalName) == null)
                        {
                            goto IL_278;
                        }
                        if (localName == "EmptyFolderContents")
                        {
                            this.currentProvider = this.EmptyFolderContentsProvider;
                            base.ProtocolLogger.IncrementValue(ProtocolLoggerData.IOEmptyFolderContents);
                            goto IL_27E;
                        }
                        if (!(localName == "Fetch"))
                        {
                            if (!(localName == "Move"))
                            {
                                goto IL_278;
                            }
                            this.currentProvider = this.MoveProvider;
                            base.ProtocolLogger.IncrementValue(ProtocolLoggerData.IOMoves);
                            goto IL_27E;
                        }
                        else
                        {
                            XmlNode xmlNode2 = xmlNode["Store", "ItemOperations:"];
                            string  a;
                            if ((a = xmlNode2.InnerText.ToLower(CultureInfo.InvariantCulture)) != null)
                            {
                                if (a == "documentlibrary")
                                {
                                    this.currentProvider = this.DocumentFetchProvider;
                                    base.ProtocolLogger.IncrementValue(ProtocolLoggerData.IOFetchDocs);
                                    goto IL_27E;
                                }
                                if (a == "mailbox")
                                {
                                    XmlNode xmlNode3 = xmlNode["FileReference", "AirSyncBase:"];
                                    if (xmlNode3 == null)
                                    {
                                        this.currentProvider = this.ItemFetchProvider;
                                        base.ProtocolLogger.IncrementValue(ProtocolLoggerData.IOFetchItems);
                                        goto IL_27E;
                                    }
                                    if (base.Version >= 160 && xmlNode3.InnerText != null && xmlNode3.InnerText.IndexOf("%3a") > 16)
                                    {
                                        this.currentProvider = this.EntityAttachmentFetchProvider;
                                        base.ProtocolLogger.IncrementValue(ProtocolLoggerData.IOFetchEntAtts);
                                        goto IL_27E;
                                    }
                                    this.currentProvider = this.AttachmentFetchProvider;
                                    base.ProtocolLogger.IncrementValue(ProtocolLoggerData.IOFetchAtts);
                                    goto IL_27E;
                                }
                            }
                            this.AppendFetchErrorXml(xmlDocument, 9.ToString(CultureInfo.InvariantCulture));
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, 9);
                        }
IL_3C0:
                        i++;
                        continue;
Block_15:
                        try
                        {
IL_27E:
                            this.currentProvider.ParseRequest(xmlNode);
                            this.currentProvider.Execute();
                            if (base.Request.AcceptMultiPartResponse && this.currentProvider is IMultipartResponse)
                            {
                                IMultipartResponse multipartResponse = this.currentProvider as IMultipartResponse;
                                multipartResponse.BuildResponse(this.responseNode, this.multipartStreams.Count + 1);
                                Stream responseStream = multipartResponse.GetResponseStream();
                                if (responseStream != null)
                                {
                                    this.multipartStreams.Add(responseStream);
                                }
                            }
                            else
                            {
                                this.currentProvider.BuildResponse(this.responseNode);
                            }
                            this.currentProvider.Reset();
                        }
                        catch (AirSyncPermanentException ex)
                        {
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.StatusCode, (int)ex.AirSyncStatusCode);
                            if (ex.HttpStatusCode != HttpStatusCode.OK)
                            {
                                throw;
                            }
                            base.ProtocolLogger.SetValueIfNotSet(ProtocolLoggerData.Error, ex.ErrorStringForProtocolLogger);
                            AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
                            AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.ProtocolTracer, this, "AirSyncPermanentException was thrown. Location Execute.\r\n{0}", arg);
                            if (base.MailboxLogger != null)
                            {
                                base.MailboxLogger.SetData(MailboxLogDataName.ItemOperationsCommand_Execute_Fetch_Exception, ex);
                            }
                            this.currentProvider.BuildErrorResponse(ex.AirSyncStatusCodeInInt.ToString(CultureInfo.InvariantCulture), this.responseNode, base.ProtocolLogger);
                            this.currentProvider.Reset();
                            base.PartialFailure = true;
                        }
                        goto IL_3C0;
IL_278:
                        AirSyncDiagnostics.Assert(false);
                        goto Block_15;
                    }
                }
                if (base.Request.AcceptMultiPartResponse)
                {
                    this.BuildMultiPartResponse(xmlDocument);
                }
                else
                {
                    base.XmlResponse = xmlDocument;
                }
            }
            finally
            {
                this.DisposeResources();
            }
            return(Command.ExecutionState.Complete);
        }
示例#22
0
 private void BackEndGetResponse(IAsyncResult asynchronousResult)
 {
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndGetResponse() Request was timed out while waiting for lock!");
             string text = this.remoteUri.Host.ToString();
             AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_ProxyResultTimedOut, text, new string[]
             {
                 text
             });
             return;
         }
     }
     try
     {
         AirSyncDiagnostics.TraceDebug <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndGetResponse called for serverName: {0}, user {1}", this.remoteUri, this.userName);
         this.UnregisterTimeoutWaitHandle();
         try
         {
             this.httpWebResponse = (HttpWebResponse)this.backEndWebRequest.EndGetResponse(asynchronousResult);
         }
         catch (WebException ex)
         {
             if (ex.Status == WebExceptionStatus.ProtocolError)
             {
                 HttpWebResponse httpWebResponse = ex.Response as HttpWebResponse;
                 if (httpWebResponse == null)
                 {
                     this.HandleException(ex);
                     return;
                 }
                 if (httpWebResponse.StatusCode == (HttpStatusCode)441)
                 {
                     httpWebResponse.Close();
                     if (!this.proxyInfo.AttemptProxyLogin)
                     {
                         AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "BackEndGetResponse(): authentication failure for {0}.", this.userName);
                         this.TryUnregisterTimeoutWaitHandle();
                         this.frontEndHttpContext.Response.StatusCode = 403;
                         this.frontEndResult.InvokeCallback();
                         return;
                     }
                     AirSyncDiagnostics.Assert(!this.proxyInfo.RequiresImpersonation && this.proxyInfo.AdditionalHeaders != null);
                     AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "BackEndGetResponse(): proxy login required for {0}.", this.userName);
                     if (this.proxyLoginAttempts > 0)
                     {
                         AirSyncDiagnostics.TraceFunction(ExTraceGlobals.RequestsTracer, this, "BackEndGetResponse(): too many login attempts.");
                         this.protocolLogger.SetValue(ProtocolLoggerData.Error, "TooManyProxyLoginAttempts");
                         this.TryUnregisterTimeoutWaitHandle();
                         this.frontEndHttpContext.Response.StatusCode = 403;
                         this.frontEndResult.InvokeCallback();
                         return;
                     }
                     this.proxyLoginAttempts++;
                     this.IssueProxyLoginRequest();
                     return;
                 }
                 else
                 {
                     if (httpWebResponse.Headers != null)
                     {
                         WebHeaderCollection headers = httpWebResponse.Headers;
                         string text2 = headers["WWW-Authenticate"];
                         if (text2 != null && text2.IndexOf("Negotiate ") == -1)
                         {
                             if (this.HasBeenProxiedByMServ)
                             {
                                 this.protocolLogger.SetValue(ProtocolLoggerData.Error, "Datacenter Config issue upon MServ proxy");
                             }
                             else
                             {
                                 this.protocolLogger.SetValue(ProtocolLoggerData.Error, "NTLM not on the destination CAS");
                                 string text3 = this.proxyInfo.RemoteUri.Host.ToString();
                                 AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_SecondCasFailureNTLM, text3, new string[]
                                 {
                                     text3
                                 });
                             }
                         }
                     }
                     this.httpWebResponse = httpWebResponse;
                 }
             }
             else
             {
                 if (ex.Status == WebExceptionStatus.TrustFailure)
                 {
                     AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "SSL Certification failed for {0}.", this.proxyInfo.RemoteUri.Host);
                     this.protocolLogger.SetValue(ProtocolLoggerData.Error, "SSL Certification Failed.");
                     string text4 = this.proxyInfo.RemoteUri.Host.ToString();
                     AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_SecondCasFailureSSL, text4, new string[]
                     {
                         text4
                     });
                     this.HandleException(ex);
                     return;
                 }
                 this.HandleException(ex);
                 return;
             }
         }
         if (GlobalSettings.ProxyHeaders != null && GlobalSettings.ProxyHeaders.Length > 0)
         {
             this.frontEndHttpContext.Response.ContentType = string.Empty;
             for (int i = 0; i < this.httpWebResponse.Headers.Count; i++)
             {
                 string text5 = this.httpWebResponse.Headers.Keys[i];
                 for (int j = 0; j < GlobalSettings.ProxyHeaders.Length; j++)
                 {
                     if (string.Equals(text5, GlobalSettings.ProxyHeaders[j], StringComparison.OrdinalIgnoreCase))
                     {
                         this.frontEndHttpContext.Response.AppendHeader(text5, this.httpWebResponse.Headers[text5]);
                     }
                 }
             }
         }
         this.backEndResponseStream = this.httpWebResponse.GetResponseStream();
         this.frontEndHttpContext.Response.StatusCode        = (int)this.httpWebResponse.StatusCode;
         this.frontEndHttpContext.Response.StatusDescription = this.httpWebResponse.StatusDescription;
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndReadContent;
         IAsyncResult asyncResult = this.backEndResponseStream.BeginRead(this.asyncBuffer, 0, this.asyncBuffer.Length, new AsyncCallback(this.BackEndReadContent), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
     }
     catch (Exception ex2)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex2);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndGetResponse caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex2);
     }
 }
示例#23
0
 public new void Add(ISyncItemId mailboxFolderId, string syncId)
 {
     AirSyncDiagnostics.Assert(mailboxFolderId != null);
     base.Add(mailboxFolderId, syncId);
 }
示例#24
0
 public new void Add(ISyncItemId itemId, string syncId)
 {
     AirSyncDiagnostics.Assert(itemId != null);
     base.Add(itemId, syncId);
 }