@Test @SuppressWarnings("deprecation") public void testBinaryCredentials() throws Exception { String binaryTokenFile = null; try { Path TEST_ROOT_DIR = new Path("target"); binaryTokenFile = FileSystem.getLocal(conf).makeQualified( new Path(TEST_ROOT_DIR, "tokenFile")).toUri().getPath(); MockFileSystem fs1 = createFileSystemForServiceName("service1"); MockFileSystem fs2 = createFileSystemForServiceName("service2"); MockFileSystem fs3 = createFileSystemForServiceName("service3"); Credentials creds = new Credentials(); Token<?> token1 = fs1.getDelegationToken(renewer); Token<?> token2 = fs2.getDelegationToken(renewer); creds.addToken(token1.getService(), token1); creds.addToken(token2.getService(), token2); creds.writeTokenStorageFile(new Path(binaryTokenFile), conf); Credentials newCreds = new Credentials(); TokenCache.mergeBinaryTokens(newCreds, conf, binaryTokenFile); Assert.assertTrue(newCreds.getAllTokens().size() > 0); checkTokens(creds, newCreds); } finally { if (binaryTokenFile != null) { try { FileSystem.getLocal(conf).delete(new Path(binaryTokenFile)); } catch (IOException e) { } } } }
@InterfaceAudience.Private public static void mergeBinaryTokens(Credentials creds, Configuration conf, String tokenFilePath) throws IOException { if (tokenFilePath == null || tokenFilePath.isEmpty()) { throw new RuntimeException("Invalid file path provided" + ", tokenFilePath=" + tokenFilePath); } LOG.info("Merging additional tokens from binary file" + ", binaryFileName=" + tokenFilePath); Credentials binary = Credentials.readTokenStorageFile( new Path("file: creds.mergeAll(binary); }
TokenCache { @InterfaceAudience.Private public static void mergeBinaryTokens(Credentials creds, Configuration conf, String tokenFilePath) throws IOException { if (tokenFilePath == null || tokenFilePath.isEmpty()) { throw new RuntimeException("Invalid file path provided" + ", tokenFilePath=" + tokenFilePath); } LOG.info("Merging additional tokens from binary file" + ", binaryFileName=" + tokenFilePath); Credentials binary = Credentials.readTokenStorageFile( new Path("file: creds.mergeAll(binary); } }
TokenCache { @InterfaceAudience.Private public static void mergeBinaryTokens(Credentials creds, Configuration conf, String tokenFilePath) throws IOException { if (tokenFilePath == null || tokenFilePath.isEmpty()) { throw new RuntimeException("Invalid file path provided" + ", tokenFilePath=" + tokenFilePath); } LOG.info("Merging additional tokens from binary file" + ", binaryFileName=" + tokenFilePath); Credentials binary = Credentials.readTokenStorageFile( new Path("file: creds.mergeAll(binary); }  }
TokenCache { @InterfaceAudience.Private public static void mergeBinaryTokens(Credentials creds, Configuration conf, String tokenFilePath) throws IOException { if (tokenFilePath == null || tokenFilePath.isEmpty()) { throw new RuntimeException("Invalid file path provided" + ", tokenFilePath=" + tokenFilePath); } LOG.info("Merging additional tokens from binary file" + ", binaryFileName=" + tokenFilePath); Credentials binary = Credentials.readTokenStorageFile( new Path("file: creds.mergeAll(binary); }  static byte[] getSecretKey(Credentials credentials, Text alias); static void obtainTokensForFileSystems(Credentials credentials,
      Path[] ps, Configuration conf); @InterfaceAudience.Private static void setSessionToken(Token<? extends TokenIdentifier> t, 
      Credentials credentials); @SuppressWarnings("unchecked") @InterfaceAudience.Private static Token<JobTokenIdentifier> getSessionToken(Credentials credentials); @InterfaceAudience.Private static void mergeBinaryTokens(Credentials creds,
      Configuration conf, String tokenFilePath); }
TokenCache { @InterfaceAudience.Private public static void mergeBinaryTokens(Credentials creds, Configuration conf, String tokenFilePath) throws IOException { if (tokenFilePath == null || tokenFilePath.isEmpty()) { throw new RuntimeException("Invalid file path provided" + ", tokenFilePath=" + tokenFilePath); } LOG.info("Merging additional tokens from binary file" + ", binaryFileName=" + tokenFilePath); Credentials binary = Credentials.readTokenStorageFile( new Path("file: creds.mergeAll(binary); }  static byte[] getSecretKey(Credentials credentials, Text alias); static void obtainTokensForFileSystems(Credentials credentials,
      Path[] ps, Configuration conf); @InterfaceAudience.Private static void setSessionToken(Token<? extends TokenIdentifier> t, 
      Credentials credentials); @SuppressWarnings("unchecked") @InterfaceAudience.Private static Token<JobTokenIdentifier> getSessionToken(Credentials credentials); @InterfaceAudience.Private static void mergeBinaryTokens(Credentials creds,
      Configuration conf, String tokenFilePath);  }