
Signature
----------------------------------------------------------------------
nospam@mi.iasf.cnr.it is a newsreading account used by more persons to
avoid unwanted spam. Any mail returning to this address will be rejected.
Users can disclose their e-mail address in the article if they wish so.
On May 16, 8:58 am, LC's No-Spam Newsreading account
<nos...@mi.iasf.cnr.it> wrote:
> > On May 15, 9:48 am, LC's No-Spam Newsreading account
> >> This prevents people to bookmark the data files and access them if they
[quoted text clipped - 6 lines]
> And all already nicely managed by an .htaccess file which deals with all
> other possible accesses.
Then I'll leave it to you to determine whether an ultimately
ineffectual security mechanism meets the legal requirements imposed on
you. Nobody said the law (or the contract) made sense. :)
> >> 1) how can I force the applet to declare a specific Referer ?
>
[quoted text clipped - 8 lines]
> DataInputStream in = new DataInputStream (new BufferedInputStream(
> url.openStream(), 2880));
Per the javadocs for java.net.URL, openStream() is shorthand for
openConnection().getInputStream().
> I replaced this with
>
[quoted text clipped - 10 lines]
> (a) is it correct to call explicitly urlc.connect() before getting
> the stream ? Or is it redundant ?
The call to connect() is redundant, but harmless. If no connection
has been made, getInputStream() opens one as if by connect().
> (b) when I've retrieved my data in my quikFitsImage class, I did (and
> still do) an in.close()
[quoted text clipped - 3 lines]
> my applet will call the quikFitsImage repeatedly for different
> images
I see no "disconnect()" method here. Reaching the end of the stream
or closing it are sufficient to close the connection to the server, if
it's still open.
> (c) in my servlet I use DataInputStream in = new DataInputStream (new
> BufferedInputStream(myurl.openStream(), 2880)); similar to above
[quoted text clipped - 4 lines]
> Will url.openConnection() or urlc.connect() throw an exception
> before (and faster) than urlc.getInputStream() ?
openStream() is shorthand for using URLConnection. Calling connect()
on a URLConnection, among other things, sends the request (and after
connect()ing, you can't modify the request properties any more);
whether or not you read the response, at that point the server starts
sending it. So the difference is probably immeasurably small.
It's probably worth noting that just because the server can reach a
given URL does not *necessarily* mean the client can, so I'm not sure
if you're actually gaining anything other than complexity from this
check. The client still needs to be prepared for failures related to
the URL it gets.
-o
LC's No-Spam Newsreading account - 19 May 2008 09:25 GMT
> On May 16, 8:58 am, LC's No-Spam Newsreading account
>>> On May 15, 9:48 am, LC's No-Spam Newsreading account
>> Scientific data right issues.
> Then I'll leave it to you to determine whether an ultimately
> ineffectual security mechanism meets the legal requirements imposed on
> you. Nobody said the law (or the contract) made sense. :)
No lawyers 'round here. Just gentlemen agreements.
>>>> 1) how can I force the applet to declare a specific Referer ?
>> URLConnection urlc = url.openConnection() ;
>> urlc.setRequestProperty("Referer","myApplet24");
[quoted text clipped - 3 lines]
>>
>> And this effectively sets the referer to a string I can test.
>> (b) when I've retrieved my data in my quikFitsImage class, I did (and
>> still do) an in.close()
>> Is it necessary to do urlc.disconnect() ? Or the connection will
>> be reset anyhow ?
> I see no "disconnect()" method here.
"here" means in my code, in URLConnection or in general ? I was aware
that URLConnection has no disconnect() method but I saw
HttpURLConnection has one. So my question was essentially if I should
move to the latter class.
> Reaching the end of the stream or closing it are sufficient to close
> the connection to the server, if it's still open.
Which I interpret as answer "NO" to the question above.
>> (c) in my servlet I use ...
>> myurl.openStream(), 2880)); ...
>> immediately followed by an in.close() ; to test the validity of
>> an URL (a not existing one throws an exception)
> It's probably worth noting that just because the server can reach a
> given URL does not *necessarily* mean the client can, so I'm not sure
> if you're actually gaining anything other than complexity from this
> check. The client still needs to be prepared for failures related to
> the URL it gets.
In practice the servlet test means simply "does a file exist at given
URL" (EXIST, not BE REACHABLE) The servlet will most likely run at the
end on the same machine where the files physically reside. Now it runs
on another machine on the same local network.
The mechanism is a replacement for another couple of possible checks
(one check is that the url, which is linked to the value of a particular
database column, exists conditionally if another flag column in the
database is set to true; the other check assumes inconditional possible
existence and is a simple "unix file existence" test ... the
openStream/close test is just a generalizion from file:// to http://
urls).
The idea is that the applet client won't receive an URL but a null if
the file does not exist, so the user will not even attempt to load it
(the idea is that some sky pointings are outside the area covered by a
given satellite and therefore images in some spectral bands won't
exist).
I believe I have now enough elements to make fruitful tests/ adaptions.
Thanks.

Signature
----------------------------------------------------------------------
nospam@mi.iasf.cnr.it is a newsreading account used by more persons to
avoid unwanted spam. Any mail returning to this address will be rejected.
Users can disclose their e-mail address in the article if they wish so.