KMSClientProvider extends KeyProvider implements CryptoExtension,
    KeyProviderDelegationTokenExtension.DelegationTokenExtension { @InterfaceAudience.Private @Override public Token<?> selectDelegationToken(Credentials creds) { Token<?> token = selectDelegationToken(creds, dtService); if (token == null) { token = selectDelegationToken(creds, canonicalService); } return token; } KMSClientProvider(URI uri, Configuration conf); @Override String toString(); @Override KeyVersion getKeyVersion(String versionName); @Override KeyVersion getCurrentKey(String name); @Override @SuppressWarnings("unchecked") List<String> getKeys(); @Override @SuppressWarnings("unchecked") Metadata[] getKeysMetadata(String ... keyNames); @Override KeyVersion createKey(String name, Options options); @Override KeyVersion createKey(String name, byte[] material, Options options); @Override void invalidateCache(String name); @Override KeyVersion rollNewVersion(String name); @Override KeyVersion rollNewVersion(String name, byte[] material); @Override EncryptedKeyVersion generateEncryptedKey(
      String encryptionKeyName); @SuppressWarnings("rawtypes") @Override KeyVersion decryptEncryptedKey(
      EncryptedKeyVersion encryptedKeyVersion); @Override EncryptedKeyVersion reencryptEncryptedKey(EncryptedKeyVersion ekv); @Override void reencryptEncryptedKeys(List<EncryptedKeyVersion> ekvs); @Override List<KeyVersion> getKeyVersions(String name); @Override Metadata getMetadata(String name); @Override void deleteKey(String name); @Override void flush(); @Override void warmUpEncryptedKeys(String... keyNames); @Override void drain(String keyName); @VisibleForTesting int getEncKeyQueueSize(String keyName); @InterfaceAudience.Private @Override Token<?> selectDelegationToken(Credentials creds); @Override String getCanonicalServiceName(); @Override Token<?> getDelegationToken(final String renewer); @Override long renewDelegationToken(final Token<?> dToken); @Override Void cancelDelegationToken(final Token<?> dToken); @Override void close(); static final String TOKEN_KIND_STR; static final Text TOKEN_KIND; static final String SCHEME_NAME; static final String AUTH_RETRY; static final int DEFAULT_AUTH_RETRY; }
@Test public void testSelectDelegationToken() throws Exception { final Credentials creds = new Credentials(); creds.addToken(new Text(providerUriString), token); assertNull(KMSClientProvider.selectDelegationToken(creds, null)); assertNull(KMSClientProvider .selectDelegationToken(creds, new Text(oldTokenService))); assertEquals(token, KMSClientProvider .selectDelegationToken(creds, new Text(providerUriString))); }