コード例 #1
0
        internal static Dictionary <Enum, string> GetAuthValues(this HttpContextBase context)
        {
            Dictionary <Enum, string> dictionary = new Dictionary <Enum, string>(9);

            if (context != null)
            {
                IDictionary     items   = context.Items;
                HttpRequestBase request = context.Request;
                dictionary.SetNonNullValue(ServiceCommonMetadata.IsAuthenticated, request.IsAuthenticated ? "true" : "false");
                string text         = items.GetContextItem("AuthType");
                string contextItem  = items.GetContextItem("AuthModuleLatency");
                string text2        = items.GetContextItem("WLID-MemberName");
                string contextItem2 = items.GetContextItem("AuthenticatedUserOrganization");
                if (string.IsNullOrEmpty(text) || text == "Unknown")
                {
                    text = context.GetAuthType();
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = request.GetRequestHeader("Authorization");
                    if (!string.IsNullOrEmpty(text))
                    {
                        text = text.Split(new char[]
                        {
                            ' '
                        })[0];
                    }
                }
                if (string.IsNullOrEmpty(text2))
                {
                    if (!string.IsNullOrEmpty(text2 = items.GetContextItem("LiveIdNegotiateMemberName")))
                    {
                        text = text + ";" + items.GetContextItem("NegoCap");
                    }
                    else if (string.IsNullOrEmpty(text2 = items.GetContextItem("RPSMemberName")))
                    {
                        if (!string.IsNullOrEmpty(text2 = items.GetContextItem("AuthenticatedUser")))
                        {
                            if (text2.Contains("\\"))
                            {
                                text2 = text2.Split(new char[]
                                {
                                    '\\'
                                })[1];
                            }
                        }
                        else
                        {
                            text2 = context.GetAuthUser();
                        }
                    }
                }
                dictionary.SetNonNullValue(ActivityStandardMetadata.AuthenticationType, text);
                dictionary.SetNonNullValue(ServiceLatencyMetadata.AuthModuleLatency, contextItem);
                dictionary.SetNonNullValue(ServiceCommonMetadata.LiveIdBasicLog, items.GetContextItem("LiveIdBasicLog"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.LiveIdBasicError, items.GetContextItem("LiveIdBasicError"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.LiveIdNegotiateError, items.GetContextItem("LiveIdNegotiateError"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.OAuthToken, items.GetContextItem("OAuthToken"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.OAuthError, items.GetContextItem("OAuthError"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.OAuthErrorCategory, items.GetContextItem("OAuthErrorCategory"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.OAuthExtraInfo, items.GetContextItem("OAuthExtraInfo"));
                dictionary.SetNonNullValue(ServiceCommonMetadata.AuthenticatedUser, text2);
                dictionary.SetNonNullValue(ActivityStandardMetadata.TenantId, contextItem2);
                dictionary.SetNonNullValue(ActivityStandardMetadata.Puid, items.GetContextItem("PassportUniqueId"));
            }
            return(dictionary);
        }