Example #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]);
        }
    }
Example #2
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]);
     }
 }
Example #3
0
        public static string janrainLogin(string token)
        {
            var rpx      = new Rpx("38b726baa689dd1afdcb82e91f905101e660d73a", "https://rpxnow.com");
            var authInfo = rpx.AuthInfo(token);
            var doc      = XDocument.Load(new XmlNodeReader(authInfo));

            return(doc.Root.Descendants("identifier").First().Value);
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var token    = Request.Form["token"];
            var rpx      = new Rpx("38b726baa689dd1afdcb82e91f905101e660d73a", "https://rpxnow.com");
            var authInfo = rpx.AuthInfo(token);
            var doc      = XDocument.Load(new XmlNodeReader(authInfo));

            Response.Write(doc.Root.Descendants("identifier").First().Value);
        }
Example #5
0
        public List <LoginResult> janrainLogin(string token)
        {
            var    rpx          = new Rpx("38b726baa689dd1afdcb82e91f905101e660d73a", "https://rpxnow.com");
            var    authInfo     = rpx.AuthInfo(token);
            var    doc          = XDocument.Load(new XmlNodeReader(authInfo));
            string jrIdentifier = doc.Root.Descendants("identifier").First().Value;
            string jrType       = doc.Root.Descendants("providerName").First().Value;
            string strStatus    = "ok";

            if (!UserData.checkUser(jrIdentifier))
            {
                strStatus = "new";
            }
            return(new List <LoginResult>()
            {
                new LoginResult()
                {
                    Status = strStatus, Identifier = jrIdentifier, Type = jrType
                }
            });
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Collections.Specialized.NameValueCollection nvc = Request.Form;

            string token = nvc["token"];

            Rpx xch = new Rpx("aab10eafde9a29f011760907b4a387f03ca560f1", "https://rpxnow.com");
            XmlElement xelement = xch.AuthInfo(token);
            foreach (XmlNode x1 in xelement.ChildNodes)
            {
                Traverse_Nodes(x1);
            }
            System.Data.DataTable dt = Worker.SqlTransaction("SELECT idMembership, idMember, CONCAT(firstname, ' ', lastname) AS fname, gender, CONCAT(city, ' ', state) AS location, latitude, longitude FROM member WHERE active = 1 AND email = '" + user_email + "'", (System.Configuration.ConfigurationManager.ConnectionStrings["hslayer_connection"]).ToString());
            if (dt.Rows.Count > 0)
            {
                Response.Cookies["hr_main_ck"]["user_id"] = dt.Rows[0]["idMember"].ToString();
                Response.Cookies["hr_main_ck"]["user_name"] = dt.Rows[0]["fname"].ToString();
                Response.Cookies["hr_main_ck"]["gender"] = dt.Rows[0]["gender"].ToString();
                Response.Cookies["hr_main_ck"]["location"] = ""; // dt.Rows[0]["location"].ToString();
                Response.Cookies["hr_main_ck"]["membership"] = dt.Rows[0]["idMembership"].ToString();
                Response.Cookies["hr_main_ck"]["last_visit"] = DateTime.Now.ToString();
                Response.Cookies["hr_main_ck"]["lat"] = dt.Rows[0]["latitude"].ToString();
                Response.Cookies["hr_main_ck"]["lng"] = dt.Rows[0]["longitude"].ToString();
                Response.Cookies["hr_main_ck"]["exp"] = DateTime.Now.AddDays(7).ToString();
                Response.Cookies["hr_main_ck"].Expires = DateTime.Now.AddDays(7);

                if (dt.Rows[0]["idMembership"].ToString() != "3")
                {
                    Response.Redirect("Profile.aspx?id=YmFyQmVy");
                }
                else
                {
                    Response.Redirect("Index.aspx");
                }
            }
            else
            {
                Response.Redirect("Signup.aspx");
            }
        }
Example #7
0
        public static string DoRpxLogin()
        {
            string redirect = HttpContext.Current.Request["redirect"];

            string     token = HttpContext.Current.Request["token"];
            XmlElement rpx   = new Rpx("26e68488dd7f567b1b0934bb6e2851d721f8473f", "https://rpxnow.com").AuthInfo(token);

            if (rpx == null)
            {
                return("An unexpected error occurred. Please try again.");
            }

            XmlElement id = (XmlElement)rpx.SelectSingleNode("profile/identifier");

            if (id == null || id.InnerText.Trim() == "")
            {
                return("An unexpected error occurred. Please try again. (RPX did not return an identifier.)");
            }

            // If we have this identifier in our database already, log
            // the user in.

            TableRow user_openid = Util.Database.DBSelectFirst(
                "users", "email, password", new Database.SpecEQ("openidurl", id.InnerText));

            if (user_openid != null)
            {
                DoLogin2((string)user_openid["email"], (string)user_openid["password"]);

                if (redirect == null || redirect.Trim() == "")
                {
                    redirect = "/users/account.xpd";
                }
            }
            else
            {
                // Otherwise, create an account if the email validates.

                //Console.Error.WriteLine(rpx.OuterXml);

                XmlElement email = (XmlElement)rpx.SelectSingleNode("profile/verifiedEmail");
                if (email == null)
                {
                    email = (XmlElement)rpx.SelectSingleNode("profile/email");
                }
                if (email == null)
                {
                    return("Your third-party account did not provide your email address to GovTrack, which you need in order to create an account. Change your third-party account settings to include an email address or use a different third-party account. You can also create a GovTrack username/password to register.");
                }
                try {
                    GovTrack.Web.Pages.Users.Account.ValidateEmail(email.InnerText, true);
                } catch (UserException ex) {
                    return("Your third-party account provided an invalid email address: " + ex.Message + " (Identity/OpenID URL: " + id.InnerText + ")");
                }

                // Create a random password for the account to allow
                // for logins the old-fashioned way.

                string password = "";
                Random random   = new Random();
                for (int i = 0; i < 10; i++)
                {
                    password += (char)((int)'A' + random.Next(26));
                }

                // Setup the database record

                Hashtable account = new Hashtable();
                account["email"]      = email.InnerText;
                account["password"]   = password;
                account["openidurl"]  = id.InnerText;
                account["created"]    = DateTime.Now;
                account["last_login"] = account["created"];

                ArrayList monitors = new ArrayList();
                monitors.AddRange(Login.GetMonitors());

                account["monitors"] = Login.EncodeMonitors(monitors);

                // Add the database record and log in the user.

                Util.Database.DBInsert("users", account);
                Login.DoLogin2(email.InnerText, password);

                if (redirect == null || redirect.Trim() == "")
                {
                    redirect = "/users/nowwhat.xpd";
                }
            }

            // Send the user on his way.

            HttpContext.Current.Response.Redirect(redirect);

            return("");
        }