Hey Danny ever seen this..
Code:import java.util.ArrayList; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.cookie.Cookie; import org.apache.http.client.params.HttpClientParams; import org.apache.http.client.params.CookiePolicy; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.client.ResponseHandler; import org.apache.http.protocol.HTTP; public class VerifyRude { public boolean[] verify(String username, String password) throws Exception { System.out.println("Verifying rudeness: email, password"+ username + ", "+ password ); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setBooleanParameter("http.protocol.expect-continue",false); httpclient.getParams().setBooleanParameter("http.protocol.single-cookie-header", true); HttpClientParams.setCookiePolicy(httpclient.getParams(),CookiePolicy.BROWSER_COMPATIBILITY); ResponseHandler<String> handler = new BasicResponseHandler(); HttpPost httpost = new http://rude.com/main/session/login/"); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("username", username)); nvps.add(new BasicNameValuePair("password", password)); nvps.add(new BasicNameValuePair("Login", " Login ")); httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); String page = httpclient.execute(httpost, handler); List<Cookie> cookies = httpclient.getCookieStore().getCookies(); boolean[] b = {false, false}; if (!cookies.isEmpty()){ for(int i = 0; i < cookies.size();i++){ if(cookies.get(i).getName().matches("user_login_remember")){ System.out.println("Verifying rudeness: email, password"+ username + ", "+ password +" Login good"); b[0] = true; } } if (b[0]){ b[1] = page.indexOf("Your Email Address is NOT confirmed") == -1; System.out.println("Verifying rudeness: email, password"+ username + ", "+ password+ "Confirmed: " + b[1]); } } System.out.println(b[0] + " " + b[1]); return b; } }
Maybe some of you will have a use for this. Let me know how you are using this.





Reply With Quote
