cmccabe commented on a change in pull request #9032:
URL: https://github.com/apache/kafka/pull/9032#discussion_r465393358



##########
File path: core/src/main/scala/kafka/server/AdminManager.scala
##########
@@ -980,4 +984,137 @@ class AdminManager(val config: KafkaConfig,
       entry.entity -> apiError
     }.toMap
   }
+
+  def describeUserScramCredentials(users: Seq[String]): 
DescribeUserScramCredentialsResponseData = {
+    val retval = new DescribeUserScramCredentialsResponseData()
+
+    def addToResults(user: String, userConfig: Properties) = {
+      val configKeys = userConfig.stringPropertyNames
+      val hasScramCredential = !ScramMechanism.values().toList.filter(key => 
key != ScramMechanism.UNKNOWN && 
configKeys.contains(key.toMechanismName)).isEmpty
+      if (hasScramCredential) {
+        val userScramCredentials = new UserScramCredential().setName(user)
+        ScramMechanism.values().foreach(mechanism => if (mechanism != 
ScramMechanism.UNKNOWN) {
+          val propertyValue = userConfig.getProperty(mechanism.toMechanismName)
+          if (propertyValue != null) {
+            val iterations = 
ScramCredentialUtils.credentialFromString(propertyValue).iterations
+            userScramCredentials.credentialInfos.add(new 
CredentialInfo().setMechanism(mechanism.ordinal.toByte).setIterations(iterations))
+          }
+        })
+        retval.userScramCredentials.add(userScramCredentials)
+      }
+    }
+
+    if (users.isEmpty)

Review comment:
       It would be good to avoid confusing empty with null.  Why not use 
Option[Seq[String]]




----------------------------------------------------------------
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.

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


Reply via email to