private void login() throws Exception {
   synchronized (Real_DebridFileRunner.class) {
     cz.vity.freerapid.plugins.services.real_debrid.Real_DebridServiceImpl service =
         (cz.vity.freerapid.plugins.services.real_debrid.Real_DebridServiceImpl)
             getPluginService();
     PremiumAccount pa = service.getConfig();
     if (!pa.isSet()) {
       pa = service.showConfigDialog();
       if (pa == null || !pa.isSet()) {
         throw new BadLoginException("No Real-Debrid account login information!");
       }
     }
     HttpMethod method =
         getMethodBuilder()
             .setAction(RD_LOGIN)
             .setParameter("user", pa.getUsername())
             .setParameter("pass", pa.getPassword())
             .setParameter("captcha_challenge", "")
             .setParameter("captcha_answer", "")
             .setParameter("time", "" + System.currentTimeMillis())
             .setBaseURL(RD_BASE_URL)
             .setReferer(RD_BASE_URL)
             .toGetMethod();
     if (!makeRedirectedRequest(method)) {
       throw new ServiceConnectionProblemException("Error posting login info");
     }
     if (getContentAsString().contains("Your login informations are incorrect")) {
       throw new BadLoginException("Invalid Real-Debrid account login information!");
     }
     final String auth = PlugUtils.getStringBetween(getContentAsString(), "cookie\":\"auth=", ";");
     addCookie(new Cookie(".real-debrid.com", "auth", auth, "/", 86400, false));
   }
 }
 protected boolean login() throws Exception {
   synchronized (getClass()) {
     final ForSharedServiceImpl service = (ForSharedServiceImpl) getPluginService();
     PremiumAccount pa = service.getConfig();
     if (!pa.isSet()) {
       pa = service.showConfigDialog();
       if (pa == null || !pa.isSet()) {
         LOGIN_CACHE.remove(getClass());
         throw new BadLoginException("No 4Shared account login information!");
       }
     }
     final LoginData loginData = LOGIN_CACHE.get(getClass());
     if (loginData == null || !pa.equals(loginData.getPa()) || loginData.isStale()) {
       logger.info("Logging in");
       doLogin(pa);
       final Cookie[] cookies = new Cookie[2];
       final Cookie loginCookie = getCookieByName("Login");
       final Cookie passwdCookie = getCookieByName("Password");
       if ((loginCookie == null) || (passwdCookie == null)) {
         throw new PluginImplementationException("Login cookies not found");
       }
       cookies[0] = loginCookie;
       cookies[1] = passwdCookie;
       LOGIN_CACHE.put(getClass(), new LoginData(pa, cookies));
     } else {
       logger.info("Login data cache hit");
       client.getHTTPClient().getState().addCookies(loginData.getCookies());
     }
     return true;
   }
 }