Enum Class KafkaAuthType

java.lang.Object
java.lang.Enum<KafkaAuthType>
org.apache.camel.component.kafka.security.KafkaAuthType
All Implemented Interfaces:
Serializable, Comparable<KafkaAuthType>, Constable

public enum KafkaAuthType extends Enum<KafkaAuthType>
Supported Kafka authentication mechanisms.

This enum provides a simplified way to configure Kafka authentication without having to manually construct JAAS configuration strings. When used with KafkaSecurityConfigurer, it automatically derives the correct securityProtocol, saslMechanism, and saslJaasConfig values.

Example usage:

 // Using the enum directly
 KafkaAuthType authType = KafkaAuthType.SCRAM_SHA_512;

 // With KafkaSecurityConfigurer
 KafkaSecurityConfigurer.forAuthType(KafkaAuthType.SCRAM_SHA_512)
         .withCredentials("username", "password")
         .configure(kafkaConfiguration);
 
  • Enum Constant Details

    • NONE

      public static final KafkaAuthType NONE
      No authentication (insecure, typically for development only).

      Uses PLAINTEXT security protocol with no SASL mechanism.

    • PLAIN

      public static final KafkaAuthType PLAIN
      SASL/PLAIN authentication with username and password.

      Uses PlainLoginModule for authentication. Credentials are sent in clear text, so this should only be used with SSL/TLS encryption (SASL_SSL).

    • SCRAM_SHA_256

      public static final KafkaAuthType SCRAM_SHA_256
      SASL/SCRAM-SHA-256 authentication.

      Uses ScramLoginModule with SHA-256 hashing. More secure than PLAIN as passwords are not sent in clear text.

    • SCRAM_SHA_512

      public static final KafkaAuthType SCRAM_SHA_512
      SASL/SCRAM-SHA-512 authentication.

      Uses ScramLoginModule with SHA-512 hashing. More secure than SCRAM-SHA-256 due to stronger hash algorithm.

    • SSL

      public static final KafkaAuthType SSL
      SSL/TLS authentication with client certificates (mTLS).

      Uses SSL security protocol. Requires keystore and truststore configuration for mutual TLS authentication.

    • OAUTH

      public static final KafkaAuthType OAUTH
      OAuth 2.0 / OIDC authentication.

      Uses OAuthBearerLoginModule for token-based authentication. Requires OAuth client credentials and token endpoint configuration.

    • AWS_MSK_IAM

      public static final KafkaAuthType AWS_MSK_IAM
      AWS MSK IAM authentication.

      Uses AWS IAM for authentication with Amazon MSK. Requires the aws-msk-iam-auth library on the classpath. Uses instance credentials or configured AWS credentials.

    • KERBEROS

      public static final KafkaAuthType KERBEROS
      Kerberos/GSSAPI authentication.

      Uses Kerberos for authentication. Requires Kerberos configuration including principal and keytab.

  • Method Details

    • values

      public static KafkaAuthType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static KafkaAuthType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDefaultSecurityProtocol

      public String getDefaultSecurityProtocol()
      Returns the default security protocol for this authentication type.
      Returns:
      the default security protocol (e.g., "SASL_SSL", "SSL", "PLAINTEXT")
    • getSaslMechanism

      public String getSaslMechanism()
      Returns the SASL mechanism for this authentication type.
      Returns:
      the SASL mechanism (e.g., "PLAIN", "SCRAM-SHA-512"), or null if not a SASL auth type
    • getLoginModuleClass

      public String getLoginModuleClass()
      Returns the fully qualified class name of the JAAS login module.
      Returns:
      the login module class name, or null if not applicable
    • requiresCredentials

      public boolean requiresCredentials()
      Returns whether this authentication type requires username and password credentials.
      Returns:
      true if credentials are required (PLAIN, SCRAM-SHA-256, SCRAM-SHA-512)
    • requiresOAuth

      public boolean requiresOAuth()
      Returns whether this authentication type uses OAuth 2.0.
      Returns:
      true if OAuth authentication is used
    • requiresSsl

      public boolean requiresSsl()
      Returns whether this authentication type uses SSL/mTLS without SASL.
      Returns:
      true if SSL-only authentication is used
    • isSasl

      public boolean isSasl()
      Returns whether this authentication type uses a SASL mechanism.
      Returns:
      true if a SASL mechanism is used
    • requiresKerberos

      public boolean requiresKerberos()
      Returns whether this authentication type uses Kerberos.
      Returns:
      true if Kerberos authentication is used
    • requiresAwsMskIam

      public boolean requiresAwsMskIam()
      Returns whether this authentication type uses AWS MSK IAM.
      Returns:
      true if AWS MSK IAM authentication is used