Currently KeytabEncoder.write() always allocate 512 bytes as the buffer size, and doesn't consider the entities list size.
For each entity, KeytabEncoder.putKeytabEntry() allocates 100 buffer size.
This mechanism fails when we create multiple principals in one keytab file.
KeytabEncoder.write() method should take into account the size of entries list to determine the buffer size. And a reasonable max size (100 currently) per entry must be determined.