C0urante commented on code in PR #12010:
URL: https://github.com/apache/kafka/pull/12010#discussion_r853542111


##########
clients/src/main/java/org/apache/kafka/common/config/internals/BrokerSecurityConfigs.java:
##########
@@ -89,4 +91,31 @@ public class BrokerSecurityConfigs {
             + "The broker will disconnect any such connection that is not 
re-authenticated within the session lifetime and that is then subsequently "
             + "used for any purpose other than re-authentication. 
Configuration names can optionally be prefixed with listener prefix and SASL "
             + "mechanism name in lower-case. For example, 
listener.name.sasl_ssl.oauthbearer.connections.max.reauth.ms=3600000";
+
+    public static class SaslEnabledMechanismsValidator implements 
ConfigDef.Validator {
+        @Override
+        public void ensureValid(String name, Object value) {
+            if (value == null) {
+                throw new ConfigException(name, null, "entry must be non 
null");
+            }
+
+            @SuppressWarnings("unchecked")
+            List<String> mechanismStrings = (List) value;
+
+            if (mechanismStrings.isEmpty()) {
+                throw new ConfigException(name, null, "entry must be non-empty 
list");
+            }
+
+            mechanismStrings.forEach(mechanism -> {
+                if (mechanism == null || mechanism.isEmpty()) {
+                    throw new ConfigException(name, mechanism, "enabled 
mechanism must be non-null or non-empty string");

Review Comment:
   The message that users will see from this exception will be "Invalid value 
<mechanism> for configuration sasl.enabled.mechanisms: enabled mechanism must 
be non-null or non-empty string" (see 
[ConfigException](https://github.com/apache/kafka/blob/9c3f605fc78f297ecf5accdcdec18471c19cf7d6/clients/src/main/java/org/apache/kafka/common/config/ConfigException.java#L37)
 for the message generation logic).
   
   Considering the message will already include the name of the property, which 
itself mentions SASL, I'm not sure it's really necessary to specify it again.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to