Java Code Examples for org.apache.http.params.HttpParams#setParameter()

The following examples show how to use org.apache.http.params.HttpParams#setParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UploadBoxUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 6 votes vote down vote up
public static void loginUploadBox() throws Exception {
    HttpParams params = new BasicHttpParams();
    params.setParameter(
            "http.useragent",
            "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
    DefaultHttpClient httpclient = new DefaultHttpClient(params);

    System.out.println("Trying to log in to uploadbox.com");
    HttpPost httppost = new HttpPost("http://www.uploadbox.com/en");
    httppost.setHeader("Cookie", sidcookie);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("login", ""));
    formparams.add(new BasicNameValuePair("passwd", ""));
    formparams.add(new BasicNameValuePair("ac", "auth"));
    formparams.add(new BasicNameValuePair("back", ""));
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
    httppost.setEntity(entity);
    HttpResponse httpresponse = httpclient.execute(httppost);
    HttpEntity resEntity = httpresponse.getEntity();
    System.out.println(httpresponse.getStatusLine());

}
 
Example 2
Source File: StreamClientImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected HttpParams getRequestParams(StreamRequestMessage requestMessage) {
    HttpParams localParams = new BasicHttpParams();

    localParams.setParameter(
        CoreProtocolPNames.PROTOCOL_VERSION,
        requestMessage.getOperation().getHttpMinorVersion() == 0 ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1
    );

    // DefaultHttpClient adds HOST header automatically in its default processor

    // Add the default user agent if not already set on the message
    if (!requestMessage.getHeaders().containsKey(UpnpHeader.Type.USER_AGENT)) {
        HttpProtocolParams.setUserAgent(
            localParams,
            getConfiguration().getUserAgentValue(requestMessage.getUdaMajorVersion(), requestMessage.getUdaMinorVersion())
        );
    }

    return new DefaultedHttpParams(localParams, globalParams);
}
 
Example 3
Source File: BitShareUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 6 votes vote down vote up
public static void loginBitShare() throws Exception {
    HttpParams params = new BasicHttpParams();
    params.setParameter(
            "http.useragent",
            "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
    DefaultHttpClient httpclient = new DefaultHttpClient(params);
    
    System.out.println("Trying to log in to bitshare.com");
    HttpPost httppost = new HttpPost("http://bitshare.com/login.html");
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("user", "007007dinesh"));
    formparams.add(new BasicNameValuePair("password", ""));
    formparams.add(new BasicNameValuePair("submit", "Login"));
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
    httppost.setEntity(entity);
    HttpResponse httpresponse = httpclient.execute(httppost);
    Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
    Cookie escookie = null;
    while (it.hasNext()) {
        escookie = it.next();
        System.out.println(escookie.getName()+" = "+escookie.getValue());
    }
    
    System.out.println(EntityUtils.toString(httpresponse.getEntity()));
    
}
 
Example 4
Source File: CommonUploaderTasks.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This private method will send statistics to the server.
 * Download Links or Delete Links will not be sent for privacy reasons.
 * 
 * These data are used for analysis and cleared periodically to avoid exceeding quota.
 * 
 * @param up 
 */
private static void sendStats(Uploader up) {
    try {
        String status = up.getStatus().getDefaultLocaleSpecificString();
        if (!status.startsWith("Upload")) {
            return;
        }

        String hostName = up.getHost();
        if(hostName.contains("|")){
            hostName = hostName.substring(hostName.indexOf("|"));
            hostName = "account " + hostName;
        }

        NULogger.getLogger().info("Sending statistics..");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("version", pvp.getVersionForProgam() ) );
        formparams.add(new BasicNameValuePair("filename", up.getFileName()));
        formparams.add(new BasicNameValuePair("size", up.getSize()));
        formparams.add(new BasicNameValuePair("host", hostName));
        formparams.add(new BasicNameValuePair("status", status));
        formparams.add(new BasicNameValuePair("os", System.getProperty("os.name")));
        formparams.add(new BasicNameValuePair("locale", ulcp.getUserLanguageCode()
                /*NeembuuUploaderLanguages.getUserLanguageCode()*/));
        formparams.add(new BasicNameValuePair("uid", userP.getUserInstance().uidString()
                /*UserImpl.I().uidString()*/));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        HttpPost httppost = new HttpPost("http://neembuuuploader.sourceforge.net/insert.php");
        httppost.setEntity(entity);
        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        httppost.setParams(params);
        HttpClient httpclient = NUHttpClient.getHttpClient();
        EntityUtils.consume(httpclient.execute(httppost).getEntity());
    } catch (Exception ex) {
        NULogger.getLogger().log(Level.INFO, "Error while sending statistics\n{0}", ex);
    }
}
 
Example 5
Source File: CheckMajorUpdate.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @deprecated version.xml is located in update.zip which is used to get list 
 * of latest plugins
 */
@Deprecated 
private static String getVersionXmlOnline()throws IOException{
    HttpParams params = new BasicHttpParams();
    params.setParameter(
            "http.useragent",
            "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
    DefaultHttpClient httpclient = new DefaultHttpClient(params);
    HttpGet httpget = new HttpGet("http://neembuuuploader.sourceforge.net/version.xml");
    NULogger.getLogger().info("Checking for new version...");
    HttpResponse response = httpclient.execute(httpget);
    return EntityUtils.toString(response.getEntity());
}
 
Example 6
Source File: TwoSharedUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
public static void loginTwoShared() throws Exception {

        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        DefaultHttpClient httpclient = new DefaultHttpClient(params);

        System.out.println("Trying to log in to 2shared.com");
        HttpPost httppost = new HttpPost("http://www.2shared.com/login.jsp");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("login", "[email protected]"));
        formparams.add(new BasicNameValuePair("password", ""));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        httppost.setEntity(entity);
        HttpResponse httpresponse = httpclient.execute(httppost);
        System.out.println("Getting cookies........");
        Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
        Cookie escookie = null;
        
        cookies= new StringBuilder();
        
        while (it.hasNext()) {
            escookie = it.next();
            cookies.append(escookie.getName()).append("=").append(escookie.getValue()).append(";"); 
        }

        if (cookies.toString().contains("Login=")) {
            System.out.println("2Shared login success :)");
            
            System.out.println("Cookies : "+cookies);
        } else {
            System.out.println("2Shared login failed :(");
        }

    }
 
Example 7
Source File: UrlRewriteTest.java    From cloud-odata-java with Apache License 2.0 5 votes vote down vote up
private HttpRequestBase createRedirectRequest(final Class<? extends HttpRequestBase> clazz) throws Exception {
  String endpoint = getEndpoint().toASCIIString();
  endpoint = endpoint.substring(0, endpoint.length() - 1);

  final HttpRequestBase httpMethod = clazz.newInstance();
  httpMethod.setURI(URI.create(endpoint));

  final HttpParams params = new BasicHttpParams();
  params.setParameter("http.protocol.handle-redirects", false);
  httpMethod.setParams(params);
  return httpMethod;
}
 
Example 8
Source File: FileFactoryUploadPlugin.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
public static void loginFileFactory() throws Exception {
        loginsuccessful = false;
        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        DefaultHttpClient httpclient = new DefaultHttpClient(params);

        System.out.println("Trying to log in to filefactory.com");
        HttpPost httppost = new HttpPost("http://www.filefactory.com/member/login.php");
//        httppost.setHeader("Cookie", filefactorycookie);
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("redirect", "/"));
        formparams.add(new BasicNameValuePair("email", uname));
        formparams.add(new BasicNameValuePair("password", pwd));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        httppost.setEntity(entity);
        HttpResponse httpresponse = httpclient.execute(httppost);
        System.out.println("Getting cookies........");
        Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
        Cookie escookie = null;
        while (it.hasNext()) {
            escookie = it.next();
            System.out.println(escookie.getName() + " : " + escookie.getValue());
            if (escookie.getName().equalsIgnoreCase("ff_membership")) {
                membershipcookie = escookie.getValue();
                System.out.println(membershipcookie);
                loginsuccessful=true;
                System.out.println("FileFactory Login successful :)");
                break;
            }
        }
        if (!loginsuccessful) {
            System.out.println("FileFactory login failed :(");
            throw new Exception();
        }

//        System.out.println(EntityUtils.toString(httpresponse.getEntity()));

    }
 
