Enum Class KafkaAuthType
- All Implemented Interfaces:
Serializable,Comparable<KafkaAuthType>,Constable
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);
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAWS MSK IAM authentication.Kerberos/GSSAPI authentication.No authentication (insecure, typically for development only).OAuth 2.0 / OIDC authentication.SASL/PLAIN authentication with username and password.SASL/SCRAM-SHA-256 authentication.SASL/SCRAM-SHA-512 authentication.SSL/TLS authentication with client certificates (mTLS). -
Method Summary
Modifier and TypeMethodDescriptionReturns the default security protocol for this authentication type.Returns the fully qualified class name of the JAAS login module.Returns the SASL mechanism for this authentication type.booleanisSasl()Returns whether this authentication type uses a SASL mechanism.booleanReturns whether this authentication type uses AWS MSK IAM.booleanReturns whether this authentication type requires username and password credentials.booleanReturns whether this authentication type uses Kerberos.booleanReturns whether this authentication type uses OAuth 2.0.booleanReturns whether this authentication type uses SSL/mTLS without SASL.static KafkaAuthTypeReturns the enum constant of this class with the specified name.static KafkaAuthType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
No authentication (insecure, typically for development only).Uses PLAINTEXT security protocol with no SASL mechanism.
-
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
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
SASL/SCRAM-SHA-512 authentication.Uses ScramLoginModule with SHA-512 hashing. More secure than SCRAM-SHA-256 due to stronger hash algorithm.
-
SSL
SSL/TLS authentication with client certificates (mTLS).Uses SSL security protocol. Requires keystore and truststore configuration for mutual TLS authentication.
-
OAUTH
OAuth 2.0 / OIDC authentication.Uses OAuthBearerLoginModule for token-based authentication. Requires OAuth client credentials and token endpoint configuration.
-
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
Kerberos/GSSAPI authentication.Uses Kerberos for authentication. Requires Kerberos configuration including principal and keytab.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getDefaultSecurityProtocol
Returns the default security protocol for this authentication type.- Returns:
- the default security protocol (e.g., "SASL_SSL", "SSL", "PLAINTEXT")
-
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
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
-