Example #1
0
        public override IClaimsIdentity ProcessSignInResponse(string realm, string originalUrl, HttpContextBase httpContext)
        {
            var client = new YahooOpenIdClient();

            AuthenticationResult result;
            try
            {
                result = client.VerifyAuthentication(httpContext);
            }
            catch (WebException wex)
            {
                throw new InvalidOperationException(new StreamReader(wex.Response.GetResponseStream()).ReadToEnd(), wex);
            }

            var claims = new List<Claim>
                {
                    new Claim(System.IdentityModel.Claims.ClaimTypes.NameIdentifier, result.ExtraData["email"])
                };

            foreach (var claim in result.ExtraData)
            {
                claims.Add(new Claim("http://schemas.yahoo.com/" + claim.Key, claim.Value));
            }

            return new ClaimsIdentity(claims, "Yahoo");
        }
        /// <summary>
        /// Registers a supported OpenID client
        /// </summary>
        public static void RegisterOpenIDClient(BuiltInOpenIDClient openIDClient)
        {
            IAuthenticationClient client;
            switch (openIDClient)
            {
                case BuiltInOpenIDClient.Google:
                    client = new GoogleOpenIdClient();
                    break;

                case BuiltInOpenIDClient.Yahoo:
                    client = new YahooOpenIdClient();
                    break;

                default:
                    throw new ArgumentOutOfRangeException("openIDClient");
            }

            RegisterClient(client);
        }
Example #3
0
 public override void ProcessSignInRequest(Scope scope, HttpContextBase httpContext)
 {
     var client = new YahooOpenIdClient();
     client.RequestAuthentication(httpContext, this.MultiProtocolIssuer.ReplyUrl);
 }