private Realm getRealm(RemoteRepository repository) {
    Realm realm = null;

    Authentication a = repository.getAuthentication();
    if (a != null && a.getUsername() != null) {
      realm =
          new Realm.RealmBuilder()
              .setPrincipal(a.getUsername())
              .setPassword(a.getPassword())
              .setUsePreemptiveAuth(false)
              .build();
    }

    return realm;
  }
  private ProxyServer getProxy(RemoteRepository repository) {
    ProxyServer proxyServer = null;

    Proxy p = repository.getProxy();
    if (p != null) {
      Authentication a = p.getAuthentication();
      boolean useSSL =
          repository.getProtocol().equalsIgnoreCase("https")
              || repository.getProtocol().equalsIgnoreCase("dav:https");
      if (a == null) {
        proxyServer =
            new ProxyServer(useSSL ? Protocol.HTTPS : Protocol.HTTP, p.getHost(), p.getPort());
      } else {
        proxyServer =
            new ProxyServer(
                useSSL ? Protocol.HTTPS : Protocol.HTTP,
                p.getHost(),
                p.getPort(),
                a.getUsername(),
                a.getPassword());
      }
    }

    return proxyServer;
  }