Exemplo n.º 1
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       prepBrowser(br);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch)
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       getPage(COOKIE_HOST + "/login.html");
       final Form loginform = br.getFormbyProperty("name", "FL");
       if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       loginform.put("login", Encoding.urlEncode(account.getUser()));
       loginform.put("password", Encoding.urlEncode(account.getPass()));
       sendForm(loginform);
       if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       if (!br.getURL().contains("/?op=my_account")) {
         getPage("/?op=my_account");
       }
       if (!new Regex(correctedBR, "(Premium(\\-| )Account expire|>Renew premium<)").matches()) {
         account.setProperty("nopremium", true);
       } else {
         account.setProperty("nopremium", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
Exemplo n.º 2
0
 private void saveDownloadSession(DownloadLink link, Browser lbr) throws PluginException {
   if (link == null || lbr == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   final HashMap<String, String> cookies = new HashMap<String, String>();
   final Cookies add = lbr.getCookies(this.getHost());
   for (final Cookie c : add.getCookies()) {
     cookies.put(c.getKey(), c.getValue());
   }
   link.setProperty("cookies", cookies);
   link.setProperty("userAgent", lbr.getHeaders().get("User-Agent"));
 }
Exemplo n.º 3
0
 @SuppressWarnings("unchecked")
 private void login(Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     /** Load cookies */
     br.setCookiesExclusive(false);
     br.setFollowRedirects(true);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         Encoding.urlEncode(account.getUser())
             .matches(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
     if (acmatch)
       acmatch =
           Encoding.urlEncode(account.getPass())
               .matches(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
     if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       if (account.isValid()) {
         for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
           final String key = cookieEntry.getKey();
           final String value = cookieEntry.getValue();
           this.br.setCookie(COOKIE_HOST, key, value);
         }
         return;
       }
     }
     br.setCookie(COOKIE_HOST, "lang", "english");
     br.getPage(COOKIE_HOST + "/login.html");
     Form loginform = br.getForm(0);
     if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     loginform.put("login", Encoding.urlEncode(account.getUser()));
     loginform.put("password", Encoding.urlEncode(account.getPass()));
     br.submitForm(loginform);
     if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     br.getPage(COOKIE_HOST + "/?op=my_account");
     doSomething();
     if (!new Regex(BRBEFORE, "(Premium\\-Account expire|Upgrade to premium|>Renew premium<)")
         .matches())
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     if (!new Regex(BRBEFORE, "(Premium\\-Account expire|>Renew premium<)").matches())
       account.setProperty("nopremium", "true");
     /** Save cookies */
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(COOKIE_HOST);
     for (final Cookie c : add.getCookies()) {
       cookies.put(c.getKey(), c.getValue());
     }
     account.setProperty("name", Encoding.urlEncode(account.getUser()));
     account.setProperty("pass", Encoding.urlEncode(account.getPass()));
     account.setProperty("cookies", cookies);
   }
 }
Exemplo n.º 4
0
 private boolean getUserLogin() throws IOException, DecrypterException {
   br.setFollowRedirects(true);
   String username = null;
   String password = null;
   synchronized (LOCK) {
     username = this.getPluginConfig().getStringProperty("user", null);
     password = this.getPluginConfig().getStringProperty("pass", null);
     if (username != null && password != null) {
       br.postPage(
           POSTPAGE,
           "user="******"&passwrd="
               + Encoding.urlEncode(password)
               + "&cookielength=2&hash_passwrd=");
     }
     for (int i = 0; i < 3; i++) {
       boolean valid = false;
       final Cookies allCookies = this.br.getCookies(MAINPAGE);
       for (final Cookie c : allCookies.getCookies()) {
         if (c.getKey().contains("SMFCookie")) {
           valid = true;
           break;
         }
       }
       if (!valid) {
         this.getPluginConfig().setProperty("user", Property.NULL);
         this.getPluginConfig().setProperty("pass", Property.NULL);
         username =
             UserIO.getInstance().requestInputDialog("Enter Loginname for " + DOMAIN + " :");
         if (username == null) return false;
         password = UserIO.getInstance().requestInputDialog("Enter password for " + DOMAIN + " :");
         if (password == null) return false;
         br.postPage(
             POSTPAGE,
             "user="******"&passwrd="
                 + Encoding.urlEncode(password)
                 + "&cookielength=2&hash_passwrd=");
       } else {
         this.getPluginConfig().setProperty("user", username);
         this.getPluginConfig().setProperty("pass", password);
         this.getPluginConfig().save();
         return true;
       }
     }
   }
   throw new DecrypterException("Login or/and password wrong");
 }
Exemplo n.º 5
0
 @SuppressWarnings("unchecked")
 private void login(Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     /** Load cookies */
     br.setCookiesExclusive(false);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         Encoding.urlEncode(account.getUser())
             .matches(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
     if (acmatch)
       acmatch =
           Encoding.urlEncode(account.getPass())
               .matches(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
     if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       if (account.isValid()) {
         for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
           final String key = cookieEntry.getKey();
           final String value = cookieEntry.getValue();
           this.br.setCookie(MAINPAGE, key, value);
         }
         return;
       }
     }
     br.setFollowRedirects(true);
     br.postPage(
         MAINPAGE + "/login.php",
         "user="******"&pass="******"&submit=Login&task=dologin&return=%2F");
     if (!br.containsHTML(PREMIUMTEXT)) {
       br.getPage(MAINPAGE + "/members/myfiles.php");
       if (!br.containsHTML(PREMIUMLIMIT))
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     }
     /** Save cookies */
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(MAINPAGE);
     for (final Cookie c : add.getCookies()) {
       cookies.put(c.getKey(), c.getValue());
     }
     account.setProperty("name", Encoding.urlEncode(account.getUser()));
     account.setProperty("pass", Encoding.urlEncode(account.getPass()));
     account.setProperty("cookies", cookies);
   }
 }
Exemplo n.º 6
0
 private void login(Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     // Load/Save cookies, if we do NOT do this parallel downloads fail
     br.setCookiesExclusive(false);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         account.getUser().matches(account.getStringProperty("name", account.getUser()));
     if (acmatch)
       acmatch = account.getPass().matches(account.getStringProperty("pass", account.getPass()));
     if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       if (cookies.containsKey("jforumUserHash") && account.isValid()) {
         for (final String key : cookies.keySet()) {
           this.br.setCookie(MAINPAGE, key, cookies.get(key));
         }
         return;
       }
     }
     br.getPage(MAINPAGE);
     br.postPage(
         "http://www.yunfile.com/view?module=user&action=validateLogin",
         "username="******"&password="******"&remember=on");
     if (br.getCookie(MAINPAGE, "jforumUserHash") == null
         || br.getCookie(MAINPAGE, "membership") == null
         || !br.getCookie(MAINPAGE, "membership").equals("2"))
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     // Save cookies
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(MAINPAGE);
     for (final Cookie c : add.getCookies()) {
       cookies.put(c.getKey(), c.getValue());
     }
     account.setProperty("name", account.getUser());
     account.setProperty("pass", account.getPass());
     account.setProperty("cookies", cookies);
   }
 }
