Ersetzen Sie Sun.security.krb5.* Verwendung (keine Problemumgehung d. H.Java

Java-Forum
Anonymous
 Ersetzen Sie Sun.security.krb5.* Verwendung (keine Problemumgehung d. H.

Post by Anonymous »

Ich migriere eine alte Java -Codebasis von JDK 8 bis JDK 17 und brauche einen Ersatz für die Sonne. Security.krb5.

Code: Select all

import sun.security.krb5.KrbException;
import sun.security.krb5.PrincipalName;
import sun.security.krb5.RealmException;
< /code>
  sun.security.krb5.Credentials getCredentialsFromCache()
throws RealmException, KrbException, IOException {

PrincipalName principalName = new PrincipalName(this.principal,
PrincipalName.KRB_NT_PRINCIPAL);
sun.security.krb5.Credentials credentials = sun.security.krb5.Credentials
.acquireTGTFromCache(principalName, ticketCache);
return credentials;
}
< /code>
This code worked fine in JDK 8, but with JDK 17, sun.security.krb5.* is encapsulated, and I want to find an alternative without relying on --add-exports
als Problemumgehung.
Ich erhalte den folgenden Fehler
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project some-project: Compilation failure: Compilation failure: [ERROR] /path/to/java/file/SomeCleass.java:[35,20] package sun.security.krb5 is not visible [ERROR] (package sun.security.krb5 is declared in module java.security.jgss, which does not export it to the unnamed module)
< /code>
The existing code also dynamically loads Kerberos configuration classes based on the Java vendor:
private Class getKrbConfigClass() throws ClassNotFoundException {
Class classRef;
if (System.getProperty("java.vendor").contains("IBM")) {
classRef = Class.forName(IBM_CONFIG);
} else {
classRef = Class.forName(SUN_CONFIG);
}
return classRef;
}
< /code>
Since sun.security.krb5.Config is no longer accessible, what is the best way to achieve the same functionality in JDK 17?
  • What are the official replacements for sun.security.krb5.* classes in JDK 17?
  • Is there a recommended way to fetch Kerberos credentials from cache without using internal APIs?
  • How should we properly handle Kerberos configuration loading in a Java vendor-independent way?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post