Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4838316

need way to access previously stored proxy user and passwd data

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.0
    • deploy

      Name: nt126004 Date: 03/26/2003


      FULL PRODUCT VERSION :
      JDK 1.4.1

      FULL OS VERSION :
      Windows 2000

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Default configuration

      A DESCRIPTION OF THE PROBLEM :
      This is a design bug (or possibly a horrible failure to document). I have thoroughly researched it and although many developers have experienced it and complained in the Forums, no one has solved it. It only occurs when using a proxy that requires Username/Password.

        Description:

      Java Web Start automatically prompts for proxy Username and Password. All internet-aware apps need the same credentials, preferably without annoying the user with redundant logons.

      Authenticator has "setDefault()", but not "getDefault()". Therefore it is not possible to query the default authenticator.

      Authenticator.requestPasswordAuthentication() allows us to do the job "IF" we know the proxy host, port and prompt, so that by matching those values we don't get a second user login. Host and port are in the System properties, but no proxy prompt is available anywhere. Also, there is no alternative method signature that does not require the proxy prompt.

      A way to perform this function is mandatory in order to create a proper Internet-aware application. The Design bug is that no solution exists.





      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      A) Make sure you are using a proxy that requires Username and Password. I tested by downloading the eval version of "Netproxy".

      B) Try to write any code that obtains the proxy's Username and Password without prompting the user twice for the proxy Username and Password.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Existence of a way to avoid double-prompting the user for proxy Username and Password when the application must have access to them (i.e.: for a SOAP call).
      There is no method, parameter or property to allow the functionality.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.io.IOException;
      import java.net.Authenticator;
      import java.net.HttpURLConnection;
      import java.net.InetAddress;
      import java.net.PasswordAuthentication;
      import java.net.URL;
      import java.net.MalformedURLException;
      import java.net.UnknownHostException;
      import java.util.Enumeration;
      import java.util.Properties;
      import javax.jnlp.*;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JPanel;

      public class Main extends JPanel
      {
          static JFrame frame;
          
          public Main()
          {
              JButton button = new JButton("Hello world");
              add(button);
          }

          public static void main(String[] args)
          {
              Main panel = new Main();
              frame = new JFrame("jwsLogin Test");
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}
              });
              frame.getContentPane().add("Center",panel);
              frame.pack();
              frame.setVisible(true);
              panel.test();
          }

          /** Test code */
          public void test()
          {
              //System.getProperties().setProperty("proxySet","true");
              //System.getProperties().setProperty("proxyHost","...");
              //System.getProperties().setProperty("proxyPort","8080");
              
              URL url = null;
              try{
                  url = new URL("http://www.yahoo.com");
              }catch(MalformedURLException e){ e.printStackTrace(); }
              
              HttpURLConnection c = null;
              try{
                  c = (HttpURLConnection)url.openConnection();
                  c.setRequestMethod("GET");
                  c.connect();
                  System.out.println("Connected:");
                  System.out.println(" URL = "+c.getURL());
                  System.out.println(" Request method = "+c.getRequestMethod());
                  System.out.println(" Response code = "+c.getResponseCode());
                  System.out.println(" Response msg = "+c.getResponseMessage());
                  System.out.println(" Using proxy = "+c.usingProxy());
                  c.disconnect();
              }catch(Exception e){ e.printStackTrace(); }
              
              Properties p = System.getProperties();
              String name = null;
              Enumeration en = p.propertyNames();
              String fwHost=p.getProperty("proxyHost");
              int fwPort=Integer.parseInt(p.getProperty("proxyPort"));
              String prompt="NetProxy-192.168.10.145"; //THIS VALUE CANNOT BE QUERIED
              String scheme="Z_SCHEME"; // DUMMY VALUE
              InetAddress addr = null;
              try{
                  addr = InetAddress.getByName(fwHost);
              }catch(UnknownHostException e){ e.printStackTrace(); }
              PasswordAuthentication pauth =
                      Authenticator.requestPasswordAuthentication(addr, 9080, "FTTP",
                      prompt, scheme);
              System.out.println("Username = "+pauth.getUserName());
              System.out.println("Password = "+pauth.getPassword());
          }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None. Since 90% of Java Web Start applications need to be Internet-aware, this design bug totally sabotages its usefulness.
      (Review ID: 183003)
      ======================================================================

            dgu Dennis Gu (Inactive)
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: