Пример #1
0
        internal static UniversalProfile ProfileFromOpenId(ClaimsResponse spprofile, FetchResponse fetchprofile, string claimedId)
        {
            var profile = new UniversalProfile
            {
                Link     = claimedId,
                Id       = claimedId,
                Provider = "openid",
            };

            if (spprofile != null)
            {
                //Fill
                profile.BirthDay    = spprofile.BirthDateRaw;
                profile.DisplayName = spprofile.FullName;
                profile.EMail       = spprofile.Email;
                profile.Name        = spprofile.Nickname;
                profile.Gender      = spprofile.Gender.HasValue ? spprofile.Gender.Value.ToString() : "";
                profile.TimeZone    = spprofile.TimeZone;
                profile.Locale      = spprofile.Language;
            }
            if (fetchprofile != null)
            {
                profile.Name        = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Alias);
                profile.LastName    = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Last);
                profile.FirstName   = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.First);
                profile.DisplayName = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.FullName);
                profile.MiddleName  = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Middle);
                profile.Salutation  = fetchprofile.GetAttributeValue(WellKnownAttributes.Name.Prefix);
                profile.Avatar      = fetchprofile.GetAttributeValue(WellKnownAttributes.Media.Images.Default);
                profile.EMail       = fetchprofile.GetAttributeValue(WellKnownAttributes.Contact.Email);
                profile.Gender      = fetchprofile.GetAttributeValue(WellKnownAttributes.Person.Gender);
                profile.BirthDay    = fetchprofile.GetAttributeValue(WellKnownAttributes.BirthDate.WholeBirthDate);
            }
            return(profile);
        }
Пример #2
0
        internal static UniversalProfile CreateFromSerializedString(string serialized)
        {
            var profile = new UniversalProfile();

            profile.FromSerializedString(serialized);
            return(profile);
        }
Пример #3
0
        internal static UniversalProfile FromError(Exception e)
        {
            var profile = new UniversalProfile {
                AuthorizationError = e.Message
            };

            return(profile);
        }
Пример #4
0
        internal static UniversalProfile ProfileFromTwitter(XDocument info)
        {
            XPathNavigator nav     = info.CreateNavigator();
            var            profile = new UniversalProfile
            {
                Name        = nav.SelectNodeValue("//screen_name"),
                DisplayName = nav.SelectNodeValue("//name"),
                Avatar      = nav.SelectNodeValue("//profile_image_url"),
                TimeZone    = nav.SelectNodeValue("//time_zone"),
                Locale      = nav.SelectNodeValue("//lang"),
                Id          = nav.SelectNodeValue("//id"),
                Link        = nav.SelectNodeValue("//url"),
                Provider    = "twitter"
            };

            return(profile);
        }
Пример #5
0
        public static UniversalProfile GetProfile(this Uri uri)
        {
            var profile     = new UniversalProfile();
            var queryString = HttpUtility.ParseQueryString(uri.Query);

            if (!string.IsNullOrEmpty(queryString[UniversalProfile.QuerySessionParamName]) && HttpContext.Current != null && HttpContext.Current.Session != null)
            {
                return((UniversalProfile)HttpContext.Current.Session[queryString[UniversalProfile.QuerySessionParamName]]);
            }
            if (!string.IsNullOrEmpty(queryString[UniversalProfile.QueryParamName]))
            {
                profile.ParseFromUrl(uri);
            }
            if (!string.IsNullOrEmpty(queryString[UniversalProfile.QueryCacheParamName]))
            {
                return((UniversalProfile)HttpRuntime.Cache.Get(queryString[UniversalProfile.QuerySessionParamName]));
            }
            return(profile);
        }
Пример #6
0
        internal static UniversalProfile ProfileFromFacebook(FacebookGraph graph)
        {
            var profile = new UniversalProfile
            {
                BirthDay    = graph.Birthday,
                Link        = graph.Link.ToString(),
                FirstName   = graph.FirstName,
                LastName    = graph.LastName,
                Gender      = graph.Gender,
                DisplayName = graph.FirstName + graph.LastName,
                EMail       = graph.Email,
                Id          = graph.Id.ToString(),
                TimeZone    = graph.Timezone,
                Locale      = graph.Locale,
                Provider    = "facebook"
            };

            return(profile);
        }
Пример #7
0
 public static Uri AddProfileCache(this Uri uri, UniversalProfile profile)
 {
     return(profile.AppendCacheProfile(uri));
 }
Пример #8
0
 public static Uri AddProfileSession(this Uri uri, UniversalProfile profile, HttpContext context)
 {
     return(profile.AppendSessionProfile(uri, context));
 }