title: Can I generate my own keytab programmatically in Java?
body: <p>I was wondering if there was a way to generate my own keytab in java without going to the kdc? I found code similar to this in an ApachDS test:</p>
  
  <pre><code>    Keytab keytab = Keytab.getInstance(); 
      KerberosTime timeStamp = new KerberosTime(KerberosUtils.UTC_DATE_FORMAT.parse("20070217235745Z"));
  
      Map&lt;EncryptionType, EncryptionKey&gt; keys = KerberosKeyFactory
          .getKerberosKeys(principalName, userPassword);
  
  
  
      KeytabEntry keytabEntry = new KeytabEntry(
          principalName, 
          1L,
          timeStamp, 
          (byte) 0,
          keys.get(EncryptionType.DES_CBC_MD5));
  
      List&lt;KeytabEntry&gt; entry = Arrays.asList(keytabEntry);
  
      keytab.setEntries(entry);
  
      keytab.write(keytabFile);
  
      return keytabFile;
  </code></pre>
  
  <p>I'm able to a klist on a keytab that i create:</p>
  
  <p>Vno  Type         Principal                  Date        Aliases</p>
  
  <p>0  des-cbc-md5  ssh/localhost@EXAMPLE.COM  2007-02-17  </p>
  
  <p>Also, if this is not possible, is there a way to programmatically get a keytab using ApacheDS or any other java library?</p>