Beispiel #1
0
 public static void Main(string[] args)
 {
     Rpx r = new Rpx(args[0], args[1]);
     if (args[2].Equals("mappings"))
     {
         Console.WriteLine("Mappings for " + args[3] + ":");
         foreach (string s in r.Mappings(args[3]))
         {
             Console.WriteLine(s);
         }
     }
     if (args[2].Equals("all_mappings"))
     {
         Console.WriteLine("All mappings:");
         foreach (KeyValuePair<string, ArrayList> pair in r.AllMappings())
         {
             Console.WriteLine(pair.Key + ":");
             foreach (string identifier in pair.Value)
             {
                 Console.WriteLine("  " + identifier);
             }
         }
     }
     if (args[2].Equals("map"))
     {
         Console.WriteLine(args[3] + " mapped to " + args[4]);
         r.Map(args[3], args[4]);
     }
     if (args[2].Equals("unmap"))
     {
         Console.WriteLine(args[3] + " unmapped from " + args[4]);
         r.Unmap(args[3], args[4]);
     }
 }
        public ActionResult Authenticate(string token, string returnUrl)
        {
            if (string.IsNullOrEmpty(token))
            {
                return ReturnWithError(returnUrl);
            }

            var rpx = new Rpx("87df721ebccbde5919f4258b45d8f3d0dc1db546", "https://shcil.rpxnow.com/");
            var response = rpx.AuthInfo(token);
            var parser = new RpxResponseParser(response);
            if (parser.Status != RpxReponseStatus.Ok)
            {
                return ReturnWithError(returnUrl);
            }
            else
            {
                var responseUser = parser.BuildUser();
                var user = _usersRepository.FindByOpenId(responseUser.OpenId);
                if (user == null)
                {
                    user = new User {
                        Email = responseUser.Email,
                        Friendly = responseUser.Friendly,
                        OpenId = responseUser.OpenId,
                        UserName = responseUser.UserName
                    };
                    DB.Users.Insert(user);
                }

                Response.AppendCookie(new HttpCookie("userId", user.Id.ToString()));

                return ReturnToUrl(returnUrl);
            }
        }