public static Set<String> validateScopes(String scopeClaimName, Collection<String> scopes) throws ValidateException {
        if (scopes == null)
            throw new ValidateException(String.format("%s value must be non-null", scopeClaimName));

        Set<String> copy = new HashSet<>();

        for (String scope : scopes) {
            scope = validateString(scopeClaimName, scope);

            if (copy.contains(scope))
                throw new ValidateException(String.format("%s value must not contain duplicates - %s already present", scopeClaimName, scope));

            copy.add(scope);
        }

        return Collections.unmodifiableSet(copy);
    }
Validates that the scopes are valid, where <i>invalid</i> means <i>any</i> of
the following:

<ul>
    <li>Collection is <code>null</code></li>
    <li>Collection has duplicates</li>
    <li>Any of the elements in the collection are <code>null</code></li>
    <li>Any of the elements in the collection are zero length</li>
    <li>Any of the elements in the collection are whitespace only</li>
</ul>

@param scopeClaimName Name of the claim used for the scope values
@param scopes         Collection of String scopes

@return Unmodifiable {@link Set} that includes the values of the original set, but with
        each value trimmed

@throws ValidateException Thrown if the value is <code>null</code>, contains duplicates, or
                          if any of the values in the set are <code>null</code>, empty,
                          or whitespace only
clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/secured/ClaimValidationUtils.java