/*
   * @see
   * org.rssowl.core.connection.auth.ICredentialsProvider#getProxyCredentials
   * (java.net.URI)
   */
  public IProxyCredentials getProxyCredentials(URI link) {
    Activator activator = Activator.getDefault();

    /* Check if Bundle is Stopped */
    if (activator == null) return null;

    IProxyService proxyService = activator.getProxyService();

    /* Check if Proxy is enabled */
    if (!proxyService.isProxiesEnabled()) return null;

    String host = URIUtils.safeGetHost(link);
    boolean isSSL = URIUtils.HTTPS_SCHEME.equals(link.getScheme());

    /* Retrieve Proxy Data */
    final IProxyData proxyData =
        proxyService.getProxyDataForHost(
            host, isSSL ? IProxyData.HTTPS_PROXY_TYPE : IProxyData.HTTP_PROXY_TYPE);
    if (proxyData != null) {

      /* Look for Domain as part of Username to support NTLM Proxy */
      final String proxyHost = proxyData.getHost();
      final int proxyPort = proxyData.getPort();
      final Pair<String /* Username */, String /* Domain */> proxyUserAndDomain =
          splitUserAndDomain(proxyData.getUserId());
      final String proxyPassword = proxyData.getPassword();

      /* Return as IProxyCredentials Object */
      return new IProxyCredentials() {
        public String getHost() {
          return proxyHost;
        }

        public int getPort() {
          return proxyPort;
        }

        public String getUsername() {
          return proxyUserAndDomain.getFirst();
        }

        public String getPassword() {
          return proxyPassword;
        }

        public String getDomain() {
          return proxyUserAndDomain.getSecond();
        }
      };
    }

    /* Feed does not require Proxy or Credentials not supplied */
    return null;
  }
  /*
   * @see
   * org.rssowl.core.connection.auth.ICredentialsProvider#setProxyCredentials
   * (org.rssowl.core.connection.auth.IProxyCredentials, java.net.URI)
   */
  public void setProxyCredentials(IProxyCredentials credentials, URI link) {
    IProxyService proxyService = Activator.getDefault().getProxyService();
    proxyService.setProxiesEnabled(true);
    boolean isSSL = URIUtils.HTTPS_SCHEME.equals(link.getScheme());

    /* Retrieve Proxy Data */
    final IProxyData proxyData =
        proxyService.getProxyData(isSSL ? IProxyData.HTTPS_PROXY_TYPE : IProxyData.HTTP_PROXY_TYPE);
    if (proxyData != null) { // TODO What if Data is NULL?
      proxyData.setHost(credentials.getHost());
      proxyData.setPort(credentials.getPort());
      proxyData.setUserid(credentials.getUsername());
      proxyData.setPassword(credentials.getPassword());
    }
  }
 /*
  * @see
  * org.rssowl.core.connection.auth.ICredentialsProvider#deleteProxyCredentials
  * (java.net.URI)
  */
 public void deleteProxyCredentials(URI link) {
   IProxyService proxyService = Activator.getDefault().getProxyService();
   proxyService.setProxiesEnabled(false);
   // TODO System Properties are still set?
 }