Package davmail.http

Class KerberosHelper

java.lang.Object
davmail.http.KerberosHelper

public class KerberosHelper extends Object
Kerberos helper class.
  • Field Details

    • LOGGER

      protected static final org.apache.log4j.Logger LOGGER
    • LOCK

      protected static final Object LOCK
    • KERBEROS_CALLBACK_HANDLER

      protected static final KerberosHelper.KerberosCallbackHandler KERBEROS_CALLBACK_HANDLER
  • Method Details

    • setClientPrincipal

      public static void setClientPrincipal(String principal)
      Force client principal in callback handler
      Parameters:
      principal - client principal
    • setClientPassword

      public static void setClientPassword(String password)
      Force client password in callback handler
      Parameters:
      password - client password
    • initSecurityContext

      public static byte[] initSecurityContext(String protocol, String host, byte[] token) throws GSSException, LoginException
      Get response Kerberos token for host with provided token.
      Parameters:
      protocol - target protocol
      host - target host
      token - input token
      Returns:
      response token
      Throws:
      GSSException - on error
      LoginException - on error
    • initSecurityContext

      public static byte[] initSecurityContext(String protocol, String host, GSSCredential delegatedCredentials, byte[] token) throws GSSException, LoginException
      Get response Kerberos token for host with provided token, use client provided delegation credentials. Used to authenticate with target host on a gateway server with client credentials, gateway must have its own principal authorized for delegation
      Parameters:
      protocol - target protocol
      host - target host
      delegatedCredentials - client delegated credentials
      token - input token
      Returns:
      response token
      Throws:
      GSSException - on error
      LoginException - on error
    • internalInitSecContext

      protected static Object internalInitSecContext(String protocol, String host, GSSCredential delegatedCredentials, byte[] token)
    • serverLogin

      public static LoginContext serverLogin(String serverPrincipal, String serverPassword) throws LoginException
      Create server side Kerberos login context for provided credentials.
      Parameters:
      serverPrincipal - server principal
      serverPassword - server password
      Returns:
      LoginContext server login context
      Throws:
      LoginException - on error
    • acceptSecurityContext

      public static KerberosHelper.SecurityContext acceptSecurityContext(LoginContext serverLoginContext, byte[] token) throws GSSException
      Check client provided Kerberos token in server login context
      Parameters:
      serverLoginContext - server login context
      token - Kerberos client token
      Returns:
      result with client principal and optional returned Kerberos token
      Throws:
      GSSException - on error