Ejemplo n.º 1
0
  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to FileParadox.in");
      httpPost = new NUHttpPost("http://fileparadox.in");

      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("op", "login"));
      formparams.add(new BasicNameValuePair("login", getUsername()));
      formparams.add(new BasicNameValuePair("password", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);
      httpResponse = httpclient.execute(httpPost, httpContext);
      NULogger.getLogger().info(httpResponse.getStatusLine().toString());
      Header lastHeader = httpResponse.getLastHeader("Location");

      if (lastHeader != null && lastHeader.getValue().contains("op=upload_form")) {
        EntityUtils.consume(httpResponse.getEntity());
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("FileParadox.in login successful!");

      } else {
        // Get error message
        responseString = EntityUtils.toString(httpResponse.getEntity());
        // FileUtils.saveInFile("FileParadoxAccount.html", responseString);
        Document doc = Jsoup.parse(responseString);
        String error = doc.select(".err").first().text();

        if ("Incorrect Login or Password".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }
    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      AccountsManager.getInstance().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to bayfiles.com");
      httpPost = new NUHttpPost("http://bayfiles.net/ajax_login");
      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("action", "login"));
      formparams.add(new BasicNameValuePair("username", getUsername()));
      formparams.add(new BasicNameValuePair("password", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);

      httpResponse = httpclient.execute(httpPost, httpContext);
      stringResponse = EntityUtils.toString(httpResponse.getEntity());

      // NULogger.getLogger().log(Level.INFO, "BayFiles.com stringResponse: {0}", stringResponse);

      jSonOjbject = new JSONObject(stringResponse);

      if (jSonOjbject.has("reload")) {
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("Bayfiles.com login succeeded :)");
      } else {
        String error = jSonOjbject.getString("error");

        if ("Login failed. Please try again".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }

    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      AccountsManager.getInstance().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }
Ejemplo n.º 3
0
 @Override
 public void printError() {
   Logger.getLogger(getClass().getName()).log(Level.SEVERE, this.getMessage());
   JOptionPane.showMessageDialog(
       NeembuuUploader.getInstance(),
       "<html><b>"
           + fileName
           + ":<br/>"
           + TranslationProvider.get("neembuuuploader.exceptions." + this.getMessage())
           + "</html>",
       this.hostName,
       JOptionPane.WARNING_MESSAGE);
 }
Ejemplo n.º 4
0
  public void loginUploadBox() 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);

    NULogger.getLogger().info("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", getUsername()));
    formparams.add(new BasicNameValuePair("passwd", getPassword()));
    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);
    if (httpresponse.getStatusLine().toString().contains("302")) {
      loginsuccessful = true;
      NULogger.getLogger().info("UploadBox Login Success");
      username = getUsername();
      password = getPassword();
    } else {
      loginsuccessful = false;
      NULogger.getLogger().info("UploadBox Login failed");
      username = "";
      password = "";
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }