code: @Override
      public void doHandshake(NextFilter nextFilter) throws ProxyAuthException {
          LOGGER.debug(" doHandshake()");
  
          if (step > 0 && challengePacket == null) {
              throw new IllegalStateException("NTLM Challenge packet not received");
          }
          
          HttpProxyRequest req = (HttpProxyRequest) request;
          Map<String, List<String>> headers = req.getHeaders() != null ? req
                  .getHeaders() : new HashMap<>();
  
          String domain = req.getProperties().get(
                  HttpProxyConstants.DOMAIN_PROPERTY);
          String workstation = req.getProperties().get(
                  HttpProxyConstants.WORKSTATION_PROPERTY);
  
          if (step > 0) {
              LOGGER.debug("  sending NTLM challenge response");
  
              byte[] challenge = NTLMUtilities
                      .extractChallengeFromType2Message(challengePacket);
              int serverFlags = NTLMUtilities
                      .extractFlagsFromType2Message(challengePacket);
  
              String username = req.getProperties().get(
                      HttpProxyConstants.USER_PROPERTY);
              String password = req.getProperties().get(
                      HttpProxyConstants.PWD_PROPERTY);
  
              byte[] authenticationPacket = NTLMUtilities.createType3Message(
                      username, password, challenge, domain, workstation,
                      serverFlags, null);
  
                  StringUtilities.addValueToHeader(headers,
                          "Proxy-Authorization", 
                          "NTLM "+ new String(Base64
                                          .encodeBase64(authenticationPacket)),
                          true);
  
              } else {
                  LOGGER.debug("  sending NTLM negotiation packet");
  
                  byte[] negotiationPacket = NTLMUtilities.createType1Message(
                          workstation, domain, null, null);
                  StringUtilities
                          .addValueToHeader(
                                  headers,
                                  "Proxy-Authorization",
                                  "NTLM "+ new String(Base64
                                            .encodeBase64(negotiationPacket)),
                                  true);
              }
  
              addKeepAliveHeaders(headers);
              req.setHeaders(headers);
  
          writeRequest(nextFilter, req);
          step++;
      }
docs: {@inheritDoc}