// Token: 0x0600105A RID: 4186 RVA: 0x0003ED74 File Offset: 0x0003CF74 private void NoActiveListeners(object sender, RemoteSubscriptionEventArgs eventArgs) { UserContextKey userContextKey; if (this.TryParseUserContextKey(eventArgs.ContextKey, out userContextKey)) { IMailboxContext mailboxContextFromCache = UserContextManager.GetMailboxContextFromCache(userContextKey); if (mailboxContextFromCache != null) { mailboxContextFromCache.NotificationManager.ReleaseSubscription(eventArgs.SubscriptionId); } } }
internal static IMailboxContext GetMailboxContext(HttpContext httpContext, AuthZClientInfo effectiveCaller = null, bool create = true) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } ClientSecurityContext overrideClientSecurityContext = (effectiveCaller == null) ? null : effectiveCaller.ClientSecurityContext; UserContextCookie userContextCookie; UserContextKey userContextKey = UserContextManager.GetUserContextKey(httpContext, overrideClientSecurityContext, out userContextCookie); if (!create) { return(UserContextManager.GetMailboxContextFromCache(userContextKey)); } return(UserContextManager.AcquireUserContext(httpContext, effectiveCaller, userContextKey, userContextCookie)); }
// Token: 0x0600105B RID: 4187 RVA: 0x0003EDAC File Offset: 0x0003CFAC private void NoActiveSubscription(object sender, EventArgs e) { ISubscriptionInfo subscriptionInfo = sender as ISubscriptionInfo; if (subscriptionInfo != null) { this.RemoveSubscriptions(subscriptionInfo); UserContextKey userContextKey; if (this.TryParseUserContextKey(subscriptionInfo.ContextKey, out userContextKey)) { UserContext userContext = UserContextManager.GetMailboxContextFromCache(userContextKey) as UserContext; if (userContext != null && userContext.IsGroupUserContext) { userContext.RetireMailboxSessionForGroupMailbox(); } } } }
// Token: 0x06001056 RID: 4182 RVA: 0x0003EA58 File Offset: 0x0003CC58 public virtual void CleanUpChannel(string channelId) { ArgumentValidator.ThrowIfNullOrWhiteSpace("channelId", channelId); List <string> list = new List <string>(); if (this.contextKeySubscriptionsLock.LockWriterElastic(3000)) { try { foreach (ISubscriptionInfo subscriptionInfo in this.contextKeySubscriptions.Values.ToArray <ISubscriptionInfo>()) { if (subscriptionInfo.CleanUpChannel(channelId)) { list.Add(subscriptionInfo.ContextKey); } } goto IL_9D; } finally { this.contextKeySubscriptionsLock.ReleaseWriterLock(); } goto IL_71; IL_9D: foreach (string contextKey in list) { UserContextKey userContextKey; if (this.TryParseUserContextKey(contextKey, out userContextKey)) { IMailboxContext mailboxContextFromCache = UserContextManager.GetMailboxContextFromCache(userContextKey); if (mailboxContextFromCache != null) { mailboxContextFromCache.NotificationManager.ReleaseSubscriptionsForChannelId(channelId); } } } return; } IL_71: ExTraceGlobals.NotificationsCallTracer.TraceError((long)this.GetHashCode(), "[RemoteNotificationManager::CleanUpChannel] mailboxSubscriptionsLock timed"); throw new OwaLockTimeoutException(string.Format("Could not acquire WriterLock on mailboxSubscriptions", new object[0])); }
private static IMailboxContext AcquireUserContext(HttpContext httpContext, AuthZClientInfo effectiveCaller, UserContextKey userContextKey, UserContextCookie userContextCookie) { IMailboxContext mailboxContext = null; UserContextStatistics userContextStatistics = null; try { if (userContextKey != null) { mailboxContext = UserContextManager.GetMailboxContextFromCache(userContextKey); if (mailboxContext == null || mailboxContext.State == UserContextState.Abandoned) { UserContextManager.CreateUserContext(httpContext, userContextKey, effectiveCaller, out mailboxContext, out userContextStatistics); } } else { UserContextManager.CreateUserContext(httpContext, null, effectiveCaller, out mailboxContext, out userContextStatistics); string cookieId = null; if (mailboxContext != null) { userContextCookie = UserContextCookie.CreateFromKey(cookieId, mailboxContext.Key, httpContext.Request.IsSecureConnection); httpContext.Response.Cookies.Set(userContextCookie.HttpCookie); userContextStatistics.CookieCreated = true; } } } finally { if (userContextStatistics != null) { SignInLogEvent logEvent = new SignInLogEvent(mailboxContext, (userContextCookie != null) ? userContextCookie.CookieValue : string.Empty, userContextStatistics, httpContext.Request.Url); OwaServerLogger.AppendToLog(logEvent); } } return(mailboxContext); }
private static void CreateUserContext(HttpContext httpContext, UserContextKey userContextKey, AuthZClientInfo effectiveCaller, out IMailboxContext userContext, out UserContextStatistics userContextStats) { Stopwatch stopwatch = Stopwatch.StartNew(); userContextStats = new UserContextStatistics(); userContext = null; OwaIdentity owaIdentity = null; OwaIdentity owaIdentity2 = null; OwaIdentity owaIdentity3 = null; try { try { OwaIdentity owaIdentity4 = OwaIdentity.ResolveLogonIdentity(httpContext, effectiveCaller); owaIdentity2 = owaIdentity4; string explicitLogonUser = UserContextUtilities.GetExplicitLogonUser(httpContext); if (!string.IsNullOrEmpty(explicitLogonUser)) { ExTraceGlobals.UserContextTracer.TraceDebug <string>(0L, "Created partial mailbox identity from SMTP address={0}", explicitLogonUser); owaIdentity = OwaIdentity.CreateOwaIdentityFromExplicitLogonAddress(explicitLogonUser); owaIdentity3 = owaIdentity; } if (userContextKey == null) { userContextKey = UserContextKey.CreateNew(owaIdentity4, owaIdentity, httpContext); ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Creating new user context key: {0}", userContextKey); } else { ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Reusing user context key: {0}", userContextKey); } OwaRWLockWrapper userContextKeyLock = UserContextManager.GetUserContextKeyLock(userContextKey.ToString()); if (userContextKeyLock == null) { userContextStats.Error = UserContextCreationError.UnableToAcquireOwaRWLock; throw new OwaLockException("UserContextManger::CreateUserContext was not able to create a lock"); } if (userContextKeyLock.LockWriterElastic(6000)) { try { userContext = UserContextManager.GetMailboxContextFromCache(userContextKey, false); if (userContext != null && userContext.TerminationStatus == UserContextTerminationStatus.TerminatePending) { UserContextManager.TerminateSession(userContext, userContext.AbandonedReason); userContext = null; } if (userContext == null) { userContextStats.Created = true; ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "User context was not found in the cache, creating one. UserContextKey: {0}", userContextKey); bool flag = false; try { if (UserContextManager.IsSharedContextKey(userContextKey)) { userContext = new SharedContext(userContextKey, httpContext.Request.UserAgent); } else { userContext = new UserContext(userContextKey, httpContext.Request.UserAgent); } Stopwatch stopwatch2 = Stopwatch.StartNew(); userContext.Load(owaIdentity4, owaIdentity, userContextStats); userContextStats.LoadTime = (int)stopwatch2.ElapsedMilliseconds; UserContextManager.InsertIntoCache(httpContext, userContext); owaIdentity2 = null; owaIdentity3 = null; string userName = userContext.LogonIdentity.UserSid.ToString(); PerformanceCounterManager.UpdatePerfCounteronUserContextCreation(userName, false, false, Globals.ArePerfCountersEnabled); flag = true; } finally { if (!flag) { ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "User context creation failed. UserContextKey: {0}", userContextKey); if (userContext != null) { ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Disposing user context. UserContextKey: {0}", userContextKey); userContext.Dispose(); userContext.State = UserContextState.Abandoned; } } } } goto IL_1EA; } finally { userContextKeyLock.ReleaseWriterLock(); } goto IL_1D4; IL_1EA: goto IL_237; } IL_1D4: userContextStats.Error = UserContextCreationError.UnableToAcquireOwaRWLock; throw new OwaLockTimeoutException("UserContextManger::CreateUserContext was not able to acquire a rw lock", null, null); } catch (OwaIdentityException ex) { userContextStats.Error = UserContextCreationError.UnableToResolveLogonIdentity; OwaServerTraceLogger.AppendToLog(new TraceLogEvent("UserContext", userContext, "UserContextManager.CreateUserContext", ex.ToString())); throw; } catch (Exception ex2) { OwaServerTraceLogger.AppendToLog(new TraceLogEvent("UserContext", userContext, "UserContextManager.CreateUserContext", ex2.ToString())); throw; } IL_237 :; } finally { if (owaIdentity2 != null) { owaIdentity2.Dispose(); } if (owaIdentity3 != null) { owaIdentity3.Dispose(); } stopwatch.Stop(); userContextStats.AcquireLatency = (int)stopwatch.ElapsedMilliseconds; httpContext.Items["UserContextStatistics"] = userContextStats; } }
internal static IMailboxContext GetMailboxContextFromCache(UserContextKey userContextKey) { return(UserContextManager.GetMailboxContextFromCache(userContextKey, true)); }