• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java KeyProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.crypto.key.KeyProvider的典型用法代码示例。如果您正苦于以下问题:Java KeyProvider类的具体用法?Java KeyProvider怎么用?Java KeyProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KeyProvider类属于org.apache.hadoop.crypto.key包,在下文中一共展示了KeyProvider类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getKeysMetadata

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
@GET
@Path(KMSRESTConstants.KEYS_METADATA_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response getKeysMetadata(@QueryParam(KMSRESTConstants.KEY)
    List<String> keyNamesList) throws Exception {
  KMSWebApp.getAdminCallsMeter().mark();
  UserGroupInformation user = HttpUserGroupInformation.get();
  final String[] keyNames = keyNamesList.toArray(
      new String[keyNamesList.size()]);
  assertAccess(KMSACLs.Type.GET_METADATA, user, KMSOp.GET_KEYS_METADATA);

  KeyProvider.Metadata[] keysMeta = user.doAs(
      new PrivilegedExceptionAction<KeyProvider.Metadata[]>() {
        @Override
        public KeyProvider.Metadata[] run() throws Exception {
          return provider.getKeysMetadata(keyNames);
        }
      }
  );

  Object json = KMSServerJSONUtils.toJSON(keyNames, keysMeta);
  kmsAudit.ok(user, KMSOp.GET_KEYS_METADATA, "");
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(json).build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:25,代码来源:KMS.java


示例2: testLoadBalancing

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
@Test
public void testLoadBalancing() throws Exception {
  Configuration conf = new Configuration();
  KMSClientProvider p1 = mock(KMSClientProvider.class);
  when(p1.createKey(Mockito.anyString(), Mockito.any(Options.class)))
      .thenReturn(
          new KMSClientProvider.KMSKeyVersion("p1", "v1", new byte[0]));
  KMSClientProvider p2 = mock(KMSClientProvider.class);
  when(p2.createKey(Mockito.anyString(), Mockito.any(Options.class)))
      .thenReturn(
          new KMSClientProvider.KMSKeyVersion("p2", "v2", new byte[0]));
  KMSClientProvider p3 = mock(KMSClientProvider.class);
  when(p3.createKey(Mockito.anyString(), Mockito.any(Options.class)))
      .thenReturn(
          new KMSClientProvider.KMSKeyVersion("p3", "v3", new byte[0]));
  KeyProvider kp = new LoadBalancingKMSClientProvider(
      new KMSClientProvider[] { p1, p2, p3 }, 0, conf);
  assertEquals("p1", kp.createKey("test1", new Options(conf)).getName());
  assertEquals("p2", kp.createKey("test2", new Options(conf)).getName());
  assertEquals("p3", kp.createKey("test3", new Options(conf)).getName());
  assertEquals("p1", kp.createKey("test4", new Options(conf)).getName());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:23,代码来源:TestLoadBalancingKMSClientProvider.java


示例3: getMetadata

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
@GET
@Path(KMSRESTConstants.KEY_RESOURCE + "/{name:.*}/" +
    KMSRESTConstants.METADATA_SUB_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response getMetadata(@PathParam("name") final String name)
    throws Exception {
  UserGroupInformation user = HttpUserGroupInformation.get();
  KMSClientProvider.checkNotEmpty(name, "name");
  KMSWebApp.getAdminCallsMeter().mark();
  assertAccess(KMSACLs.Type.GET_METADATA, user, KMSOp.GET_METADATA, name);

  KeyProvider.Metadata metadata = user.doAs(
      new PrivilegedExceptionAction<KeyProvider.Metadata>() {
        @Override
        public KeyProvider.Metadata run() throws Exception {
          return provider.getMetadata(name);
        }
      }
  );

  Object json = KMSServerJSONUtils.toJSON(name, metadata);
  kmsAudit.ok(user, KMSOp.GET_METADATA, name, "");
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(json).build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:25,代码来源:KMS.java


示例4: toJSON

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Map toJSON(String keyName, KeyProvider.Metadata meta) {
  Map json = new LinkedHashMap();
  if (meta != null) {
    json.put(KMSRESTConstants.NAME_FIELD, keyName);
    json.put(KMSRESTConstants.CIPHER_FIELD, meta.getCipher());
    json.put(KMSRESTConstants.LENGTH_FIELD, meta.getBitLength());
    json.put(KMSRESTConstants.DESCRIPTION_FIELD, meta.getDescription());
    json.put(KMSRESTConstants.ATTRIBUTES_FIELD, meta.getAttributes());
    json.put(KMSRESTConstants.CREATED_FIELD,
        meta.getCreated().getTime());
    json.put(KMSRESTConstants.VERSIONS_FIELD,
        (long) meta.getVersions());
  }
  return json;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:KMSServerJSONUtils.java


示例5: decryptEncryptedDataEncryptionKey

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
/**
 * Decrypts a EDEK by consulting the KeyProvider.
 */
private KeyVersion decryptEncryptedDataEncryptionKey(FileEncryptionInfo
    feInfo) throws IOException {
  TraceScope scope = Trace.startSpan("decryptEDEK", traceSampler);
  try {
    KeyProvider provider = getKeyProvider();
    if (provider == null) {
      throw new IOException("No KeyProvider is configured, cannot access" +
          " an encrypted file");
    }
    EncryptedKeyVersion ekv = EncryptedKeyVersion.createForDecryption(
        feInfo.getKeyName(), feInfo.getEzKeyVersionName(), feInfo.getIV(),
        feInfo.getEncryptedDataEncryptionKey());
    try {
      KeyProviderCryptoExtension cryptoProvider = KeyProviderCryptoExtension
          .createKeyProviderCryptoExtension(provider);
      return cryptoProvider.decryptEncryptedKey(ekv);
    } catch (GeneralSecurityException e) {
      throw new IOException(e);
    }
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:DFSClient.java


示例6: KeyProviderCache

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
public KeyProviderCache(long expiryMs) {
  cache = CacheBuilder.newBuilder()
      .expireAfterAccess(expiryMs, TimeUnit.MILLISECONDS)
      .removalListener(new RemovalListener<URI, KeyProvider>() {
        @Override
        public void onRemoval(
            RemovalNotification<URI, KeyProvider> notification) {
          try {
            notification.getValue().close();
          } catch (Throwable e) {
            LOG.error(
                "Error closing KeyProvider with uri ["
                    + notification.getKey() + "]", e);
            ;
          }
        }
      })
      .build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:KeyProviderCache.java


示例7: get

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
public KeyProvider get(final Configuration conf) {
  URI kpURI = createKeyProviderURI(conf);
  if (kpURI == null) {
    return null;
  }
  try {
    return cache.get(kpURI, new Callable<KeyProvider>() {
      @Override
      public KeyProvider call() throws Exception {
        return DFSUtil.createKeyProvider(conf);
      }
    });
  } catch (Exception e) {
    LOG.error("Could not create KeyProvider for DFSClient !!", e.getCause());
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:KeyProviderCache.java


示例8: createProvider

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
private KeyProvider createProvider(URI providerUri, Configuration conf,
    URL origUrl, int port, String hostsPart) throws IOException {
  String[] hosts = hostsPart.split(";");
  if (hosts.length == 1) {
    return new KMSClientProvider(providerUri, conf);
  } else {
    KMSClientProvider[] providers = new KMSClientProvider[hosts.length];
    for (int i = 0; i < hosts.length; i++) {
      try {
        providers[i] =
            new KMSClientProvider(
                new URI("kms", origUrl.getProtocol(), hosts[i], port,
                    origUrl.getPath(), null, null), conf);
      } catch (URISyntaxException e) {
        throw new IOException("Could not instantiate KMSProvider..", e);
      }
    }
    return new LoadBalancingKMSClientProvider(providers, conf);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:KMSClientProvider.java


示例9: decryptEncryptedDataEncryptionKey

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
/**
 * Decrypts a EDEK by consulting the KeyProvider.
 */
private KeyVersion decryptEncryptedDataEncryptionKey(FileEncryptionInfo
    feInfo) throws IOException {
  try (TraceScope ignored = tracer.newScope("decryptEDEK")) {
    KeyProvider provider = getKeyProvider();
    if (provider == null) {
      throw new IOException("No KeyProvider is configured, cannot access" +
          " an encrypted file");
    }
    EncryptedKeyVersion ekv = EncryptedKeyVersion.createForDecryption(
        feInfo.getKeyName(), feInfo.getEzKeyVersionName(), feInfo.getIV(),
        feInfo.getEncryptedDataEncryptionKey());
    try {
      KeyProviderCryptoExtension cryptoProvider = KeyProviderCryptoExtension
          .createKeyProviderCryptoExtension(provider);
      return cryptoProvider.decryptEncryptedKey(ekv);
    } catch (GeneralSecurityException e) {
      throw new IOException(e);
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:DFSClient.java


示例10: get

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
public KeyProvider get(final Configuration conf) {
  URI kpURI = createKeyProviderURI(conf);
  if (kpURI == null) {
    return null;
  }
  try {
    return cache.get(kpURI, new Callable<KeyProvider>() {
      @Override
      public KeyProvider call() throws Exception {
        return DFSUtilClient.createKeyProvider(conf);
      }
    });
  } catch (Exception e) {
    LOG.error("Could not create KeyProvider for DFSClient !!", e.getCause());
    return null;
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:KeyProviderCache.java


示例11: decryptEncryptedDataEncryptionKey

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
/**
 * Decrypts a EDEK by consulting the KeyProvider.
 */
private KeyVersion decryptEncryptedDataEncryptionKey(FileEncryptionInfo
    feInfo) throws IOException {
  KeyProvider provider = getKeyProvider();
  if (provider == null) {
    throw new IOException("No KeyProvider is configured, cannot access" +
        " an encrypted file");
  }
  EncryptedKeyVersion ekv = EncryptedKeyVersion.createForDecryption(
      feInfo.getKeyName(), feInfo.getEzKeyVersionName(), feInfo.getIV(),
      feInfo.getEncryptedDataEncryptionKey());
  try {
    KeyProviderCryptoExtension cryptoProvider = KeyProviderCryptoExtension
        .createKeyProviderCryptoExtension(provider);
    return cryptoProvider.decryptEncryptedKey(ekv);
  } catch (GeneralSecurityException e) {
    throw new IOException(e);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:22,代码来源:DFSClient.java


示例12: renew

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
@Override
public long renew(Token<?> token, Configuration conf) throws IOException {
  LOG.debug("Renewing delegation token {}", token);
  KeyProvider keyProvider = KMSUtil.createKeyProvider(conf,
      KeyProviderFactory.KEY_PROVIDER_PATH);
  try {
    if (!(keyProvider instanceof
        KeyProviderDelegationTokenExtension.DelegationTokenExtension)) {
      LOG.warn("keyProvider {} cannot renew dt.", keyProvider == null ?
          "null" : keyProvider.getClass());
      return 0;
    }
    return ((KeyProviderDelegationTokenExtension.DelegationTokenExtension)
        keyProvider).renewDelegationToken(token);
  } finally {
    if (keyProvider != null) {
      keyProvider.close();
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:KMSClientProvider.java


示例13: cancel

import org.apache.hadoop.crypto.key.KeyProvider; //导入依赖的package包/类
@Override
public void cancel(Token<?> token, Configuration conf) throws IOException {
  LOG.debug("Canceling delegation token {}", token);
  KeyProvider keyProvider = KMSUtil.createKeyProvider(conf,
      KeyProviderFactory.KEY_PROVIDER_PATH);
  try {
    if (!(keyProvider instanceof
        KeyProviderDelegationTokenExtension.DelegationTokenExtension)) {
      LOG.warn("keyProvider {} cannot cancel dt.", keyProvider == null ?
          "null" : keyProvider.getClass());
      return;
    }
    ((KeyProviderDelegationTokenExtension.DelegationTokenExtension)
        keyProvider).cancelDelegationToken(token);
  } finally {
    if (keyProvider != null) {
      keyProvider.close();
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:KMSClientProvider.java



注:本文中的org.apache.hadoop.crypto.key.KeyProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextDecorator类代码示例发布时间:2022-05-22
下一篇:
Java ThisExpr类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap