// We force using one etype so the output is determined
Files.write(Paths.get("krb5.conf"), List.of( "[libdefaults]", "default_tkt_enctypes = aes128-cts"
));
System.setProperty("java.security.krb5.conf", "krb5.conf");
KeyTab kt = KeyTab.create("ktab"); int num = 0; while (true) {
num++;
PrincipalName pn = new PrincipalName(
String.format("user%03d@REALM", num));
kt.addEntry(pn, "password".toCharArray(), num, true); int length = 2; for (KeyTabEntry e : kt.getEntries()) {
length += e.entryLength() + 4;
} // Create enough big keytab if (length > 8400) { break;
}
}
kt.save();
int count = 0; boolean written = false; try (KeyTabInputStream kin
= new KeyTabInputStream(new FileInputStream("ktab"));
KeyTabOutputStream kout
= new KeyTabOutputStream(new FileOutputStream("ktab2"))) {
kout.write(kin.readNBytes(2)); // version
count += 2; while (true) { int len;
try {
len = kin.read(4);
} catch (IOException e) { break; // reach end
}
count += 4; byte[] data = kin.readNBytes(len);
count += len; if (count < 8192 || written) {
kout.write32(len);
kout.write(data);
} else { // Create a hole on the 8192 boundary
kout.write32(-len);
kout.write(newbyte[len]);
written = true;
}
}
}
kt = KeyTab.getInstance("ktab2"); if (!kt.isValid()) { thrownew Exception("Should be valid");
} if (kt.getEntries().length != num - 1) { thrownew Exception("Should have " + (num - 1) + " entries");
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.