Exemplo n.º 7
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /* Load cookies */
       br.setCookiesExclusive(true);
       this.br = newBrowser();
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(DOMAIN, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       br.getPage(DOMAIN + "user_login_session.php");
       final String userName = br.getRegex("name=\"(user_name.*?)\"").getMatch(0);
       final String passWord = br.getRegex("name=\"(password.*?)\"").getMatch(0);
       this.postAPISafe(
           DOMAIN + "user_login_session.php",
           "B1=Login&"
               + userName
               + "="
               + Encoding.urlEncode(account.getUser())
               + "&"
               + passWord
               + "="
               + Encoding.urlEncode(account.getPass()));
       if (this.br.getCookie(DOMAIN, "secureid") == null) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin broken, please contact the JDownloader Support!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       /* Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(DOMAIN);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
Exemplo n.º 8
0
 @SuppressWarnings("unchecked")
 public void login(Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch)
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       br.setCookie(COOKIE_HOST, "mfh_mylang", "en");
       br.setCookie(COOKIE_HOST, "yab_mylang", "en");
       br.getPage(COOKIE_HOST + "/login.php");
       Form form = br.getFormbyProperty("name", "loginfrm");
       if (form == null) form = br.getForm(0);
       if (form == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       form.put("user", Encoding.urlEncode(account.getUser()));
       form.put("pass", Encoding.urlEncode(account.getPass()));
       // If the referer is still in the form (and if it is a valid downloadlink) the download
       // starts directly after logging in so
       // we MUST remove it!
       form.remove("refer_url");
       form.put("autologin", "0");
       br.submitForm(form);
       if (!br.getURL().endsWith("/members.php")) br.getPage(COOKIE_HOST + "/members.php");
       final String premium =
           br.getRegex(
                   "return overlay\\(this, \\'package_details\\',\\'width=\\d+px,height=\\d+px,center=1,resize=1,scrolling=1\\'\\)\">(Premium)</a>")
               .getMatch(0);
       if (br.getCookie(COOKIE_HOST, "mfh_passhash") == null
           || "0".equals(br.getCookie(COOKIE_HOST, "mfh_uid"))
           || premium == null
           || !premium.equals("Premium"))
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
 @SuppressWarnings("unchecked")
 private boolean login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       // Load cookies
       br.setCookiesExclusive(true);
       br.setFollowRedirects(true);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch)
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       if (acmatch && ret != null && ret instanceof HashMap<?, ?>) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             br.setCookie(MAINPAGE, key, value);
           }
           /* Avoids enerving login captchas */
           if (force) {
             br.getPage("http://www.premiumax.net/");
             if (br.containsHTML(">Sign out</a>")) {
               return true;
             } else {
               br.clearCookies(MAINPAGE);
               logger.info("Seems like the cookies are no longer valid -> Doing a full refresh");
             }
           } else {
             return true;
           }
         }
       }
       br.getPage("http://www.premiumax.net/");
       if (br.containsHTML(">Sign out</a>")) return true;
       final String stayin =
           br.getRegex("type=\"hidden\" name=\"stayloggedin\" value=\"([^<>\"]*?)\"").getMatch(0);
       if (stayin == null) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin broken, please contact the JDownloader Support!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       final DownloadLink dummyLink =
           new DownloadLink(this, "Account", "premiumax.net", "http://premiumax.net", true);
       final String code = getCaptchaCode("http://www.premiumax.net/veriword.php", dummyLink);
       br.postPage(
           "http://www.premiumax.net/",
           "serviceButtonValue=login&service=login&stayloggedin="
               + stayin
               + "&username="******"&password="******"&formcode="
               + code);
       if (br.getCookie(MAINPAGE, "WebLoginPE") == null) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nSchnellhilfe: \r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen?\r\nFalls dein Passwort Sonderzeichen enthält, ändere es und versuche es erneut!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nQuick help:\r\nYou're sure that the username and password you entered are correct?\r\nIf your password contains special characters, change it (remove them) and try again!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       // Save cookies
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = br.getCookies(MAINPAGE);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
       return true;
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       return false;
     }
   }
 }
Exemplo n.º 10
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       // Load cookies
       br.setCookiesExclusive(true);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             br.setCookie(MAINPAGE, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(false);
       br.getPage("http://lolabits.es/");
       br.getHeaders().put("X-Requested-With", "XMLHttpRequest");
       br.postPage("http://lolabits.es/action/login/loginWindow", "irect=true");
       br.postPage(
           "http://lolabits.es/action/login/login",
           "RememberMe=true&__RequestVerificationToken=undefined&RedirectUrl=&Redirect=True&FileId=0&Login="******"&Password="******"RememberMe") == null) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nSchnellhilfe: \r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen?\r\nFalls dein Passwort Sonderzeichen enthält, ändere es und versuche es erneut!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nQuick help:\r\nYou're sure that the username and password you entered are correct?\r\nIf your password contains special characters, change it (remove them) and try again!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       // Save cookies
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = br.getCookies(MAINPAGE);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
Exemplo n.º 11
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /* Load cookies */
       br.setCookiesExclusive(true);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       br.postPage(
           "https://wushare.com/login",
           "stay_login=1&commit=Login&referrer=http%3A%2F%2Fwushare.com%2F&username_or_email="
               + Encoding.urlEncode(account.getUser())
               + "&password="******"".equals(br.getCookie("https://wushare.com/", "session"))) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       if (!br.containsHTML(">Account type:</span><span class=\"info\">Premium</span>")) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nNicht unterstützter Accounttyp!\r\nFalls du denkst diese Meldung sei falsch die Unterstützung dieses Account-Typs sich\r\ndeiner Meinung nach aus irgendeinem Grund lohnt,\r\nkontaktiere uns über das support Forum.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUnsupported account type!\r\nIf you think this message is incorrect or it makes sense to add support for this account type\r\ncontact us via our support forum.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       /* Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
Exemplo n.º 12
0
  @SuppressWarnings("unchecked")
  public void login(final Account account, final boolean force) throws Exception {
    synchronized (LOCK) {
      try {
        /* Load cookies */
        br.setCookiesExclusive(true);
        final Object ret = account.getProperty("cookies", null);
        boolean acmatch =
            Encoding.urlEncode(account.getUser())
                .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
        if (acmatch) {
          acmatch =
              Encoding.urlEncode(account.getPass())
                  .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
        }
        if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
          final HashMap<String, String> cookies = (HashMap<String, String>) ret;
          if (account.isValid()) {
            for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
              final String key = cookieEntry.getKey();
              final String value = cookieEntry.getValue();
              this.br.setCookie(COOKIE_HOST, key, value);
            }
            return;
          }
        }
        setBrowserExclusive();
        br.setFollowRedirects(true);
        br.setDebug(true);
        try {
          changeToEnglish();
        } catch (final Throwable e) {
          if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else if ("pl".equalsIgnoreCase(System.getProperty("user.language"))) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nBłąd wtyczki, skontaktuj się z Supportem JDownloadera!",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nPlugin broken, please contact the JDownloader Support!",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          }
        }
        br.getPage("http://www.hellshare.com/?do=login-showLoginWindow");
        br.postPage(
            "/?do=login-loginBoxForm-submit",
            "username="******"&password="******"&login=P%C5%99ihl%C3%A1sit+registrovan%C3%A9ho+u%C5%BEivatele&perm_login=on");

        /*
         * this will change account language to eng,needed because language is saved in profile
         */
        final String permLogin = br.getCookie(br.getURL(), "permlogin");
        if (permLogin == null || br.containsHTML("zadal jsi špatné uživatelské")) {
          if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nUngültiger Benutzername/Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else if ("pl".equalsIgnoreCase(System.getProperty("user.language"))) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nBłędny użytkownik/hasło lub kod Captcha wymagany do zalogowania!\r\nUpewnij się, że prawidłowo wprowadziłes hasło i nazwę użytkownika. Dodatkowo:\r\n1. Jeśli twoje hasło zawiera znaki specjalne, zmień je (usuń) i spróbuj ponownie!\r\n2. Wprowadź hasło i nazwę użytkownika ręcznie bez użycia opcji Kopiuj i Wklej.",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          }
        }
        br.getPage("/members/");
        if (br.containsHTML("Wrong user name or wrong password\\.")
            || !br.containsHTML("credit for downloads")
            || br.containsHTML("Špatně zadaný login nebo heslo uživatele")
            || br.containsHTML("zadal jsi špatné uživatelské")) {
          if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nUngültiger Benutzername/Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else if ("pl".equalsIgnoreCase(System.getProperty("user.language"))) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nBłędny użytkownik/hasło lub kod Captcha wymagany do zalogowania!\r\nUpewnij się, że prawidłowo wprowadziłes hasło i nazwę użytkownika. Dodatkowo:\r\n1. Jeśli twoje hasło zawiera znaki specjalne, zmień je (usuń) i spróbuj ponownie!\r\n2. Wprowadź hasło i nazwę użytkownika ręcznie bez użycia opcji Kopiuj i Wklej.",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          }
        }
        /* Save cookies */
        final HashMap<String, String> cookies = new HashMap<String, String>();
        final Cookies add = this.br.getCookies(COOKIE_HOST);
        for (final Cookie c : add.getCookies()) {
          cookies.put(c.getKey(), c.getValue());
        }
        account.setProperty("name", Encoding.urlEncode(account.getUser()));
        account.setProperty("pass", Encoding.urlEncode(account.getPass()));
        account.setProperty("cookies", cookies);
      } catch (final PluginException e) {
        account.setProperty("cookies", Property.NULL);
        throw e;
      }
    }
  }
