public Path parseUntrustedPath(String path) {
        Path parsedPath = Paths.get(path);

        if (allowedPaths != null) {
            Path normalisedPath = parsedPath.normalize();
            long allowed = allowedPaths.stream().filter(normalisedPath::startsWith).count();
            if (allowed == 0) {
                return null;
            }
            return normalisedPath;
        }

        return parsedPath;
    }
Checks if the given {@code path} resides in the configured {@code allowed.paths}.
If {@code allowed.paths} is not configured, the given Path is returned as allowed.
@param path the Path to check if allowed
@return Path that can be accessed or null if the given Path does not reside in the configured {@code allowed.paths}.
clients/src/main/java/org/apache/kafka/common/config/internals/AllowedPaths.java