Package com.adito.agent.client.util

Examples of com.adito.agent.client.util.URI


        agents.remove(ticketUri);
      }
    }
    if(agent == null) {
      agent = new Agent(agentConfiguration);
      URI uri = new URI(ticketUri);
      String username = uri.getUserinfo();
      String password = null;
      int idx = username.indexOf(':');
      if(idx != -1) {
        password = username.substring(idx + 1);
        username = username.substring(0, idx);
      }
      String ticket = uri.getQueryString();
      agent.init();
      boolean connected = false;
      try {
        agent.connect(uri.getHost(), uri.getPort(), uri.getScheme().equalsIgnoreCase("https"), username, password == null ? ticket : password, password != null);
        connected = true;
        agents.put(ticketUri, agent);       
      }
      finally {
        if(!connected) {
View Full Code Here


   *            original url
   * @return obfuscated url
   */
  public static String obfuscateURL(String originalUrl) {
    try {
      URI url = new URI(originalUrl);
      String userInfo = url.getUserinfo();
      String user = ""; //$NON-NLS-1$
      if (userInfo != null && !userInfo.equals("")) { //$NON-NLS-1$
        int idx = userInfo.indexOf(':');
        user = userInfo;
        if (idx != -1) {
          user = userInfo.substring(0, idx);
        }
        return url.getScheme()
            + "://" + user + ":***@" + url.getHost() + ":" + url.getPort() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            + (url.getQueryString() != null ? ("?" + url.getQueryString()) : ""); //$NON-NLS-1$ //$NON-NLS-2$
      } else {
        return originalUrl;
      }

    } catch (URI.MalformedURIException e) {
View Full Code Here

      log.info("Attempting to detect proxy settings using platform specific methods"); //$NON-NLS-1$
      // #endif

      if (localProxyURL != null && localProxyURL.startsWith("browser://")) { //$NON-NLS-1$
              
        URI uri = new URI(localProxyURL);

        /*
         * Try to determine the proxy settings by first usng platform /
         * browser specific method, then the proxy supplied by the Java
         * plugin.
         *
         * TODO be more intelligent about which browse to try first -
         * use the userAgent parameter passed from the JSP
         */
        String proxyURL = null;
        if (userAgent != null) {

          // TODO support more browsers

          BrowserProxySettings proxySettings = null;
          if (userAgent.indexOf("MSIE") != -1) { //$NON-NLS-1$
            try {
              // #ifdef DEBUG
              log.info("Looking for IE"); //$NON-NLS-1$
              // #endif
              proxySettings = ProxyUtil.lookupIEProxySettings();
            } catch (Throwable t) {
              // #ifdef DEBUG
              log
                  .error(
                      "Failed to get IE proxy settings, trying Firefox.", t); //$NON-NLS-1$
              // #endif
            }
          }

          if (proxySettings == null
              && userAgent.indexOf("Firefox") != -1) { //$NON-NLS-1$
            try {
              // #ifdef DEBUG
              log.info("Looking for Firefox"); //$NON-NLS-1$
              // #endif
              proxySettings = ProxyUtil
                  .lookupFirefoxProxySettings();
            } catch (Throwable t) {
              // #ifdef DEBUG
              log.error(
                  "Failed to get Firefox proxy settings.", t); //$NON-NLS-1$
              // #endif
            }
          }
          if (proxySettings != null) {
            // #ifdef DEBUG
            log.info("Found some proxy settings."); //$NON-NLS-1$
            // #endif
            ProxyInfo[] proxyInfo = proxySettings.getProxies();
            for (int i = 0; proxyInfo != null
                && i < proxyInfo.length; i++) {
              // #ifdef DEBUG
              log
                  .info("Checking if " + obfuscateURL(proxyInfo[i].toUri()) + " is suitable."); //$NON-NLS-1$
              // #endif
              if (proxyInfo[i].getProtocol().equals("ssl") || proxyInfo[i].getProtocol().equals("https") //$NON-NLS-1$ //$NON-NLS-2$
                  || proxyInfo[i].getProtocol().equals("all")) { //$NON-NLS-1$
                StringBuffer buf = new StringBuffer("http://"); //$NON-NLS-1$
                if (proxyInfo[i].getUsername() != null
                    && !proxyInfo[i].getUsername().equals(
                        "")) { //$NON-NLS-1$
                  buf.append(proxyInfo[i].getUsername());
                  if (proxyInfo[i].getPassword() != null
                      && !proxyInfo[i].getPassword()
                          .equals("")) { //$NON-NLS-1$
                    buf.append(":"); //$NON-NLS-1$
                    buf.append(proxyInfo[i].getPassword());
                  }
                  buf.append("@"); //$NON-NLS-1$
                }
                buf.append(proxyInfo[i].getHostname());
                if (proxyInfo[i].getPort() != 0) {
                  buf.append(":"); //$NON-NLS-1$
                  buf.append(proxyInfo[i].getPort());
                }
                if (uri.getHost() != null) {
                  buf.append("?"); //$NON-NLS-1$
                  buf.append(uri.getHost());
                }
                proxyURL = buf.toString();
                break;
              }
            }
View Full Code Here

   *            local proxy URL
   * @throws URI.MalformedURIException
   */
  public void setLocalProxyURL(String localProxyURL)
      throws URI.MalformedURIException {
    this.localProxyURL = new URI(localProxyURL);

    // FIXME What about HttpsURLConnection?
  }
View Full Code Here

    // #endif

    // Parse the link address and create a new address for the browser
    // to use
    try {
      URI url = new URI(link);
      String linkHost = url.getHost();
      int linkPort = url.getPort() == -1 ? (url.getScheme()
          .equalsIgnoreCase("https") ? 443 : 80) : url.getPort(); //$NON-NLS-1$

      // Start a tunnel

      DefaultTunnel t = new DefaultTunnel(-1,
          TunnelConfiguration.LOCAL_TUNNEL,
View Full Code Here

TOP

Related Classes of com.adito.agent.client.util.URI

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.