code: public static byte[] createType1Message(String workStation,
              String domain, Integer customFlags, byte[] osVersion) {
          byte[] msg;
  
          if (osVersion != null && osVersion.length != 8) {
              throw new IllegalArgumentException(
                      "osVersion parameter should be a 8 byte wide array");
          }
  
          if (workStation == null || domain == null) {
              throw new NullPointerException(
                      "workStation and domain must be non null");
          }
  
          int flags = customFlags != null ? customFlags
                  | FLAG_NEGOTIATE_WORKSTATION_SUPPLIED
                  | FLAG_NEGOTIATE_DOMAIN_SUPPLIED : DEFAULT_FLAGS;
  
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
  
          try {
              baos.write(NTLM_SIGNATURE);
              baos.write(ByteUtilities.writeInt(MESSAGE_TYPE_1));
              baos.write(ByteUtilities.writeInt(flags));
  
              byte[] domainData = ByteUtilities.getOEMStringAsByteArray(domain);
              byte[] workStationData = ByteUtilities
                      .getOEMStringAsByteArray(workStation);
  
              int pos = (osVersion != null) ? 40 : 32;
              baos.write(writeSecurityBuffer((short) domainData.length, pos
                      + workStationData.length));
              baos
                      .write(writeSecurityBuffer((short) workStationData.length,
                              pos));
  
              if (osVersion != null) {
                  baos.write(osVersion);
              }
  
              // Order is not mandatory since a pointer is given in the security buffers
              baos.write(workStationData);
              baos.write(domainData);
  
              msg = baos.toByteArray();
              baos.close();
          } catch (IOException e) {
              return null;
          }
  
          return msg;
      }
docs: see http://davenport.sourceforge.net/ntlm.html#theType1Message
  
  @param workStation the workstation name
  @param domain the domain name
  @param customFlags custom flags, if null then
  <code>NTLMConstants.DEFAULT_CONSTANTS</code> is used
  @param osVersion the os version of the client, if null then
  <code>NTLMConstants.DEFAULT_OS_VERSION</code> is used
  @return the type 1 message