docs: private void validateNegotiation ( SmbTransportImpl trans, SmbSessionImpl sess ) throws CIFSException {
          if ( !trans.isSMB2() || sess.getCredentials().isAnonymous() || sess.getCredentials().isGuest()
                  || !sess.getConfig().isRequireSecureNegotiate() ) {
              log.debug("Secure negotiation does not apply");
              return;
          }
  
          Smb2NegotiateResponse nego = (Smb2NegotiateResponse) trans.getNegotiateResponse();
          if ( nego.getSelectedDialect().atLeast(DialectVersion.SMB311) ) {
              // have preauth integrity instead
              log.debug("Secure negotiation does not apply, is SMB3.1");
              return;
          }
          Smb2NegotiateRequest negoReq = new Smb2NegotiateRequest(sess.getConfig(), trans.getRequestSecurityMode(nego));
  
          log.debug("Sending VALIDATE_NEGOTIATE_INFO");
          Smb2IoctlRequest req = new Smb2IoctlRequest(sess.getConfig(), Smb2IoctlRequest.FSCTL_VALIDATE_NEGOTIATE_INFO);
          req.setFlags(Smb2IoctlRequest.SMB2_O_IOCTL_IS_FSCTL);
          req.setInputData(
              new ValidateNegotiateInfoRequest(
                  negoReq.getCapabilities(),
                  negoReq.getClientGuid(),
                  (short) negoReq.getSecurityMode(),
                  negoReq.getDialects()));
  
          Smb2IoctlResponse resp;
          try {
              resp = send(req, RequestParam.NO_RETRY);
          }
          catch ( SMBSignatureValidationException e ) {
              throw new SMBProtocolDowngradeException("Signature error during negotiate validation", e);
          }
          catch ( SmbException e ) {
              if ( log.isDebugEnabled() ) {
                  log.debug(String.format("VALIDATE_NEGOTIATE_INFO response code 0x%x", e.getNtStatus()));
              }
              log.trace("VALIDATE_NEGOTIATE_INFO returned error", e);
              if ( ( req.getResponse().isReceived() && req.getResponse().isVerifyFailed() ) || e.getNtStatus() == NtStatus.NT_STATUS_ACCESS_DENIED ) {
                  // this is the signature error
                  throw new SMBProtocolDowngradeException("Signature error during negotiate validation", e);
              }
  
              // other errors are treated as success
              return;
          }
          ValidateNegotiateInfoResponse out = resp.getOutputData(ValidateNegotiateInfoResponse.class);
  
          if ( nego.getSecurityMode() != out.getSecurityMode() || nego.getCapabilities() != out.getCapabilities()
                  || nego.getDialectRevision() != out.getDialect() || !Arrays.equals(nego.getServerGuid(), out.getServerGuid()) ) {
              log.debug("Secure negotiation failure");
              throw new CIFSException("Mismatched attributes validating negotiate info");
          }
  
          log.debug("Secure negotiation OK");
      }