Пример #1
0
        protected override void OnBeginRequestInternal(HttpApplication httpApplication)
        {
            ExTraceGlobals.HttpModuleTracer.TraceFunction((long)this.GetHashCode(), "[RpsHttpProxyModule::OnBeginRequestInternal] Enter");
            HttpContext          context = httpApplication.Context;
            RequestDetailsLogger current = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(context);

            if (current != null)
            {
                RequestMonitor.Instance.RegisterRequest(current.ActivityId);
                string text = context.Request.Headers["Authorization"];
                byte[] bytes;
                byte[] array;
                if (!string.IsNullOrEmpty(text) && LiveIdBasicAuthModule.ParseCredentials(context, text, false, out bytes, out array))
                {
                    string      text2       = Encoding.UTF8.GetString(bytes).Trim();
                    SmtpAddress smtpAddress = new SmtpAddress(text2);
                    RequestMonitor.Instance.Log(current.ActivityId, RequestMonitorMetadata.AuthenticatedUser, text2);
                    RequestMonitor.Instance.Log(current.ActivityId, RequestMonitorMetadata.Organization, smtpAddress.Domain);
                    context.Items[Constants.WLIDMemberName] = text2;
                    ExTraceGlobals.HttpModuleTracer.TraceDebug <string>((long)this.GetHashCode(), "[RpsHttpProxyModule::OnBeginRequestInternal] LiveIdMember={0}", text2);
                }
            }
            base.OnBeginRequestInternal(httpApplication);
            ExTraceGlobals.HttpModuleTracer.TraceFunction((long)this.GetHashCode(), "[RpsHttpProxyModule::OnBeginRequestInternal] Exit");
        }
        // Token: 0x06000004 RID: 4 RVA: 0x000020E0 File Offset: 0x000002E0
        public bool TryParseUserToken(HttpContext context, out string userToken)
        {
            Logger.EnterFunction(ExTraceGlobals.FailFastModuleTracer, "BasicLiveIDAuthUserTokenParser.TryParseUserToken");
            userToken = null;
            if (context == null || context.Request == null)
            {
                Logger.TraceDebug(ExTraceGlobals.FailFastModuleTracer, "Context or Context.Request is null.", new object[0]);
                return(false);
            }
            string text = context.Request.Headers["X-WLID-MemberName"];

            if (!string.IsNullOrEmpty(text))
            {
                userToken = text;
            }
            else
            {
                string text2 = context.Request.Headers["Authorization"];
                byte[] bytes;
                byte[] array;
                if (!LiveIdBasicAuthModule.ParseCredentials(context, text2, false, out bytes, out array))
                {
                    Logger.TraceDebug(ExTraceGlobals.FailFastModuleTracer, "Auth header \"{0}\" is not Basic LiveID Auth format. Ignore this request in BasicLiveIDAuthUserTokenParser.", new object[]
                    {
                        text2
                    });
                    return(false);
                }
                userToken = Encoding.ASCII.GetString(bytes);
            }
            Logger.TraceDebug(ExTraceGlobals.FailFastModuleTracer, "Parse auth header and get user token {0}.", new object[]
            {
                userToken
            });
            Logger.ExitFunction(ExTraceGlobals.FailFastModuleTracer, "BasicLiveIDAuthUserTokenParser.TryParseUserToken");
            return(true);
        }