Package org.eclipse.core.net.proxy

Examples of org.eclipse.core.net.proxy.IProxyService


    /**
     * Returns @link{IProxyService} if there is a registered service otherwise
     * null.
     */
    protected IProxyService getProxyService() {
        IProxyService result = null;
        if (Saros.isWorkbenchAvailable()) {
            BundleContext bundleContext = getBundle().getBundleContext();
            ServiceReference serviceReference = bundleContext
                .getServiceReference(IProxyService.class.getName());
            result = (IProxyService) bundleContext.getService(serviceReference);
View Full Code Here


     * @SuppressWarnings("deprecation") -> getProxyDataForHost replacement is
     *                                  only available in Eclipse 3.5
     */
    @SuppressWarnings("deprecation")
    public ProxyInfo getProxyInfo(String host) {
        IProxyService ips = getProxyService();
        if (ips == null || !ips.isProxiesEnabled())
            return null;

        for (IProxyData pd : ips.getProxyDataForHost(host)) {
            if (IProxyData.HTTP_PROXY_TYPE.equals(pd.getType())) {
                return ProxyInfo.forHttpProxy(pd.getHost(), pd.getPort(),
                    pd.getUserId(), pd.getPassword());
            } else if (IProxyData.SOCKS_PROXY_TYPE.equals(pd.getType())) {
                return ProxyInfo.forSocks5Proxy(pd.getHost(), pd.getPort(),
View Full Code Here

   * @throws MalformedURLException
   */
  private URL getProxiedUrl(URI uri) throws URISyntaxException,
      MalformedURLException {

    IProxyService proxyService = getProxyService();
    IProxyData[] proxyDataForHost = proxyService.select(uri);

    for (IProxyData proxyData : proxyDataForHost) {
      if (proxyData.getHost() != null) {
        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", proxyData.getHost());
View Full Code Here

   * Disables usage of proxy servers
   */
  public static void disableProxy() {
    BundleContext context = Activator.getDefault().getBundle().getBundleContext();
    ServiceReference<IProxyService> serviceReference = context.getServiceReference(IProxyService.class);
    IProxyService proxyService = context.getService(serviceReference);
    proxyService.setSystemProxiesEnabled(false);
    proxyService.setProxiesEnabled(false);
  }
View Full Code Here

    /* 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();
View Full Code Here

   * @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());
View Full Code Here

   * @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?
  }
View Full Code Here

   * @param versionCheckUrl
   * @throws URISyntaxException
   */
  private void configureProxy(HttpClient httpClient, String versionCheckUrl) throws URISyntaxException
  {
    IProxyService proxyService = InstaSearchPlugin.getDefault().getProxyService();
   
    if (proxyService != null && proxyService.isProxiesEnabled()) {
      URI uri = new URI(versionCheckUrl);
      final IProxyData[] proxiesData = proxyService.select(uri);
     
      IProxyData proxy = null;
      for(IProxyData proxyData: proxiesData)
      {
        if( proxyData.getType().equals(IProxyData.HTTP_PROXY_TYPE) )
View Full Code Here

    }
    assertTrue(count > eventCount);
  }

  protected void addProxy(final String proxyHost, final int port, final String username, final String password) throws Exception {
    IProxyService proxyService = Activator.getDefault().getProxyService();
    proxyService.setProxiesEnabled(true);
    proxyService.setSystemProxiesEnabled(false);
    IProxyData proxyData = new IProxyData() {
 
      public void disable() {
      }
 
      public String getHost() {
        return proxyHost;
      }
 
      public String getPassword() {
        return password;
      }
 
      public int getPort() {
        return port;
      }
 
      public String getType() {
        return "HTTP";
      }
 
      public String getUserId() {
        return username;
      }
 
      public boolean isRequiresAuthentication() {
        return (username != null);
      }
 
      public void setHost(String host) {
      }
 
      public void setPassword(String password) {
      }
 
      public void setPort(int port) {
      }
 
      public void setUserid(String userid) {
      }

      //TODO: What is the current expected target
      public String getSource() {
        // TODO Auto-generated method stub
        return null;
      }

      public void setSource(String source) {
        // TODO Auto-generated method stub
       
      }
     
    };
    proxyService.setProxyData(new IProxyData[] { proxyData });
  }
View Full Code Here

*/
public class ProxySetupHelper {
  public static Proxy getProxy(String url) {
    Proxy proxy = null;
    try {
      IProxyService proxyService = Activator.getDefault().getProxyService();
      // Only do this if platform service exists
      if (proxyService != null && proxyService.isProxiesEnabled()) {
        // Setup via proxyService entry
        URI uri = new URI(url);
        final IProxyData[] proxies = proxyService.select(uri);
        IProxyData selectedProxy = selectProxyFromProxies(uri.getScheme(), proxies);
        if (selectedProxy != null) {
          proxy = new Proxy(((selectedProxy.getType().equalsIgnoreCase(IProxyData.SOCKS_PROXY_TYPE)) ? Proxy.Type.SOCKS : Proxy.Type.HTTP), new ProxyAddress(selectedProxy.getHost(), selectedProxy.getPort()), selectedProxy.getUserId(), selectedProxy.getPassword());
        }
      }
View Full Code Here

TOP

Related Classes of org.eclipse.core.net.proxy.IProxyService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.