Exemplo n.º 13
0
  private void login(final Account account, final boolean force) throws Exception {
    synchronized (LOCK) {
      // Load cookies
      try {
        setBrowserExclusive();
        br.setFollowRedirects(true);
        final Object ret = account.getProperty("cookies", null);
        boolean acmatch =
            Encoding.urlEncode(account.getUser())
                .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
        if (acmatch) {
          acmatch =
              Encoding.urlEncode(account.getPass())
                  .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
        }
        if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
          final HashMap<String, String> cookies = (HashMap<String, String>) ret;
          if (account.isValid()) {
            for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
              final String key = cookieEntry.getKey();
              final String value = cookieEntry.getValue();
              br.setCookie(br.getHost(), key, value);
            }
            return;
          }
        }
        String u = account.getUser();
        String p = account.getPass();
        String s = " + ";

        br.getPage("http://www.trilulilu.ro/login");
        Form loginform = br.getFormbyProperty("id", "login_form");
        String n =
            loginform
                .getRegex("<input id=\"login_nonce\" type=\"hidden\" value=\"([0-9a-f]+)\"")
                .getMatch(0);

        String ditati =
            br.getRegex("<script src=\"(http://static\\.trilulilu\\.ro/\\w+/ditati\\.js\\?\\d+)\"")
                .getMatch(0);
        Browser md5fn = br.cloneBrowser();
        md5fn.getPage(ditati == null ? "http://static.trilulilu.ro/compiled/ditati.js" : ditati);

        NONSTANDARDMD5 =
            md5fn.getRegex("(var hexcase.*?)String\\.prototype\\.htmlentities").getMatch(0);
        if (n == null || NONSTANDARDMD5 == null) {
          throw new PluginException(
              LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
        }

        String postdata = "action=login";
        postdata += "&username="******"&remember=0";
        postdata += "&PAS5WORD=" + md5hex(p + md5hex(u) + s + n + s);
        postdata += "&PAS5W0RD=" + md5hex(p + s + md5hex(u + s + n));
        postdata += "&PA55WORD=" + md5hex(s + md5hex(n + u) + s + p);
        postdata += "&PASSW0RD=" + md5hex(md5hex(p) + s + n + s + u);
        postdata += "&PA5SW0RD=" + md5hex(md5hex(s + u + p) + s + n);
        postdata += "&PA5SWORD=" + md5hex(u + s + md5hex(n + s + p));
        postdata += "&PA55W0RD=" + md5hex(n + md5hex(s + p + u + s));
        postdata += "&PASSWORD="******"/login", postdata);
        if (!br.containsHTML("ok")) {
          throw new PluginException(
              LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
        }
        // cookies
        final HashMap<String, String> cookies = new HashMap<String, String>();
        final Cookies add = br.getCookies(br.getHost());
        for (final Cookie c : add.getCookies()) {
          cookies.put(c.getKey(), c.getValue());
        }
        account.setProperty("name", Encoding.urlEncode(account.getUser()));
        account.setProperty("pass", Encoding.urlEncode(account.getPass()));
        account.setProperty("cookies", cookies);
      } catch (final PluginException e) {
        account.setProperty("cookies", null);
        throw e;
      }
    }
  }
