src/main/java/org/beigesoft/replicator/service/ReplicatorXmlHttps.java
public final void authForm(final Map<String, Object> pAddParams,
      final CookieManager pCookieManager) throws Exception {
    String authUrl = (String) pAddParams.get("authUrl");
    String authUserName = (String) pAddParams.get("authUserName");
    String authUserPass = (String) pAddParams.get("authUserPass");
    String userName = (String) pAddParams.get("userName");
    String userPass = (String) pAddParams.get("userPass");
    URL url = new URL(authUrl);
    HttpsURLConnection urlConnection = (HttpsURLConnection) url
      .openConnection();
    if (!url.getHost().equals(urlConnection.getURL().getHost())) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "You should sign-in in browser first!");
    }
    OutputStreamWriter writer = null;
    BufferedReader reader = null;
    try {
      urlConnection.setDoOutput(true);
      urlConnection.setRequestMethod("POST");
      String paramStr = authUserName + "=" + userName + "&"
        + authUserPass + "=" + userPass;
      StringBuffer cookiesSb = new StringBuffer();
      for (HttpCookie cookie : pCookieManager.getCookieStore().getCookies()) {
        cookiesSb.append(cookie.getName() + "=" + cookie.getValue() + ";");
      }
      setCookies(cookiesSb.toString());
      urlConnection.addRequestProperty("Cookie", getCookies());
      urlConnection.addRequestProperty("Connection", "keep-alive");
      urlConnection.addRequestProperty("Content-Type",
        "application/x-www-form-urlencoded");
      urlConnection.addRequestProperty("Content-Length",
        String.valueOf(paramStr.length()));
      boolean isDbgSh = this.logger.getDbgSh(this.getClass())
        && this.logger.getDbgFl() < 8001 && this.logger.getDbgCl() > 8003;
      if (isDbgSh) {
        getLogger().debug(null, ReplicatorXmlHttp.class,
          "Request before flush auth:");
        for (Map.Entry<String, List<String>> entry
          : urlConnection.getRequestProperties().entrySet()) {
          this.logger.debug(null, ReplicatorXmlHttp.class,
            "  Request entry key: " + entry.getKey());
          for (String val : entry.getValue()) {
            this.logger.debug(null, ReplicatorXmlHttp.class,
              "   Request entry value: " + val);
          }
        }
      }
      writer = new OutputStreamWriter(urlConnection
        .getOutputStream(), Charset.forName("UTF-8").newEncoder());
      writer.write(paramStr);
      writer.flush();
      reader = new BufferedReader(new InputStreamReader(urlConnection
          .getInputStream(), Charset.forName("UTF-8").newDecoder()));
      while (reader.read() != -1) { //NOPMD
        //just read out
      }
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      if (writer != null) {
        try {
          writer.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      urlConnection.disconnect();
    }
  }
public final void authForm(final Map<String, Object> pAddParams,
      final CookieManager pCookieManager) throws Exception {
    String authUrl = (String) pAddParams.get("authUrl");
    String authUserName = (String) pAddParams.get("authUserName");
    String authUserPass = (String) pAddParams.get("authUserPass");
    String userName = (String) pAddParams.get("userName");
    String userPass = (String) pAddParams.get("userPass");
    URL url = new URL(authUrl);
    HttpsURLConnection urlConnection = (HttpsURLConnection) url
      .openConnection();
    if (!url.getHost().equals(urlConnection.getURL().getHost())) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "You should sign-in in browser first!");
    }
    OutputStreamWriter writer = null;
    BufferedReader reader = null;
    try {
      urlConnection.setDoOutput(true);
      urlConnection.setRequestMethod("POST");
      String paramStr = authUserName + "=" + userName + "&"
        + authUserPass + "=" + userPass;
      StringBuffer cookiesSb = new StringBuffer();
      for (HttpCookie cookie : pCookieManager.getCookieStore().getCookies()) {
        cookiesSb.append(cookie.getName() + "=" + cookie.getValue() + ";");
      }
      setCookies(cookiesSb.toString());
      urlConnection.addRequestProperty("Cookie", getCookies());
      urlConnection.addRequestProperty("Connection", "keep-alive");
      urlConnection.addRequestProperty("Content-Type",
        "application/x-www-form-urlencoded");
      urlConnection.addRequestProperty("Content-Length",
        String.valueOf(paramStr.length()));
      boolean isDbgSh = this.logger.getDbgSh(this.getClass())
        && this.logger.getDbgFl() < 8001 && this.logger.getDbgCl() > 8003;
      if (isDbgSh) {
        getLogger().debug(null, ReplicatorXmlHttp.class,
          "Request before flush auth:");
        for (Map.Entry<String, List<String>> entry
          : urlConnection.getRequestProperties().entrySet()) {
          this.logger.debug(null, ReplicatorXmlHttp.class,
            "  Request entry key: " + entry.getKey());
          for (String val : entry.getValue()) {
            this.logger.debug(null, ReplicatorXmlHttp.class,
              "   Request entry value: " + val);
          }
        }
      }
      writer = new OutputStreamWriter(urlConnection
        .getOutputStream(), Charset.forName("UTF-8").newEncoder());
      writer.write(paramStr);
      writer.flush();
      reader = new BufferedReader(new InputStreamReader(urlConnection
          .getInputStream(), Charset.forName("UTF-8").newDecoder()));
      while (reader.read() != -1) { //NOPMD
        //just read out
      }
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      if (writer != null) {
        try {
          writer.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      urlConnection.disconnect();
    }
  }
<p>It authenticate by post simulate form.</p>
@param pAddParams additional params
@param pCookieManager CookieManager for form auth
@throws Exception - an exception