public static Proxy parseProxy(String proxy_entry){

      String proxy_host;
      int proxy_port = 1080;
      String proxy_user = null;
      String proxy_password = null;
      Proxy proxy;

      java.util.StringTokenizer st = new java.util.StringTokenizer(
                                         proxy_entry,":");
      if(st.countTokens() < 1) return null;

      proxy_host = st.nextToken();
      if(st.hasMoreTokens())
         try{
           proxy_port = Integer.parseInt(st.nextToken().trim());
         }catch(NumberFormatException nfe){}

      if(st.hasMoreTokens())
         proxy_user = st.nextToken();

      if(st.hasMoreTokens())
         proxy_password = st.nextToken();

      try{
         if(proxy_user == null)
           proxy = new Socks5Proxy(proxy_host,proxy_port);
         else if(proxy_password == null)
           proxy = new Socks4Proxy(proxy_host,proxy_port,proxy_user);
         else{
           proxy = new Socks5Proxy(proxy_host,proxy_port);
           UserPasswordAuthentication upa = new UserPasswordAuthentication(
                                            proxy_user, proxy_password);

           ((Socks5Proxy)proxy).setAuthenticationMethod(UserPasswordAuthentication.METHOD_ID,upa);
         }
      }catch(UnknownHostException uhe){
         return null;
      }

      return proxy;
   }