public static bool IsAcsOAuthRequest(this HttpContext context)
        {
            if (context.User == null)
            {
                return(false);
            }
            RbacSession rbacSession = context.User as RbacSession;
            IIdentity   identity;

            if (rbacSession != null)
            {
                identity = rbacSession.Settings.LogonUserIdentity;
            }
            else
            {
                LogoffSession logoffSession = context.User as LogoffSession;
                if (logoffSession != null)
                {
                    identity = logoffSession.OriginalIdentity;
                }
                else
                {
                    identity = context.User.Identity;
                }
            }
            return(identity is OAuthIdentity || identity is SidOAuthIdentity || context.Items["LogonUserIdentity"] is SidOAuthIdentity);
        }
Beispiel #2
0
 public RbacSession CreateSession()
 {
     ExTraceGlobals.RBACTracer.TraceInformation <RbacSession.Factory, string>(0, 0L, "Testing if {0} can create a session for {1}.", this, this.Settings.UserName);
     if (this.CanCreateSession())
     {
         ExTraceGlobals.RBACTracer.TraceInformation <RbacSession.Factory, string>(0, 0L, "{0} accepted the request to create a session for {1}.", this, this.Settings.UserName);
         RbacSession rbacSession = this.CreateNewSession();
         ExTraceGlobals.RBACTracer.TraceInformation <RbacSession, string>(0, 0L, "Initializing {0} session for {1}.", rbacSession, this.Settings.UserName);
         rbacSession.Initialize();
         return(rbacSession);
     }
     ExTraceGlobals.RBACTracer.TraceInformation <RbacSession.Factory, string>(0, 0L, "{0} declined the request to create a session for {1}.", this, this.Settings.UserName);
     return(null);
 }
        public static string GetCanaryName(this HttpContext context)
        {
            DelegatedPrincipal delegatedPrincipal = null;

            if (context.User is RbacSession)
            {
                RbacSession rbacSession = (RbacSession)context.User;
                delegatedPrincipal = (rbacSession.Settings.OriginalUser as DelegatedPrincipal);
            }
            if (delegatedPrincipal == null)
            {
                return("msExchEcpCanary");
            }
            return("msExchEcpCanary.UID");
        }
Beispiel #4
0
        private RbacSession CreateSession()
        {
            RbacSession result;

            using (new AverageTimePerfCounter(EcpPerfCounters.AverageRbacSessionCreation, EcpPerfCounters.AverageRbacSessionCreationBase, true))
            {
                using (EcpPerformanceData.CreateRbacSession.StartRequestTimer())
                {
                    RbacContext rbacContext = new RbacContext(this);
                    RbacSession rbacSession = rbacContext.CreateSession();
                    RbacSettings.AddSessionToCache(this.CacheKey, rbacSession, true, true);
                    rbacSession.SessionStart();
                    result = rbacSession;
                }
            }
            return(result);
        }
Beispiel #5
0
        internal static void AddSessionToCache(string cacheKey, RbacSession session, bool canRemove, bool isNewSession)
        {
            Cache                    cache               = HttpRuntime.Cache;
            CacheDependency          dependencies        = null;
            DateTime                 absoluteExpiration  = (DateTime)ExDateTime.UtcNow.Add(RbacSection.Instance.RbacPrincipalMaximumAge);
            TimeSpan                 noSlidingExpiration = Cache.NoSlidingExpiration;
            CacheItemPriority        priority            = canRemove ? CacheItemPriority.High : CacheItemPriority.NotRemovable;
            CacheItemRemovedCallback onRemoveCallback;

            if (!isNewSession)
            {
                onRemoveCallback = null;
            }
            else
            {
                onRemoveCallback = delegate(string key, object value, CacheItemRemovedReason reason)
                {
                    ((RbacSession)value).SessionEnd();
                };
            }
            cache.Insert(cacheKey, session, dependencies, absoluteExpiration, noSlidingExpiration, priority, onRemoveCallback);
        }