cmccabe commented on a change in pull request #9032: URL: https://github.com/apache/kafka/pull/9032#discussion_r465370586
########## 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)) Review comment: I'd really prefer some way to just get the `value` byte out of the ScramMechanism object, rather than relying on the ordering of enum entries. If we are going to rely on the ordering, that would have to be prominently documented in the class (but let's not....) ---------------------------------------------------------------- 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