当前位置: 首页>>代码示例>>Java>>正文


Java KeyProvider.Metadata方法代码示例

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


在下文中一共展示了KeyProvider.Metadata方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: createEncryptionZone

import org.apache.hadoop.crypto.key.KeyProvider; //导入方法依赖的package包/类
/**
 * Create an encryption zone on directory src using the specified key.
 *
 * @param src     the path of a directory which will be the root of the
 *                encryption zone. The directory must be empty.
 * @param keyName name of a key which must be present in the configured
 *                KeyProvider.
 * @throws AccessControlException  if the caller is not the superuser.
 * @throws UnresolvedLinkException if the path can't be resolved.
 * @throws SafeModeException       if the Namenode is in safe mode.
 */
void createEncryptionZone(final String src, final String keyName,
                          boolean logRetryCache)
  throws IOException, UnresolvedLinkException,
    SafeModeException, AccessControlException {
  try {
    if (provider == null) {
      throw new IOException(
          "Can't create an encryption zone for " + src +
          " since no key provider is available.");
    }
    if (keyName == null || keyName.isEmpty()) {
      throw new IOException("Must specify a key name when creating an " +
          "encryption zone");
    }
    KeyProvider.Metadata metadata = provider.getMetadata(keyName);
    if (metadata == null) {
      /*
       * It would be nice if we threw something more specific than
       * IOException when the key is not found, but the KeyProvider API
       * doesn't provide for that. If that API is ever changed to throw
       * something more specific (e.g. UnknownKeyException) then we can
       * update this to match it, or better yet, just rethrow the
       * KeyProvider's exception.
       */
      throw new IOException("Key " + keyName + " doesn't exist.");
    }
    // If the provider supports pool for EDEKs, this will fill in the pool
    generateEncryptedDataEncryptionKey(keyName);
    createEncryptionZoneInt(src, metadata.getCipher(),
        keyName, logRetryCache);
  } catch (AccessControlException e) {
    logAuditEvent(false, "createEncryptionZone", src);
    throw e;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:FSNamesystem.java

示例5: ensureKeyIsInitialized

import org.apache.hadoop.crypto.key.KeyProvider; //导入方法依赖的package包/类
static KeyProvider.Metadata ensureKeyIsInitialized(final FSDirectory fsd,
    final String keyName, final String src) throws IOException {
  KeyProviderCryptoExtension provider = fsd.getProvider();
  if (provider == null) {
    throw new IOException("Can't create an encryption zone for " + src
        + " since no key provider is available.");
  }
  if (keyName == null || keyName.isEmpty()) {
    throw new IOException("Must specify a key name when creating an "
        + "encryption zone");
  }
  KeyProvider.Metadata metadata = provider.getMetadata(keyName);
  if (metadata == null) {
    /*
     * It would be nice if we threw something more specific than
     * IOException when the key is not found, but the KeyProvider API
     * doesn't provide for that. If that API is ever changed to throw
     * something more specific (e.g. UnknownKeyException) then we can
     * update this to match it, or better yet, just rethrow the
     * KeyProvider's exception.
     */
    throw new IOException("Key " + keyName + " doesn't exist.");
  }
  // If the provider supports pool for EDEKs, this will fill in the pool
  provider.warmUpEncryptedKeys(keyName);
  return metadata;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:28,代码来源:FSDirEncryptionZoneOp.java

示例6: 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 {
  try {
    LOG.trace("Entering getKeysMetadata method.");
    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, "");
    LOG.trace("Exiting getKeysMetadata method.");
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(json)
            .build();
  } catch (Exception e) {
    LOG.debug("Exception in getKeysmetadata.", e);
    throw e;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:33,代码来源:KMS.java

示例7: 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 {
  try {
    LOG.trace("Entering getMetadata method.");
    UserGroupInformation user = HttpUserGroupInformation.get();
    KMSClientProvider.checkNotEmpty(name, "name");
    KMSWebApp.getAdminCallsMeter().mark();
    assertAccess(KMSACLs.Type.GET_METADATA, user, KMSOp.GET_METADATA, name);
    LOG.debug("Getting metadata for key with name {}.", 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, "");
    LOG.trace("Exiting getMetadata method.");
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(json)
            .build();
  } catch (Exception e) {
    LOG.debug("Exception in getMetadata.", e);
    throw e;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:34,代码来源:KMS.java

示例8: createEncryptionZone

import org.apache.hadoop.crypto.key.KeyProvider; //导入方法依赖的package包/类
/**
 * Create an encryption zone on directory src using the specified key.
 *
 * @param src     the path of a directory which will be the root of the
 *                encryption zone. The directory must be empty.
 * @param keyName name of a key which must be present in the configured
 *                KeyProvider.
 * @throws AccessControlException  if the caller is not the superuser.
 * @throws UnresolvedLinkException if the path can't be resolved.
 * @throws SafeModeException       if the Namenode is in safe mode.
 */
void createEncryptionZone(final String src, final String keyName)
  throws IOException, UnresolvedLinkException,
    SafeModeException, AccessControlException {
  final CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache);
  if (cacheEntry != null && cacheEntry.isSuccess()) {
    return; // Return previous response
  }

  boolean success = false;
  try {
    if (provider == null) {
      throw new IOException(
          "Can't create an encryption zone for " + src +
          " since no key provider is available.");
    }
    if (keyName == null || keyName.isEmpty()) {
      throw new IOException("Must specify a key name when creating an " +
          "encryption zone");
    }
    KeyProvider.Metadata metadata = provider.getMetadata(keyName);
    if (metadata == null) {
      /*
       * It would be nice if we threw something more specific than
       * IOException when the key is not found, but the KeyProvider API
       * doesn't provide for that. If that API is ever changed to throw
       * something more specific (e.g. UnknownKeyException) then we can
       * update this to match it, or better yet, just rethrow the
       * KeyProvider's exception.
       */
      throw new IOException("Key " + keyName + " doesn't exist.");
    }
    // If the provider supports pool for EDEKs, this will fill in the pool
    generateEncryptedDataEncryptionKey(keyName);
    createEncryptionZoneInt(src, metadata.getCipher(),
        keyName, cacheEntry != null);
    success = true;
  } catch (AccessControlException e) {
    logAuditEvent(false, "createEncryptionZone", src);
    throw e;
  } finally {
    RetryCache.setState(cacheEntry, success);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:55,代码来源:FSNamesystem.java

示例9: createEncryptionZone

import org.apache.hadoop.crypto.key.KeyProvider; //导入方法依赖的package包/类
/**
 * Create an encryption zone on directory src using the specified key.
 *
 * @param src     the path of a directory which will be the root of the
 *                encryption zone. The directory must be empty.
 * @param keyName name of a key which must be present in the configured
 *                KeyProvider.
 * @throws AccessControlException  if the caller is not the superuser.
 * @throws UnresolvedLinkException if the path can't be resolved.
 * @throws SafeModeException       if the Namenode is in safe mode.
 */
void createEncryptionZone(final String src, final String keyName)
  throws IOException, UnresolvedLinkException,
    SafeModeException, AccessControlException {
  final CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache);
  if (cacheEntry != null && cacheEntry.isSuccess()) {
    return; // Return previous response
  }

  boolean success = false;
  try {
    if (provider == null) {
      throw new IOException(
          "Can't create an encryption zone for " + src +
          " since no key provider is available.");
    }
    if (keyName == null || keyName.isEmpty()) {
      throw new IOException("Must specify a key name when creating an " +
          "encryption zone");
    }
    KeyProvider.Metadata metadata = provider.getMetadata(keyName);
    if (metadata == null) {
      /*
       * It would be nice if we threw something more specific than
       * IOException when the key is not found, but the KeyProvider API
       * doesn't provide for that. If that API is ever changed to throw
       * something more specific (e.g. UnknownKeyException) then we can
       * update this to match it, or better yet, just rethrow the
       * KeyProvider's exception.
       */
      throw new IOException("Key " + keyName + " doesn't exist.");
    }
    createEncryptionZoneInt(src, metadata.getCipher(),
        keyName, cacheEntry != null);
    success = true;
  } catch (AccessControlException e) {
    logAuditEvent(false, "createEncryptionZone", src);
    throw e;
  } finally {
    RetryCache.setState(cacheEntry, success);
  }
}
 
开发者ID:yncxcw,项目名称:FlexMap,代码行数:53,代码来源:FSNamesystem.java


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