Package org.eclipse.ecf.core.util

Examples of org.eclipse.ecf.core.util.Proxy


        int proxyPort = ((pPort != null)?Integer.parseInt(pPort):9808);

        String username = System.getProperty(this.getClass().getName()+".proxyUsername");
        if (username != null) {
          String password = System.getProperty(this.getClass().getName()+".proxyPassword");
          retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(
          proxyName, proxyPort), username, password) );
        } else {
          retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(
              proxyName, proxyPort)));
        }
      }
    } catch (Exception e) {
      // Print out problems to system err
View Full Code Here


    Credentials result = matchCredentials(this.cachedCredentials, authscope);
    // If we have a match, return credentials
    if (result != null)
      return result;
    // If we don't have a match, first get ECF proxy, if any
    Proxy proxy = getECFProxy();
    if (proxy == null)
      return null;

    // Make sure that authscope and proxy host and port match
    if (!matchAuthScopeAndProxy(authscope, proxy))
      return null;

    // Then match scheme, and get credentials from proxy (if it's scheme we know about)
    Credentials credentials = null;
    if ("ntlm".equalsIgnoreCase(authscope.getScheme())) { //$NON-NLS-1$
      credentials = getNTLMCredentials(proxy);
    } else if ("basic".equalsIgnoreCase(authscope.getScheme()) || //$NON-NLS-1$
        "digest".equalsIgnoreCase(authscope.getScheme())) { //$NON-NLS-1$
      final String proxyUsername = proxy.getUsername();
      final String proxyPassword = proxy.getPassword();
      // If credentials present for proxy then we're done
      if (proxyUsername != null) {
        credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
      }
    } else if ("negotiate".equalsIgnoreCase(authscope.getScheme())) { //$NON-NLS-1$
View Full Code Here

* @noextend This class is not intended to be extended by clients.
* @since 3.1
*/
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());
        }
      }
    } catch (Exception e) {
      // If we don't even have the classes for this (i.e. the org.eclipse.core.net plugin not available)
      // then we simply log and ignore
View Full Code Here

   */
  public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean isProxyAuthenticating) throws CredentialsNotAvailableException {
    if (!isProxyAuthenticating) {
      return null;
    }
    Proxy proxy = getECFProxy();
    if (proxy == null) {
      return null;
    }

    Object provideKey = makeProvidedKey(scheme, host, port, isProxyAuthenticating);
    if (provided.contains(provideKey)) {
      // HttpClient asks about credentials only once.
      // If already provided don't use them again.
      return null;
    }

    provided.add(provideKey);

    if ("ntlm".equalsIgnoreCase(scheme.getSchemeName())) { //$NON-NLS-1$
      return getNTLMCredentials(proxy);
    } else if ("basic".equalsIgnoreCase(scheme.getSchemeName()) || //$NON-NLS-1$
        "digest".equalsIgnoreCase(scheme.getSchemeName())) { //$NON-NLS-1$
      final String proxyUsername = proxy.getUsername();
      final String proxyPassword = proxy.getPassword();
      if (proxyUsername != null) {
        Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
        return credentials;
      }
    }
View Full Code Here

  /**
   */
  void setupProxy() {
    com.jcraft.jsch.Proxy jProxy = null;
    final Proxy proxy = handler.getProxy();
    if (proxy != null) {
      final String hostname = proxy.getAddress().getHostName();
      final int port = proxy.getAddress().getPort();
      if (proxy.getType().equals(Proxy.Type.HTTP)) {
        if (port == -1)
          jProxy = new ProxyHTTP(hostname);
        else
          jProxy = new ProxyHTTP(hostname, port);
      } else if (proxy.getType().equals(Proxy.Type.SOCKS)) {
        if (port == -1)
          jProxy = new ProxySOCKS5(hostname);
        else
          jProxy = new ProxySOCKS5(hostname, port);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.core.util.Proxy

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.