ClientDistributedCacheManager { public static void determineCacheVisibilities(Configuration job, Map<URI, FileStatus> statCache) throws IOException { URI[] tarchives = DistributedCache.getCacheArchives(job); if (tarchives != null) { StringBuilder archiveVisibilities = new StringBuilder(String.valueOf(isPublic(job, tarchives[0], statCache))); for (int i = 1; i < tarchives.length; i++) { archiveVisibilities.append(","); archiveVisibilities.append(String.valueOf(isPublic(job, tarchives[i], statCache))); } setArchiveVisibilities(job, archiveVisibilities.toString()); } URI[] tfiles = DistributedCache.getCacheFiles(job); if (tfiles != null) { StringBuilder fileVisibilities = new StringBuilder(String.valueOf(isPublic(job, tfiles[0], statCache))); for (int i = 1; i < tfiles.length; i++) { fileVisibilities.append(","); fileVisibilities.append(String.valueOf(isPublic(job, tfiles[i], statCache))); } setFileVisibilities(job, fileVisibilities.toString()); } }  static void determineTimestampsAndCacheVisibilities(Configuration job); static void determineTimestampsAndCacheVisibilities(Configuration job,
      Map<URI, FileStatus> statCache); static void determineTimestamps(Configuration job,
      Map<URI, FileStatus> statCache); static void getDelegationTokens(Configuration job,
      Credentials credentials); static void determineCacheVisibilities(Configuration job,
      Map<URI, FileStatus> statCache);  }
@Test public void testDetermineCacheVisibilities() throws IOException { fs.setPermission(TEST_VISIBILITY_PARENT_DIR, new FsPermission((short)00777)); fs.setPermission(TEST_VISIBILITY_CHILD_DIR, new FsPermission((short)00777)); fs.setWorkingDirectory(TEST_VISIBILITY_CHILD_DIR); Job job = Job.getInstance(conf); Path relativePath = new Path(SECOND_CACHE_FILE); Path wildcardPath = new Path("*"); Map<URI, FileStatus> statCache = new HashMap<>(); Configuration jobConf; job.addCacheFile(firstCacheFile.toUri()); job.addCacheFile(relativePath.toUri()); jobConf = job.getConfiguration(); assumeTrue(TEST_VISIBILITY_PARENT_DIR + " is not public", ClientDistributedCacheManager.isPublic( jobConf, TEST_VISIBILITY_PARENT_DIR.toUri(), statCache)); ClientDistributedCacheManager.determineCacheVisibilities(jobConf, statCache); assertEquals("The file paths were not found to be publicly visible " + "even though the full path is publicly accessible", "true,true", jobConf.get(MRJobConfig.CACHE_FILE_VISIBILITIES)); checkCacheEntries(statCache, null, firstCacheFile, relativePath); job = Job.getInstance(conf); job.addCacheFile(wildcardPath.toUri()); jobConf = job.getConfiguration(); statCache.clear(); ClientDistributedCacheManager.determineCacheVisibilities(jobConf, statCache); assertEquals("The file path was not found to be publicly visible " + "even though the full path is publicly accessible", "true", jobConf.get(MRJobConfig.CACHE_FILE_VISIBILITIES)); checkCacheEntries(statCache, null, wildcardPath.getParent()); Path qualifiedParent = fs.makeQualified(TEST_VISIBILITY_PARENT_DIR); fs.setPermission(TEST_VISIBILITY_PARENT_DIR, new FsPermission((short)00700)); job = Job.getInstance(conf); job.addCacheFile(firstCacheFile.toUri()); job.addCacheFile(relativePath.toUri()); jobConf = job.getConfiguration(); statCache.clear(); ClientDistributedCacheManager.determineCacheVisibilities(jobConf, statCache); assertEquals("The file paths were found to be publicly visible " + "even though the parent directory is not publicly accessible", "false,false", jobConf.get(MRJobConfig.CACHE_FILE_VISIBILITIES)); checkCacheEntries(statCache, qualifiedParent, firstCacheFile, relativePath); job = Job.getInstance(conf); job.addCacheFile(wildcardPath.toUri()); jobConf = job.getConfiguration(); statCache.clear(); ClientDistributedCacheManager.determineCacheVisibilities(jobConf, statCache); assertEquals("The file path was found to be publicly visible " + "even though the parent directory is not publicly accessible", "false", jobConf.get(MRJobConfig.CACHE_FILE_VISIBILITIES)); checkCacheEntries(statCache, qualifiedParent, wildcardPath.getParent()); }