I'm working on a Java code base that checks whether a Kerberos KeyTab file is valid, but it uses the internal class sun.security.krb5.internal.ktab.KeyTab
for its isValid()
method. Currently, it is doing the following:
File keytabFile = new File("/path/to/keytab");
KeyTab keytab = KeyTab.getInstance(keytabFile);
boolean keytabIsValid = keytab.isValid();
if (!keytabIsValid) {
throw new ApplicationSpecificException("Keytab is not valid");
}
Accessing this method is more of an annoyance in Java 9, so I'm looking for a way to avoid using this internal class, but browsing through the JDK source, I haven't seen anything that exposes the isValid()
method or an equivalent in a non-internal class.
Are there options which don't rely on hacks like reflecting on private methods or accessing internal APIs?