private SmbNegotiation negotiate2 ( Smb2NegotiateResponse first ) throws IOException, SocketException {
        int size = 0;

        int securityMode = getRequestSecurityMode(first);

        // further negotiation needed
        Smb2NegotiateRequest smb2neg = new Smb2NegotiateRequest(getContext().getConfig(), securityMode);
        Smb2NegotiateResponse r = null;
        byte[] negoReqBuffer = null;
        byte[] negoRespBuffer = null;
        try {
            smb2neg.setRequestCredits(Math.max(1, this.desiredCredits - this.credits.availablePermits()));

            int reqLen = negotiateWrite(smb2neg, first != null);
            boolean doPreauth = getContext().getConfig().getMaximumVersion().atLeast(DialectVersion.SMB311);
            if ( doPreauth ) {
                negoReqBuffer = new byte[reqLen];
                System.arraycopy(this.sbuf, 4, negoReqBuffer, 0, reqLen);
            }

            negotiatePeek();

            r = smb2neg.initResponse(getContext());
            int respLen = r.decode(this.sbuf, 4);
            r.received();

            if ( doPreauth ) {
                negoRespBuffer = new byte[respLen];
                System.arraycopy(this.sbuf, 4, negoRespBuffer, 0, respLen);
            }
            else {
                negoReqBuffer = null;
            }

            if ( log.isTraceEnabled() ) {
                log.trace(r.toString());
                log.trace(Hexdump.toHexString(this.sbuf, 4, size));
            }
            return new SmbNegotiation(smb2neg, r, negoReqBuffer, negoRespBuffer);
        }
        finally {
            int grantedCredits = r != null ? r.getGrantedCredits() : 0;
            if ( grantedCredits == 0 ) {
                grantedCredits = 1;
            }
            this.credits.release(grantedCredits);
            Arrays.fill(this.sbuf, (byte) 0);
        }
    }
private SmbNegotiation negotiate2 ( Smb2NegotiateResponse first ) throws IOException , SocketException { int size = 0 ; int securityMode = getRequestSecurityMode ( first ) ; Smb2NegotiateRequest smb2neg = new Smb2NegotiateRequest ( getContext ( ) . getConfig ( ) , securityMode ) ; Smb2NegotiateResponse r = null ; byte [ ] negoReqBuffer = null ; byte [ ] negoRespBuffer = null ; try { smb2neg . setRequestCredits ( Math . max ( 1 , this . desiredCredits - this . credits . availablePermits ( ) ) ) ; int reqLen = negotiateWrite ( smb2neg , first != null ) ; boolean doPreauth = getContext ( ) . getConfig ( ) . getMaximumVersion ( ) . atLeast ( DialectVersion . SMB311 ) ; if ( doPreauth ) { negoReqBuffer = new byte [ reqLen ] ; System . arraycopy ( this . sbuf , 4 , negoReqBuffer , 0 , reqLen ) ; } negotiatePeek ( ) ; r = smb2neg . initResponse ( getContext ( ) ) ; int respLen = r . decode ( this . sbuf , 4 ) ; r . received ( ) ; if ( doPreauth ) { negoRespBuffer = new byte [ respLen ] ; System . arraycopy ( this . sbuf , 4 , negoRespBuffer , 0 , respLen ) ; } else { negoReqBuffer = null ; } if ( log . isTraceEnabled ( ) ) { log . trace ( r . toString ( ) ) ; log . trace ( Hexdump . toHexString ( this . sbuf , 4 , size ) ) ; } return new SmbNegotiation ( smb2neg , r , negoReqBuffer , negoRespBuffer ) ; } finally { int grantedCredits = r != null ? r . getGrantedCredits ( ) : 0 ; if ( grantedCredits == 0 ) { grantedCredits = 1 ; } this . credits . release ( grantedCredits ) ; Arrays . fill ( this . sbuf , ( byte ) 0 ) ; } }
@param first
@param n
@return
@throws IOException
@throws SocketException
@throws InterruptedException