Search in sources :

Example 1 with KeytabEntry

use of org.apache.directory.server.kerberos.shared.keytab.KeytabEntry in project karaf by apache.

the class Krb5LoginModuleTest method createKeytab.

private String createKeytab() throws Exception {
    File file = folder.newFile("test.keytab");
    List<KeytabEntry> entries = new ArrayList<>();
    entries.add(createKeytabEntry());
    Keytab writer = Keytab.getInstance();
    writer.setEntries(entries);
    writer.write(file);
    return file.getAbsolutePath();
}
Also used : Keytab(org.apache.directory.server.kerberos.shared.keytab.Keytab) ArrayList(java.util.ArrayList) File(java.io.File) KeytabEntry(org.apache.directory.server.kerberos.shared.keytab.KeytabEntry)

Example 2 with KeytabEntry

use of org.apache.directory.server.kerberos.shared.keytab.KeytabEntry in project karaf by apache.

the class Krb5LoginModuleTest method createKeytabEntry.

private KeytabEntry createKeytabEntry() throws ParseException {
    String principalName = "hnelson@EXAMPLE.COM";
    int principalType = 1;
    String zuluTime = "20070217235745Z";
    Date date = null;
    synchronized (KerberosUtils.UTC_DATE_FORMAT) {
        date = KerberosUtils.UTC_DATE_FORMAT.parse(zuluTime);
    }
    KerberosTime timeStamp = new KerberosTime(date.getTime());
    byte keyVersion = 1;
    String passPhrase = "secret";
    Map<EncryptionType, EncryptionKey> keys = KerberosKeyFactory.getKerberosKeys(principalName, passPhrase);
    EncryptionKey key = keys.get(EncryptionType.AES128_CTS_HMAC_SHA1_96);
    return new KeytabEntry(principalName, principalType, timeStamp, keyVersion, key);
}
Also used : EncryptionType(org.apache.directory.shared.kerberos.codec.types.EncryptionType) KerberosTime(org.apache.directory.shared.kerberos.KerberosTime) EncryptionKey(org.apache.directory.shared.kerberos.components.EncryptionKey) Date(java.util.Date) KeytabEntry(org.apache.directory.server.kerberos.shared.keytab.KeytabEntry)

Aggregations

KeytabEntry (org.apache.directory.server.kerberos.shared.keytab.KeytabEntry)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Keytab (org.apache.directory.server.kerberos.shared.keytab.Keytab)1 KerberosTime (org.apache.directory.shared.kerberos.KerberosTime)1 EncryptionType (org.apache.directory.shared.kerberos.codec.types.EncryptionType)1 EncryptionKey (org.apache.directory.shared.kerberos.components.EncryptionKey)1