Re: [netcdf-java] OPeNDAP authentication using nj22

Further information on this: I can connect successfully to the server
in question using the toolsUI-2.2.22.jar, but I still can't via my own
application.  I've had a quick look at the code for HttpClientManager
and HTTPRandomAccessFile and perhaps there is a call to
setDoAuthentication() missing?

Cheers, Jon

On Dec 13, 2007 9:12 PM, Jon Blower <jdb@xxxxxxxxxxxxxxxxxxxx> wrote:
> Thanks John, and everyone else who replied.
>
> I'm now experimenting with trying to get OPeNDAP authentication
> working in version 2.2.22.  I have a very simple main() method that
> simply tries to open a NetcdfDataset from an OPeNDAP URL, where the
> OPeNDAP server requires authentication:
>
>     public static void main(String[] args) throws Exception
>     {
>         HttpClientManager.init(new CredentialsProvider(){
>             public Credentials getCredentials(AuthScheme scheme,
>                        String host, int port, boolean proxy)
>                        throws CredentialsNotAvailableException
>             {
>                 System.out.println("Called Credentials Provider!");
>                 throw new CredentialsNotAvailableException();
>             }
>         }, null);
>
>         NetcdfDataset nc = NetcdfDataset.openDataset("http://myurl";);
>         nc.close();
>     }
>
> When I run this I get an error message:
>
>     Server does not support byte Ranges
>     at 
> ucar.unidata.io.http.HTTPRandomAccessFile.<init>(HTTPRandomAccessFile.java:99)
>
> which, having delved through the nj22 code, actually just means that
> the call to get the value of the Accept-Ranges header does not return
> what is expected.  I assume that the real reason that the call fails
> is that the server requires authentication.  The simple
> CredentialsProvider that I have written in the above code never gets
> called.
>
> Could anyone please shed some light on this, or perhaps provide a code
> snippet of the right way to go about this?
>
> Thanks very much,
> Jon
>
>
> On Nov 26, 2007 7:24 PM, John Caron <caron@xxxxxxxxxxxxxxxx> wrote:
> > Hi Jon:
> >
> > ucar.nc2.dataset.HttpClientManager is in 2.2.22 release. I beleive it was 
> > added at 2.2.19.
> >
> >
> > Jon Blower wrote:
> > > Hi all,
> > >
> > > I'm trying to read data from an authenticated OPeNDAP server.  I've
> > > found the page 
> > > http://www.unidata.ucar.edu/software/netcdf-java/reference/HTTPauthentication.html,
> > > which says that I should create a CredentialsProvider and register it
> > > using ucar.nc2.dataset.HttpClientManager.init().  However, there is no
> > > class called HttpClientManager in the ucar.nc2.dataset package, or
> > > indeed anywhere in the nj22 distribution that I can see.
> > >
> > > What is the best way to read data from authenticated OPeNDAP servers?
> > > I am using nj22 version 2.2.16.
> > >
> > > 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
> --------------------------------------------------------------
>



-- 
--------------------------------------------------------------
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
--------------------------------------------------------------


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