code: private String generateDigest(boolean passwordAlreadyEncoded, String username,
                                   String realm, String password, String httpMethod, String uri, String qop,
                                   String nonce, String nc, String cnonce) {
          String ha1;
          String a2 = httpMethod + ":" + uri;
          String ha2 = CredentialUtil.encryptMD5(a2);
  
          if (passwordAlreadyEncoded) {
              ha1 = password;
          } else {
              ha1 = CredentialUtil.encryptMD5(username + ":" + realm + ":" +password);
          }
  
          String digest;
  
          if (qop == null) {
              digest = CredentialUtil.encryptMD5(ha1, nonce + ":" + ha2);
          } else if ("auth".equals(qop)) {
              digest = CredentialUtil.encryptMD5(ha1, nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + ha2);
          } else {
              throw new TechnicalException("Invalid qop: '" + qop + "'");
          }
  
          return digest;
      }
docs: generate digest token based on RFC 2069 and RFC 2617 guidelines
  
  @return digest token