NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Reading remote files through authenticating proxy

NetcdfFile doesnt know anything about dods. Use NetcdfDataset.open() instead.

Jon Blower wrote:
Thanks John.  The following code worked:

    System.setProperty("http.proxyHost", "myproxyhost.com");
    System.setProperty("http.proxyPort", "8080");
    Authenticator.setDefault(new Authenticator()
    {
        public PasswordAuthentication getPasswordAuthentication()
        {
            return new PasswordAuthentication("myusername",
"mypassword".toCharArray());
        }
    });
    NetcdfFile file
        new
DODSNetcdfFile("http://www.cdc.noaa.gov/cgi-bin/nph-nc/Datasets/ncep.reanaly
sis/pressure/uwnd.1992.nc", null);

Note that I had to explicitly use the DODSNetcdfFile() constructor.  When I
tried using NetcdfFile.open(<url>) the code seems to use the httpclient
libraries and hence does not connect.  I thought that if I passed a DODS URL
to the NetcdfFile.open() method, it would automatically recognise a DODS url
and construct a DODSNetcdfFile in the background?

Regards, Jon



-----Original Message-----
From: owner-netcdf-java@xxxxxxxxxxxxxxxx [mailto:owner-netcdf-java@xxxxxxxxxxxxxxxx] On Behalf Of John Caron
Sent: 10 October 2005 17:43
To: Jon Blower
Cc: netcdf-java@xxxxxxxxxxxxxxxx; support-netcdf-java@xxxxxxxxxxxxxxxx
Subject: Re: Reading remote files through authenticating proxy



Jon Blower wrote:

Hi all,

Does anyone know how (using the Java NetCDF libs) I can

read a remote
NetCDF or OpenDAP/DODS file through an authenticating proxy server using Basic authentication?

Thanks, Jon

--------------------------------------------------------------
Dr Jon Blower              Tel: +44 118 378 5213 (direct line)
Technical Director         Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre   Fax: +44 118 378 6413
ESSC                       Email: jdb@xxxxxxxxxxxxxxxxxxxx
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
--------------------------------------------------------------


Do this through the java.net library, eg:

java.net.Authenticator.setDefault( new SimpleAuthenticator(name, pass));

public class SimpleAuthenticator
  extends Authenticator
{
  private String username,
                 password;
public SimpleAuthenticator(String username,String password)
  {
     this.username = username;
     this.password = password;
  }
protected PasswordAuthentication getPasswordAuthentication()
  {
     return new PasswordAuthentication(
            username,password.toCharArray());
  }
}


You can google Authenticator.setDefault, eg:

 http://www.javaworld.com/javaworld/javatips/jw-javatip46.html

I should caution that at some point, netcdf-java may switch to using apache commons httpclient library when accessing OpenDAP. That uses a slightly different mechanism for authentication, but it wont be hard to switch, if and when that happens.



  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: