private SmbTreeImpl connectTree ( SmbResourceLocatorImpl loc, String addr, String share, SmbTransportInternal trans, SmbTreeImpl t,
            DfsReferralData referral ) throws CIFSException {
        if ( log.isDebugEnabled() && trans.isSigningOptional() && !loc.isIPC() && !this.ctx.getConfig().isSigningEnforced() ) {
            log.debug("Signatures for file enabled but not required " + this);
        }

        if ( referral != null ) {
            t.markDomainDfs();
        }

        try {
            if ( log.isTraceEnabled() ) {
                log.trace("doConnect: " + addr);
            }
            t.treeConnect(null, null);
            return t.acquire();
        }
        catch ( SmbAuthException sae ) {
            log.debug("Authentication failed", sae);
            if ( t.getSession().getCredentials().isAnonymous() ) { // anonymous session, refresh
                try ( SmbSessionInternal s = trans
                        .getSmbSession(this.ctx.withAnonymousCredentials(), t.getSession().getTargetHost(), t.getSession().getTargetDomain())
                        .unwrap(SmbSessionInternal.class);
                      SmbTreeImpl tr = s.getSmbTree(null, null).unwrap(SmbTreeImpl.class) ) {
                    tr.treeConnect(null, null);
                    log.debug("Anonymous retry succeeded");
                    return tr.acquire();
                }
                catch ( Exception e ) {
                    log.debug("Retry also failed", e);
                    throw sae;
                }
            }
            else if ( this.ctx.renewCredentials(loc.getURL().toString(), sae) ) {
                log.debug("Trying to renew credentials after auth error");
                try ( SmbSessionInternal s = trans.getSmbSession(this.ctx, t.getSession().getTargetHost(), t.getSession().getTargetDomain())
                        .unwrap(SmbSessionInternal.class);
                      SmbTreeImpl tr = s.getSmbTree(share, null).unwrap(SmbTreeImpl.class) ) {
                    if ( referral != null ) {
                        tr.markDomainDfs();
                    }
                    tr.treeConnect(null, null);
                    return tr.acquire();
                }
            }
            else {
                throw sae;
            }
        }
    }
private SmbTreeImpl connectTree ( SmbResourceLocatorImpl loc , String addr , String share , SmbTransportInternal trans , SmbTreeImpl t , DfsReferralData referral ) throws CIFSException { if ( log . isDebugEnabled ( ) && trans . isSigningOptional ( ) && ! loc . isIPC ( ) && ! this . ctx . getConfig ( ) . isSigningEnforced ( ) ) { log . debug ( "Signatures for file enabled but not required " + this ) ; } if ( referral != null ) { t . markDomainDfs ( ) ; } try { if ( log . isTraceEnabled ( ) ) { log . trace ( "doConnect: " + addr ) ; } t . treeConnect ( null , null ) ; return t . acquire ( ) ; } catch ( SmbAuthException sae ) { log . debug ( "Authentication failed" , sae ) ; if ( t . getSession ( ) . getCredentials ( ) . isAnonymous ( ) ) { try ( SmbSessionInternal s = trans . getSmbSession ( this . ctx . withAnonymousCredentials ( ) , t . getSession ( ) . getTargetHost ( ) , t . getSession ( ) . getTargetDomain ( ) ) . unwrap ( SmbSessionInternal . class ) ; SmbTreeImpl tr = s . getSmbTree ( null , null ) . unwrap ( SmbTreeImpl . class ) ) { tr . treeConnect ( null , null ) ; log . debug ( "Anonymous retry succeeded" ) ; return tr . acquire ( ) ; } catch ( Exception e ) { log . debug ( "Retry also failed" , e ) ; throw sae ; } } else if ( this . ctx . renewCredentials ( loc . getURL ( ) . toString ( ) , sae ) ) { log . debug ( "Trying to renew credentials after auth error" ) ; try ( SmbSessionInternal s = trans . getSmbSession ( this . ctx , t . getSession ( ) . getTargetHost ( ) , t . getSession ( ) . getTargetDomain ( ) ) . unwrap ( SmbSessionInternal . class ) ; SmbTreeImpl tr = s . getSmbTree ( share , null ) . unwrap ( SmbTreeImpl . class ) ) { if ( referral != null ) { tr . markDomainDfs ( ) ; } tr . treeConnect ( null , null ) ; return tr . acquire ( ) ; } } else { throw sae ; } } }
@param loc
@param addr
@param trans
@param t
@throws CIFSException