This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
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: address@hidden 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.htmlI 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.