[jcifs] Problems with getOutputStream for a jCIFS client

Michael B Allen mba2000 at ioplex.com
Thu Apr 29 02:36:03 GMT 2004


Eric,

I'm fixing the NPA hash invalidation when transport closes. I was just
going to add the following to NPA and call it from
SmbSession.sessionSetup:

void validateChallenge( byte[] challenge ) {
    if( this.challenge == challenge ) {
        return;
    }
    this.challenge = challenge;
    this.ansihash = this.unicodeHash = null; // force recompute
}

Since the encryptionKey is created with new byte[] in
SmbComNegotiateReponse every time the client negotiates this should ensure
that no session setup can be performed with an invalid challange. Was this
what you were thinking when we spoke previously about this? I don't
recall. Do you have a better suggestion?

Also, can the error described below by Jan Christian Herlitz be attributed
to our NtlmHttpURLConnection? I would like to explore this error and work
out a test case for the above code change at the same time. I'm reasoning
I can use the NtlmHttpURLConnection to test NPA challenge invalidation as
well as the PUT method with one Servlet. That will test the
NtlmHttpURLConnection code as well. But I'm not very good at writing
servlets. Can someone write a Servlet for me that accepts a PUT request
and prints "Hello, world"?

Mike

Jan Christian Herlitz said:
>
> Hello,
>
> JCIFS works fantastic in our Tomcat servlet for authentication.
>
> For our client it also works for "input" methods.
> However, for PUT operations I get the following exception:
>
>  java.net.ProtocolException: Cannot write output after reading input.
>    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown
> Source)
>    at
> jcifs.http.NtlmHttpURLConnection.getOutputStream(NtlmHttpURLConnection.java:
> 240)
>
> The code is as follows:
>
>    URL url = new URL(query);
>    HttpURLConnection con = (HttpURLConnection) url.openConnection();
>    con.setDoOutput(true);
>    con.setRequestMethod("PUT");
>    con.connect();
>    OutputStream out = con.getOutputStream();
>
> This worked fine before registering the Smb URL handler.
>
> Regards, Jan Christian Herlitz
>
>
>



More information about the jcifs mailing list