Search in sources :

Example 1 with KerberosTime

use of org.apache.kerby.kerberos.kerb.type.KerberosTime in project hadoop by apache.

the class TestKerberosUtil method createKeyTab.

private void createKeyTab(String fileName, String[] principalNames) throws IOException {
    //create a test keytab file
    List<KeytabEntry> lstEntries = new ArrayList<KeytabEntry>();
    for (String principal : principalNames) {
        // duplicate principals
        for (int kvno = 1; kvno <= 3; kvno++) {
            EncryptionKey key = new EncryptionKey(EncryptionType.NONE, "samplekey1".getBytes(), kvno);
            KeytabEntry keytabEntry = new KeytabEntry(new PrincipalName(principal), new KerberosTime(), (byte) 1, key);
            lstEntries.add(keytabEntry);
        }
    }
    Keytab keytab = new Keytab();
    keytab.addKeytabEntries(lstEntries);
    keytab.store(new File(testKeytab));
}
Also used : Keytab(org.apache.kerby.kerberos.kerb.keytab.Keytab) ArrayList(java.util.ArrayList) KerberosTime(org.apache.kerby.kerberos.kerb.type.KerberosTime) EncryptionKey(org.apache.kerby.kerberos.kerb.type.base.EncryptionKey) PrincipalName(org.apache.kerby.kerberos.kerb.type.base.PrincipalName) File(java.io.File) KeytabEntry(org.apache.kerby.kerberos.kerb.keytab.KeytabEntry)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 Keytab (org.apache.kerby.kerberos.kerb.keytab.Keytab)1 KeytabEntry (org.apache.kerby.kerberos.kerb.keytab.KeytabEntry)1 KerberosTime (org.apache.kerby.kerberos.kerb.type.KerberosTime)1 EncryptionKey (org.apache.kerby.kerberos.kerb.type.base.EncryptionKey)1 PrincipalName (org.apache.kerby.kerberos.kerb.type.base.PrincipalName)1