Exemplo n.º 14
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       // Load cookies
       br.setCookiesExclusive(true);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(MAINPAGE, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       br.postPage(
           "http://" + this.getHost() + "/login." + TYPE,
           "submit=Login&submitme=1&rememberMe=on&loginUsername="******"&loginPassword="******"user.language");
       if (!br.containsHTML("/logout\\." + TYPE + "\">logout")) {
         if ("de".equalsIgnoreCase(lang)) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       if (br.containsHTML("/upgrade\\." + TYPE + "\">upgrade account</a>")
           || !br.containsHTML("/upgrade\\." + TYPE + "\">extend account</a>")) {
         account.setProperty("free", true);
       } else {
         account.setProperty("free", false);
       }
       // Save cookies
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(MAINPAGE);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
Exemplo n.º 15
0
 @SuppressWarnings("unchecked")
 private void login(Account account, boolean showCaptcha, boolean doCheck) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       br.setCookie(COOKIE_HOST, "lang", "english");
       final Object ret = account.getProperty("cookies", null);
       boolean refreshCookies = true;
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch)
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       if (acmatch && ret != null && ret instanceof HashMap<?, ?>) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           if (doCheck) {
             br.getPage(COOKIE_HOST + "/?op=my_account");
             doSomething();
             if ((br.getCookie(COOKIE_HOST, "login")) == null
                 || br.getCookie(COOKIE_HOST, "xfss") == null) {
               /* cookies are no longer valid, refresh them */
               refreshCookies = true;
             } else {
               /* cookies are still okay, no need to refresh */
               refreshCookies = false;
             }
           } else {
             /* no doCheck */
             return;
           }
         }
       }
       if (refreshCookies) {
         /* fresh login = new cookies */
         br.getPage(COOKIE_HOST + "/login.html");
         Form loginform = br.getForm(0);
         if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
         loginform.put("login", Encoding.urlEncode(account.getUser()));
         loginform.put("password", Encoding.urlEncode(account.getPass()));
         if (br.containsHTML("RecaptchaOptions")) {
           /* too many logins result in recaptcha login */
           if (showCaptcha == false) {
             AccountInfo ai = account.getAccountInfo();
             if (ai != null) {
               ai.setStatus("Logout/Login in Browser please!");
             }
             throw new PluginException(
                 LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
           } else {
             /* recaptcha needed */
             PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
             jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
             rc.setForm(loginform);
             String id = this.br.getRegex("\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0);
             rc.setId(id);
             rc.load();
             File cf = rc.downloadCaptcha(getLocalCaptchaFile());
             DownloadLink dummyLink =
                 new DownloadLink(null, "Account", "easybytez.com", "http://easybytez.com", true);
             String c = getCaptchaCode(cf, dummyLink);
             rc.setCode(c);
           }
         } else {
           /* no recaptcha needed */
           br.submitForm(loginform);
         }
       }
       if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       if (refreshCookies) {
         /* we have to fetch my_account page again */
         br.getPage(COOKIE_HOST + "/?op=my_account");
         doSomething();
       }
       if (!new Regex(
               BRBEFORE,
               "(Premium\\-Account expire|/\\?op=payments\">Get Premium<|>Renew premium<)")
           .matches())
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       if (!new Regex(BRBEFORE, "(Premium\\-Account expire|>Renew premium<)").matches()) {
         account.setProperty("nopremium", true);
       } else {
         account.setProperty("nopremium", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (PluginException e) {
       account.setProperty("cookies", null);
       throw e;
     }
   }
 }
Exemplo n.º 16
0
 @SuppressWarnings("unchecked")
 public void loginWebsite(final Account account) throws IOException, PluginException {
   setBrowserExclusive();
   synchronized (HotFileCom.LOCK) {
     br.setDebug(true);
     br.getHeaders().put("User-Agent", ua);
     br.setCookie("http://hotfile.com", "lang", "en");
     final Object ret = account.getProperty("cookies", null);
     if (ret != null
         && ret instanceof HashMap<?, ?>
         && getPluginConfig().getBooleanProperty(HotFileCom.TRY_IWL_BYPASS, false)) {
       logger.info("Use cookie login");
       /* use saved cookies */
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       for (final String key : cookies.keySet()) {
         br.setCookie("http://hotfile.com/", key, cookies.get(key));
       }
       br.setFollowRedirects(true);
       br.getPage("http://hotfile.com/");
       br.setFollowRedirects(false);
       String isPremium =
           br.getRegex("Account:.*?label.*?centerSide[^/]*?>(Premium)<").getMatch(0);
       if (isPremium == null)
         isPremium = br.getRegex("centerSide\"><p><span>(Premium)</span>").getMatch(0);
       if (isPremium == null) {
         account.setProperty("cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
     } else {
       /* normal login */
       br.setFollowRedirects(true);
       br.getPage("http://hotfile.com/");
       br.postPage(
           "http://hotfile.com/login.php",
           "returnto=%2F&user="******"&pass="******"<td>Username:"******"cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       if (br.getCookie("http://hotfile.com/", "auth") == null) {
         account.setProperty("cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       String isPremium =
           br.getRegex("Account:.*?label.*?centerSide[^/]*?>(Premium)<").getMatch(0);
       if (isPremium == null)
         isPremium = br.getRegex("centerSide\"><p><span>(Premium)</span>").getMatch(0);
       if (isPremium == null) {
         account.setProperty("cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = br.getCookies("http://hotfile.com/");
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("cookies", cookies);
       br.setFollowRedirects(false);
     }
   }
 }
Exemplo n.º 17
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       prepBrowser(br);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       getPage(COOKIE_HOST + "/login.html");
       final String lang = System.getProperty("user.language");
       final Form loginform = br.getFormbyProperty("name", "FL");
       if (loginform == null) {
         if ("de".equalsIgnoreCase(lang)) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin broken, please contact the JDownloader Support!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       loginform.put("login", Encoding.urlEncode(account.getUser()));
       loginform.put("password", Encoding.urlEncode(account.getPass()));
       sendForm(loginform);
       if (br.getCookie(COOKIE_HOST, "login") == null
           || br.getCookie(COOKIE_HOST, "xfss") == null) {
         if ("de".equalsIgnoreCase(lang)) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nSchnellhilfe: \r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen?\r\nFalls dein Passwort Sonderzeichen enthält, ändere es und versuche es erneut!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nQuick help:\r\nYou're sure that the username and password you entered are correct?\r\nIf your password contains special characters, change it (remove them) and try again!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       if (!br.getURL().contains("/?op=my_account")) {
         getPage("/?op=my_account");
       }
       if (!new Regex(correctedBR, "(Premium(\\-| )Account expire|>Renew premium<)").matches()) {
         account.setProperty("nopremium", true);
       } else {
         account.setProperty("nopremium", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
Exemplo n.º 18
0
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       prepBrowser();
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(MAINPAGE, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       br.setCookie(MAINPAGE, "language", "en");
       // br.getPage(MAINPAGE);
       br.getHeaders().put("Content-Type", "application/x-www-form-urlencoded");
       postPage(
           this.br,
           "https://www.crocko.com/accounts/login",
           "remember=1&success_llocation=&login="******"&password="******"logacc");
       final String prem = br.getCookie(MAINPAGE, "PREMIUM");
       if (acc == null) {
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       if (prem == null) {
         account.setProperty("free", true);
       } else {
         account.setProperty("free", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(MAINPAGE);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }