public void addRepository(
      final Project project,
      final RedmineRepositoryConfig config,
      final SCMConnectorConfig scmConfig,
      final String username,
      final String password)
      throws MalformedURLException, IOException, SAXException {
    login(config);
    LOGGER.info("Redmine add Repository: " + scmConfig.getScmUrl());

    // Check if Repository should be added
    if (!config.isAddRepositoryConfiguration()) {
      LOGGER.debug("Redmine Repository config is disabled.");
      return;
    }

    List<Cookie> cookies = (List<Cookie>) _wt.getDialog().getCookies();
    for (Cookie cookie : cookies) {
      _wc.putCookie(cookie.getName(), cookie.getValue());
    }
    String token = getAuthenticityToken(_wt.getPageSource());
    LOGGER.debug("Token: {}", token);

    String scm = getScmType(scmConfig);
    LOGGER.debug("SCM CONFIG: {}", scm);

    postData(config, project, scmConfig, username, password, scm);
  }
  protected boolean login(final String url, final String username, final String password)
      throws MalformedURLException, IOException, SAXException {
    _wt.setBaseUrl(url);
    _wt.beginAt("/login");
    _wt.setTextField("username", username);
    _wt.setTextField("password", password);
    _wt.submit();

    if (_wt.getDialog().getPageURL().toExternalForm().endsWith("/my/page")) {
      return true;
    } else {
      return false;
    }
  }
  /**
   * @throws SAXException
   * @throws IOException
   * @throws MalformedURLException
   */
  private void postData(
      final RedmineRepositoryConfig config,
      final Project project,
      final SCMConnectorConfig scmConfig,
      final String username,
      final String password,
      final String scm) {
    LOGGER.info("Redmine add Repository: " + scmConfig.getScmUrl());

    // Check if Repository should be added
    if (!config.isAddRepositoryConfiguration()) {
      LOGGER.debug("Repository config is disabled");
      return;
    }

    List<Cookie> cookies = (List<Cookie>) _wt.getDialog().getCookies();
    for (Cookie cookie : cookies) {
      LOGGER.debug("Cookie: {}", cookie);
      _wc.putCookie(cookie.getName(), cookie.getValue());
    }

    PostMethodWebRequest form =
        new PostMethodWebRequest(
            config.getServer().getUrl() + "/projects/" + project.getName() + "/repositories");
    form.setParameter("authenticity_token", getAuthenticityToken(_wt.getPageSource()));
    form.setParameter("repository_scm", scm);
    form.setParameter("repository[url]", scmConfig.getProjectScmUrl(project.getName()));
    form.setParameter("repository[login]", username);
    form.setParameter("repository[password]", password);
    form.setParameter("commit", "Create");
    try {
      LOGGER.debug("Posting: {}", form);
      _wc.getResponse(form);
      LOGGER.debug("Posted");
    } catch (MalformedURLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }