[jcifs] Suggested modification to handle authenication with IPC$
Michael B Allen
mballen at erols.com
Sat Feb 16 14:15:05 EST 2002
On Fri, 15 Feb 2002 18:37:44 -0800
Sean Ryan <sryan at clear-tec.com> wrote:
> This mod (to the SmbFile class) will enable use of the AuthHandler when
> authentication fails with an IPC$ pipe with the URL provided credentials,
> and then with null credentials. Previously, it got stuck in a loop if
> authentication failed with the supplied credentials and then with null
> credentials.
The !u.equals( "" ) should stop the loop if you failed, tried "null"
credentials and failed again. How do you get stuck in a loop? You know
if you return false from authenticate() se will be thrown right? I'm
not sure I understand.
Mike
> void sendTransaction( SmbComTransaction request,
> SmbComTransactionResponse response ) throws SmbException {
> String u, p, d;
>
> u = authInfo.username;
> p = authInfo.password;
> d = authInfo.domain;
> boolean triedNullAuth = false;
>
> while( true ) {
> if( tree == null ) {
> SmbTransport trans = SmbTransport.getSmbTransport( getAddress(), port );
> SmbSession ssn = trans.getSmbSession( u, p, d );
> tree = ssn.getSmbTree( share, null );
> }
> try {
> // BUG ?
> request.hasMore = request.isPrimary = true;
> tree.sendTransaction( request, response );
> break;
> } catch( SmbAuthException sae ) {
> tree = null;
>
> if(( share == null || share.equalsIgnoreCase( "IPC$" )) &&
> (u == null || !u.equals( "" )) && !triedNullAuth) {
> // AuthException trying to access IPC$, try "null" credentials
> u = p = "";
> d = null;
> triedNullAuth = true;
> } else if( authHandler == null ) {
> throw sae;
> } else {
> authInfo.exception = sae;
> authInfo.target = url;
> if( authHandler.authenticate( authInfo ) == false ) {
> authInfo.username = null;
> authInfo.password = null;
> authInfo.domain = null;
> throw sae;
> }
> u = authInfo.username;
> p = authInfo.password;
> d = authInfo.domain;
> }
> }
> }
> }
--
May The Source be with you.
More information about the jcifs
mailing list