[jcifs] Hosts and shares enumeration
Eric
eglass1 at comcast.net
Wed Jun 30 01:01:27 GMT 2004
>
> 1) Authentication failure generates an "IllegalStateException: Already
> connected". I haven't traced this down but would it be possible to throw a
> regular exception (e.g. IOException) with the SmbAuthException text? That
> would be much more infomative.
>
Whoops -- that's a bug; lines ~470 should be:
if (allowUserInteraction && attempt < MAX_REDIRECTS) {
reconnect();
} else {
break;
}
Basically the loop should only occur if allowUserInteraction is true (as
otherwise it will just keep trying the known bad credentials).
>
> 2) When specifying credentials in the HTTP URL the domain separator is '\'
> or '/' which are both illegal characters in the authority component. I
> think it was determined at one time that the only valid separator
> character in the authority component that is not already reserved is ';'.
> That's what the SMB URL uses.
Actually, I originally intended it to take something like:
http://DOM%5Ceglass:password@server/
i.e. the encoded '\'; this was for compatibility with IE, since you used
to be able to specify credentials in the URL bar this way. This syntax
has since been disabled in a security update to IE:
http://support.microsoft.com/default.aspx?scid=kb;en-us;834489
Really (as you mentioned previously), it's rarely a good idea to specify
credentials in *any* URL. But support for ';' as a separator would be
fairly easy to put in (since as noted that would be compatible with the
SMB separator).
>
> Finally, how do I do a POST request? The following code does not work. It
> doesn't even send an HTTP request at all.
>
> import java.io.*;
> import java.net.*;
>
> public class HttpPut {
>
> public static void main( String[] args ) throws Exception {
> jcifs.Config.registerSmbURLHandler();
> URL url = new URL(args[0]);
> HttpURLConnection con = (HttpURLConnection) url.openConnection();
> con.setDoOutput(true);
> con.setRequestMethod("PUT");
> con.connect();
> PrintStream out = new PrintStream( con.getOutputStream() );
> out.println( "This is some POST data" );
> out.flush();
> Thread.sleep( 10000 );
> }
> }
>
> Mike
>
This is a PUT, which I haven't toyed with; POST would be similar to what
you have, just s/PUT/POST. Also, you might need to read from/check the
response code after writing (i.e. con.getResponseCode()); the underlying
connection typically won't read the pending server output unless an
explicit read occurs (since after that has happened you can no longer
write to the connection, which was the original problem we had with POSTs).
Eric
More information about the jcifs
mailing list