public static byte[] encodeDelegationTokenInformation(DelegationTokenInformation token) {
    try {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      DataOutputStream out = new DataOutputStream(bos);
      WritableUtils.writeVInt(out, token.password.length);
      out.write(token.password);
      out.writeLong(token.renewDate);
      out.flush();
      return bos.toByteArray();
    } catch (IOException ex) {
      throw new RuntimeException("Failed to encode token.", ex);
    }
  }
Workaround for serialization of {@link DelegationTokenInformation} through package access.
Future version of Hadoop should add this to DelegationTokenInformation itself.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/security/token/delegation/MetastoreDelegationTokenSupport.java