Class KerberosUtils

java.lang.Object
org.apache.gravitino.auth.KerberosUtils

public class KerberosUtils extends Object
Utility class for Kerberos related tests.
  • Field Details

    • GSS_SPNEGO_MECH_OID

      public static final Oid GSS_SPNEGO_MECH_OID
      Oid instance for Kerberos spnego mechanism.
    • GSS_KRB5_MECH_OID

      public static final Oid GSS_KRB5_MECH_OID
      Oid instance for Kerberos mechanism.
    • NT_GSS_KRB5_PRINCIPAL_OID

      public static final Oid NT_GSS_KRB5_PRINCIPAL_OID
      Oid instance for Kerberos principal name.
  • Method Details

    • login

      public static LoginContext login(String principal, String keyTabFile) throws LoginException
      Login to KDC using principal and keytab file.
      Parameters:
      principal - The principal name
      keyTabFile - The keytab file
      Returns:
      The login context
      Throws:
      LoginException - If login fails, or if the principal and keytab file are invalid.
    • doAs

      public static <T> T doAs(Subject subject, Callable<T> callable) throws Exception
      Execute the given action as the given subject.
      Type Parameters:
      T - The return type of the action
      Parameters:
      subject - The subject to execute the action as.
      callable - The action to execute.
      Returns:
      The result of the action
      Throws:
      Exception - If the action throws an exception
    • getKrb5LoginModuleName

      public static String getKrb5LoginModuleName()
      Returns:
      The Kerberos login module name.