コード例 #1
0
ファイル: FireDrive.java プロジェクト: tetratec/AutoSite
  @Override
  public void run() {
    uploadInitialising();
    try {
      if (fireDriveAccount.loginsuccessful) {
        httpContext = fireDriveAccount.getHttpContext();

        if (fireDriveAccount.isPremium()) {
          maxFileSizeLimit = 53687091200l; // 50 GB
        } else {
          maxFileSizeLimit = 1073741824l; // 1 GB
        }

      } else {
        httpContext.setAttribute(ClientContext.COOKIE_STORE, new BasicCookieStore());
      }

      if (file.length() > maxFileSizeLimit) {
        throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), getHost());
      }

      normalUpload();
      uploadFinished();
    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      NULogger.getLogger().log(Level.INFO, "Exception: {0}", e);
      uploadFailed();
    }
  }
コード例 #2
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);
    }
  }
コード例 #3
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);
    }
  }
コード例 #4
0
ファイル: FileCloud.java プロジェクト: tetratec/AutoSite
  @Override
  public void run() {

    try {
      if (fileCloudAccount.loginsuccessful) {
        host = fileCloudAccount.username + " | FileCloud.io";
      } else {
        host = "FileCloud.io";

        uploadInvalid();
        return;
      }

      // Check file size (max)
      if (file.length() > maxFileSizeLimit) {
        throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
      }

      // Check file size (min)
      if (file.length() < minFileSizeLimit) {
        throw new NUMinFileSizeException(minFileSizeLimit, file.getName(), host);
      }

      uploadInitialising();
      NULogger.getLogger().info("Getting upload url from FileCloud.....");
      stringResponse =
          NUHttpClientUtils.getData(
              "http://api.filecloud.io/api-fetch_upload_url.api?response=json");

      // Get JSONObject
      jSonObject = new JSONObject(stringResponse);
      String responseStatus = jSonObject.getString("status");

      if ("ok".equals(responseStatus)) {
        uploadURL = jSonObject.getString("upload_url");
        NULogger.getLogger().log(Level.INFO, "FileCloud Upload URL : {0}", uploadURL);
        fileUpload();
        uploadFinished();
      } else {
        // Handle errors
        throw new Exception("Error: " + jSonObject.getString("message"));
      }

    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      Logger.getLogger(FileCloud.class.getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }
コード例 #5
0
ファイル: AnonFiles.java プロジェクト: tetratec/AutoSite
  @Override
  public void run() {
    try {

      // Check size
      if (file.length() > maxFileSizeLimit) {
        throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
      }

      addExtensions();

      // Check extension
      if (!FileUtils.checkFileExtension(allowedExtensions, file)) {
        throw new NUFileExtensionException(file.getName(), host);
      }

      uploadInitialising();

      httpPost = new NUHttpPost(uploadURL);
      MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      mpEntity.addPart("file", createMonitoredFileBody());
      httpPost.setEntity(mpEntity);

      NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
      NULogger.getLogger().info("Now uploading your file into AnonFiles.com");
      uploading();
      httpResponse = httpclient.execute(httpPost);
      responseString = EntityUtils.toString(httpResponse.getEntity());

      // Read the links
      gettingLink();
      jSonObject = new JSONObject(responseString);
      if (jSonObject.getString("status").equals("success")) {
        downloadlink = jSonObject.getString("url");
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
      } else {
        throw new Exception("Upload failed: " + jSonObject.getString("msg"));
      }

      downURL = downloadlink;

      uploadFinished();
    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }