addPost() публичный Метод

public addPost ( String field, String data ) : void
field String
data String
Результат void
Пример #1
0
        static void contact_rowan()
        {
            Boolean logged_in = false;
            HttpBrowserEntitiy browser = new HttpBrowserEntitiy();
            // Secure connections use SSL/TLS
            HttpConnection CAS_Con = browser.openSecureConnection("cas.rowan.edu", HttpBrowserEntitiy.PORTS.SSL, "cas.rowan.edu");
            var request = new HttpRequest("/cas/login");
            SignLoginRequest(request);
            WriteToFile(request.ToString());
            var response = CAS_Con.sendRequest(request);
            browser.processResponse(response);
            browser.SessionCookies.Remove("Path");
            WriteToFile(response.ToString());
            WriteToFile("");
            string resp = response.ToString();
            string lp = GetMiddleString(resp, "name=\"lt\" value=\"", "\" />");
            //WriteToFile(lp);
            //&execution = e4s1 & _eventId = submit & submit = LOGIN
            if (1 == 1)
            {
                request = new HttpRequest("POST", "/cas/login;jsessionid=" + browser.SessionCookies["JSESSIONID"]);
                request.cookies = browser.SessionCookies;
                SignLoginRequest(request);
                request.addHeader("Content-Type", "application/x-www-form-urlencoded");
                //"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                Console.Write("Enter Rowan Username: "******"username", Console.ReadLine());
                Console.Write("\r\nEnter Password(NOT HIDDEN): ");
                request.addPost("password", Console.ReadLine());
                request.addPost("lt", lp);
                request.addPost("execution", "e1s1");
                request.addPost("_eventId", "submit");
                request.addPost("submit", "LOGIN");
                request.guessContentLength();
                //WriteToFile(request.ToString());//  LETS NOT SEE EACHOTHER PASSWORD YES?!
                response = CAS_Con.sendRequest(request);
                WriteToFile(response.ToString() + Environment.NewLine);
                browser.processResponse(response);
                browser.SessionCookies.Remove("Path");

                if (response.Body.Contains(SUCCESS_STR))
                {
                    showMessage("You have logged in successfully.");
                    logged_in = true;
                }
                else
                {
                    showMessage("Login Failure!");
                    logged_in = false;
                }
            }
            if (logged_in)
            {
                showMessage("Press any key to log out.");
            }
            else
            {
                showMessage("Press enter to end.");
            }
            Console.Read();
            if (logged_in)
            {
                request = new HttpRequest("/cas/logout");
                SignLoginRequest(request);
                request.cookies = browser.SessionCookies;
                WriteToFile(request.ToString() + Environment.NewLine);
                response = CAS_Con.sendRequest(request);
                WriteToFile(response.ToString());

                if (response.Body.Contains(SUCCESS_STR))
                {
                    showMessage("You have logged in successfully.");
                }
                else
                {
                    showMessage("Error loggin out. This is weird..");
                    Console.Read();
                }
            }
        }
Пример #2
0
 static void Main(string[] args)
 {
     if (args.Length >= 0)
     {
         HttpBrowserEntitiy browser = new HttpBrowserEntitiy(true);
         HttpConnection CAS_Con = browser.openSecureConnection("10.0.0.67", HttpBrowserEntitiy.PORTS.SSL, "lamp");
         var request = new HttpRequest("POST", "/check_cas_auth.php");
         request.addHeader("Content-Type", "application/x-www-form-urlencoded");
         Console.Write("Enter Rowan Username: "******"username", Console.ReadLine());
         Console.Write("\r\nEnter Password(NOT HIDDEN): ");
         request.addPost("password", Console.ReadLine());
         request.guessContentLength();
         //WriteToFile(request.ToString());
         var response = CAS_Con.sendRequest(request);
         WriteToFile(response.Body);
         Console.Read();
     }
     else
     {
         contact_rowan();
     }
 }