Example 9
Source File: ZShareUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
public static void loginZshare() throws Exception {
    HttpParams params = new BasicHttpParams();
    params.setParameter(
            "http.useragent",
            "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
    DefaultHttpClient httpclient = new DefaultHttpClient(params);

    System.out.println("Trying to log in to zshare.ma");
    HttpPost httppost = new HttpPost(zsharedomain);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("op", "login"));
    formparams.add(new BasicNameValuePair("login", uname));
    formparams.add(new BasicNameValuePair("password", pwd));
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
    httppost.setEntity(entity);
    HttpResponse httpresponse = httpclient.execute(httppost);
    System.out.println("Getting cookies........");
    Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
    Cookie escookie = null;

    while (it.hasNext()) {
        escookie = it.next();
        System.out.println(escookie.getName() + "=" + escookie.getValue());
        if (escookie.getName().equalsIgnoreCase("xfss")) {
            xfsscookie = "xfss=" + escookie.getValue();
            System.out.println(xfsscookie);
            login = true;
            System.out.println("Zshare Login success :)");
        }

    }
    if (!login) {
        System.out.println("Zshare login failed :(");
    }

}
 
Example 10
Source File: FileSonicUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
public void loginFileSonic() throws IOException {



        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        DefaultHttpClient httpclient = new DefaultHttpClient(params);

        System.out.println("Trying to log in to FileSonic");
        HttpPost httppost = new HttpPost(filesoniclink + "/user/login");
        httppost.setHeader("Referer", "http://www.filesonic.com/");
        httppost.setHeader("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("email", uname));
        formparams.add(new BasicNameValuePair("password", pwd));
        formparams.add(new BasicNameValuePair("redirect", "/"));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        httppost.setEntity(entity);
        HttpResponse httpresponse = httpclient.execute(httppost);

        System.out.println("Getting cookies........");
        Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
        Cookie escookie = null;
        while (it.hasNext()) {
            escookie = it.next();
            if (escookie.getName().equalsIgnoreCase("PHPSESSID")) {
                sessioncookie = "PHPSESSID=" + escookie.getValue();
                System.out.println(sessioncookie);
            }
            if (escookie.getName().equalsIgnoreCase("email")) {
                mailcookie = "email=" + escookie.getValue();
                login = true;
                System.out.println(mailcookie);
            }
            if (escookie.getName().equalsIgnoreCase("nickname")) {
                namecookie = "nickname=" + escookie.getValue();
                System.out.println(namecookie);
            }
            if (escookie.getName().equalsIgnoreCase("isAffiliate")) {
                affiliatecookie = "isAffiliate=" + escookie.getValue();
                System.out.println(affiliatecookie);
            }
            if (escookie.getName().equalsIgnoreCase("role")) {
                rolecookie = "role=" + escookie.getValue();
                System.out.println(rolecookie);
            }

        }
        if (login) {
            System.out.println("Login Success");
//            getMessagingCookies();
        } else {
            System.out.println("Login failed");
        }

    }
 
Example 11
Source File: GRuploadAccount.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
public void login() {

        loginsuccessful = false;
        try {

            HttpParams params = new BasicHttpParams();
            params.setParameter(
                    "http.useragent",
                    "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
            DefaultHttpClient httpclient = new DefaultHttpClient(params);

            NULogger.getLogger().info("Trying to log in to grupload.com");
            HttpPost httppost = new HttpPost("http://grupload.com/");
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();

            formparams.add(new BasicNameValuePair("op", "login"));
            formparams.add(new BasicNameValuePair("redirect", "http://grupload.com"));
            formparams.add(new BasicNameValuePair("login", getUsername()));
            formparams.add(new BasicNameValuePair("password", getPassword()));
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
            httppost.setEntity(entity);
            HttpResponse httpresponse = httpclient.execute(httppost);

            NULogger.getLogger().info("Getting cookies........");
            Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
            Cookie escookie = null;
            while (it.hasNext()) {
                escookie = it.next();
                if (escookie.getName().equalsIgnoreCase("login")) {
                    logincookie = "login=" + escookie.getValue();
                    NULogger.getLogger().info(logincookie);
                }
                if (escookie.getName().equalsIgnoreCase("xfss")) {
                    xfsscookie = "xfss=" + escookie.getValue();
                    NULogger.getLogger().info(xfsscookie);
                    loginsuccessful = true;
                }
            }

            if (loginsuccessful) {
                loginsuccessful = true;
                username = getUsername();
                password = getPassword();
                NULogger.getLogger().info("Grupload Login successful :)");
            } else {
                loginsuccessful = false;
                username = "";
                password = "";
                showWarningMessage( Translation.T().loginerror(), HOSTNAME);
                accountUIShow().setVisible(true);
                NULogger.getLogger().info("Grupload Login failed :(");
            }
            httpclient.getConnectionManager().shutdown();
        } catch (Exception e) {

            NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[]{getClass().getName(), e.toString()});
            System.err.println(e);

        }

    }
 
Example 12
Source File: ImageShackUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
private static void loginImageShack() throws Exception {
    HttpParams params = new BasicHttpParams();
    params.setParameter(
            "http.useragent",
            "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
    DefaultHttpClient httpclient = new DefaultHttpClient(params);

    System.out.println("Trying to log in to imageshack.us");
    HttpPost httppost = new HttpPost("http://imageshack.us/auth.php");
    httppost.setHeader("Referer", "http://www.uploading.com/");
    httppost.setHeader("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
    httppost.setHeader("Cookie", newcookie + ";" + phpsessioncookie + ";" + imgshckcookie + ";" + uncookie + ";" + latestcookie + ";" + langcookie);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("username", ""));
    formparams.add(new BasicNameValuePair("password", ""));
    formparams.add(new BasicNameValuePair("stay_logged_in", ""));
    formparams.add(new BasicNameValuePair("format", "json"));
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
    httppost.setEntity(entity);
    HttpResponse httpresponse = httpclient.execute(httppost);
    HttpEntity en = httpresponse.getEntity();
    uploadresponse = EntityUtils.toString(en);
    System.out.println("Upload response : " + uploadresponse);
    System.out.println("Getting cookies........");
    Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
    Cookie escookie = null;
    while (it.hasNext()) {
        escookie = it.next();
        if (escookie.getName().equalsIgnoreCase("myid")) {
            myidcookie = escookie.getValue();
            System.out.println(myidcookie);
            login = true;

        }
        if (escookie.getName().equalsIgnoreCase("myimages")) {
            myimagescookie = escookie.getValue();
            System.out.println(myimagescookie);
        }
        if (escookie.getName().equalsIgnoreCase("isUSER")) {
            usercookie = escookie.getValue();
            System.out.println(usercookie);
        }
    }

}
 
Example 13
Source File: RapidGatorUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
public static void loginRapidGator() throws Exception {
        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        DefaultHttpClient httpclient = new DefaultHttpClient(params);

        loginCookie = new StringBuilder();

        System.out.println("Trying to log in to rapidgator.net");

        HttpPost httppost = new HttpPost("http://rapidgator.net/auth/login");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
//        formparams.add(new BasicNameValuePair("t", tvalue));
        formparams.add(new BasicNameValuePair("LoginForm[email]:", "[email protected]"));
        formparams.add(new BasicNameValuePair("LoginForm[password]:", ""));


//        formparams.add(new BasicNameValuePair("remember", "1"));
//        formparams.add(new BasicNameValuePair("username", ""));
//        formparams.add(new BasicNameValuePair("password", ""));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        httppost.setEntity(entity);
        HttpResponse httpresponse = httpclient.execute(httppost);


//        String loginResponse = EntityUtils.toString(httpresponse.getEntity());


        Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
        Cookie escookie = null;
        while (it.hasNext()) {
            escookie = it.next();
            loginCookie.append(escookie.getName()).append("=").append(escookie.getValue()).append(";");
            System.out.println(escookie.getName() + " : " + escookie.getValue());

        }

        if (loginCookie.toString().contains("user")) {
            System.out.println("RapidGator Login succeeded :)");
        } else {
            System.out.println("RapidGator login failed :(");
        }
    }
 
Example 14
Source File: CrockoUploaderPlugin.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
public static void loginCrocko() throws Exception {


        cookies = new StringBuilder();
        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        DefaultHttpClient httpclient = new DefaultHttpClient(params);

        System.out.println("Trying to log in to crocko.com");
        HttpPost httppost = new HttpPost("https://www.crocko.com/accounts/login");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("login", "007007dinesh"));
        formparams.add(new BasicNameValuePair("password", "*********************"));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        httppost.setEntity(entity);
        HttpResponse httpresponse = httpclient.execute(httppost);
        System.out.println("Getting cookies........");
        System.out.println(EntityUtils.toString(httpresponse.getEntity()));
        Iterator<Cookie> it = httpclient.getCookieStore().getCookies().iterator();
        Cookie escookie = null;
        while (it.hasNext()) {
            escookie = it.next();
            cookies.append(escookie.getName()).append("=").append(escookie.getValue()).append(";");
//       
            if (escookie.getName().equals("PHPSESSID")) {
                sessionid = escookie.getValue();
                System.out.println(sessionid);
            }
        }

        if (cookies.toString().contains("logacc")) {
            System.out.println(cookies);
            login = true;
            System.out.println("Crocko login successful :)");
            getData();
        }
        if (!login) {
            System.out.println("Crocko.com Login failed :(");
        }


    }
 
Example 15
Source File: EasyShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void login() {
    try {
        loginsuccessful = false;
        HttpParams params = new BasicHttpParams();
        params.setParameter(
                "http.useragent",
                "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
        DefaultHttpClient eshttpclient = new DefaultHttpClient(params);

        NULogger.getLogger().info("Trying to log in to EasyShare");
        HttpPost httppost = new HttpPost("http://www.easy-share.com/accounts/login");
        httppost.setHeader("Referer", "http://www.easy-share.com/");
        httppost.setHeader("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("login", getUsername()));
        formparams.add(new BasicNameValuePair("password", getPassword()));
        formparams.add(new BasicNameValuePair("remember", "1"));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
        ////////////////////////////////////////////////////////////////////
        httppost.setEntity(entity);
        HttpResponse httpresponse = eshttpclient.execute(httppost);
        //Check success
        if (httpresponse.getFirstHeader("Set-Cookie") == null) {
            NULogger.getLogger().info("Easy-share login not successful");
            loginsuccessful = false;
            username = "";
            password = "";
            showWarningMessage( Translation.T().loginerror(), HOSTNAME);
            accountUIShow().setVisible(true);
        } else {
            Iterator<Cookie> it = eshttpclient.getCookieStore().getCookies().iterator();
            Cookie escookie;
            while (it.hasNext()) {
                escookie = it.next();
                if (escookie.getName().equals("logacc") && escookie.getValue().equals("1")) {
                    NULogger.getLogger().info("EasyShare login successful");
                    loginsuccessful = true;
                    username = getUsername();
                    password = getPassword();
                    break;
                }
            }
            if (!loginsuccessful) {
                showWarningMessage( Translation.T().loginerror(), HOSTNAME);
                accountUIShow().setVisible(true);
            }
        }
        EntityUtils.consume(httpresponse.getEntity());
    } catch (Exception ex) {
        NULogger.getLogger().log(Level.SEVERE, "{0}: Error in $EasyShare Login", getClass().getName());
    }
}
 
Example 16
Source File: AsyncHttpClient.java    From AndroidWear-OpenWear with MIT License 3 votes vote down vote up
/**
 * Sets the Proxy by it's hostname,port,username and password
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 * @param username the username
 * @param password the password
 */
public void setProxy(String hostname, int port, String username, String password) {
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(hostname, port),
            new UsernamePasswordCredentials(username, password));
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
Example 17
Source File: AsyncHttpClient.java    From AndroidWear-OpenWear with MIT License 2 votes vote down vote up
/**
 * Sets the Proxy by it's hostname and port
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 */
public void setProxy(String hostname, int port) {
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
Example 18
Source File: AsyncHttpClient.java    From android-project-wo2b with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the Proxy by it's hostname and port
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 */
public void setProxy(String hostname, int port) {
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
Example 19
Source File: AsyncHttpClient.java    From Libraries-for-Android-Developers with MIT License 2 votes vote down vote up
/**
 * Sets the Proxy by it's hostname and port
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 */
public void setProxy(String hostname, int port) {
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
Example 20
Source File: AsyncHttpClient.java    From Android-Basics-Codes with Artistic License 2.0 2 votes vote down vote up
/**
 * Sets the Proxy by it's hostname and port
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 */
public void setProxy(String hostname, int port) {
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}