pprovenzano commented on code in PR #13114: URL: https://github.com/apache/kafka/pull/13114#discussion_r1107184550
########## metadata/src/main/java/org/apache/kafka/image/ScramImage.java: ########## @@ -50,6 +58,63 @@ public void write(ImageWriter writer, ImageWriterOptions options) { } } + public DescribeUserScramCredentialsResponseData describe(DescribeUserScramCredentialsRequestData request) { + + List<UserName> users = request.users(); + Map<String, Boolean> uniqueUsers = new HashMap<String, Boolean>(); + + if ((users == null) || (users.size() == 0)) { + System.out.println("Describe : get all the users"); + // If there are no users listed then get all the users + for (Map<String, ScramCredentialData> scramCredentialDataSet : mechanisms.values()) { + for (String user : scramCredentialDataSet.keySet()) { + uniqueUsers.put(user, false); + } + } + } else { + // Filter out duplicates + for (UserName user : users) { + if (uniqueUsers.containsKey(user.name())) { + uniqueUsers.put(user.name(), true); + } else { + uniqueUsers.put(user.name(), false); + } + } + } + + DescribeUserScramCredentialsResponseData retval = new DescribeUserScramCredentialsResponseData(); + + for (Map.Entry<String, Boolean> user : uniqueUsers.entrySet()) { + DescribeUserScramCredentialsResult result = + new DescribeUserScramCredentialsResult().setUser(user.getKey()); + + if (user.getValue() == false) { + List<CredentialInfo> credentialInfos = new ArrayList<CredentialInfo>(); + + boolean datafound = false; + for (Map.Entry<ScramMechanism, Map<String, ScramCredentialData>> mechanismsEntry : mechanisms.entrySet()) { Review Comment: No, in our implementation we will never create a `Map<String, ScramCredentialData>` for ScramMechanism.UNKNOWN because we never populate any credentials for an unknown mechanism. Thus I can iterate over the maps knowing that they are all valid. -- 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