[jcifs] Suggested modification to handle authenication with IPC$
Sean Ryan
sryan at clear-tec.com
Sat Feb 16 13:37:44 EST 2002
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.
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;
}
}
}
}
ClearTech Incorporated
Sean Ryan
Development Manager
Citadel
Suite 1550, 13401-108th Avenue
Surrey BC V3T 5T3
CANADA
+1 (604) 588-6964 ext 307 (Voice)
+1 (604) 588-9332 (Fax)
< http://www.clear-tec.com/ <http://www.clear-tec.com/> >
-------------- next part --------------
HTML attachment scrubbed and removed
More information about the jcifs
mailing list