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


Java KMSRESTConstants.KEY_VERSION_RESOURCE属性代码示例

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


在下文中一共展示了KMSRESTConstants.KEY_VERSION_RESOURCE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeyVersion

@GET
@Path(KMSRESTConstants.KEY_VERSION_RESOURCE + "/{versionName:.*}")
@Produces(MediaType.APPLICATION_JSON)
public Response getKeyVersion(
    @PathParam("versionName") final String versionName) throws Exception {
  UserGroupInformation user = HttpUserGroupInformation.get();
  KMSClientProvider.checkNotEmpty(versionName, "versionName");
  KMSWebApp.getKeyCallsMeter().mark();
  assertAccess(KMSACLs.Type.GET, user, KMSOp.GET_KEY_VERSION);

  KeyVersion keyVersion = user.doAs(
      new PrivilegedExceptionAction<KeyVersion>() {
        @Override
        public KeyVersion run() throws Exception {
          return provider.getKeyVersion(versionName);
        }
      }
  );

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

示例2: getKeyVersion

@GET
@Path(KMSRESTConstants.KEY_VERSION_RESOURCE + "/{versionName:.*}")
@Produces(MediaType.APPLICATION_JSON)
public Response getKeyVersion(
    @PathParam("versionName") final String versionName) throws Exception {
  try {
    LOG.trace("Entering getKeyVersion method.");
    UserGroupInformation user = HttpUserGroupInformation.get();
    KMSClientProvider.checkNotEmpty(versionName, "versionName");
    KMSWebApp.getKeyCallsMeter().mark();
    assertAccess(KMSACLs.Type.GET, user, KMSOp.GET_KEY_VERSION);
    LOG.debug("Getting key with version name {}.", versionName);

    KeyVersion keyVersion = user.doAs(
            new PrivilegedExceptionAction<KeyVersion>() {
            @Override
              public KeyVersion run() throws Exception {
              return provider.getKeyVersion(versionName);
            }
          }
    );

    if (keyVersion != null) {
      kmsAudit.ok(user, KMSOp.GET_KEY_VERSION, keyVersion.getName(), "");
    }
    Object json = KMSServerJSONUtils.toJSON(keyVersion);
    LOG.trace("Exiting getKeyVersion method.");
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(json)
            .build();
  } catch (Exception e) {
    LOG.debug("Exception in getKeyVersion.", e);
    throw e;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:34,代码来源:KMS.java

示例3: decryptEncryptedKey

@SuppressWarnings("rawtypes")
@POST
@Path(KMSRESTConstants.KEY_VERSION_RESOURCE + "/{versionName:.*}/" +
    KMSRESTConstants.EEK_SUB_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response decryptEncryptedKey(
    @PathParam("versionName") final String versionName,
    @QueryParam(KMSRESTConstants.EEK_OP) String eekOp,
    Map jsonPayload)
    throws Exception {
  UserGroupInformation user = HttpUserGroupInformation.get();
  KMSClientProvider.checkNotEmpty(versionName, "versionName");
  KMSClientProvider.checkNotNull(eekOp, "eekOp");

  final String keyName = (String) jsonPayload.get(
      KMSRESTConstants.NAME_FIELD);
  String ivStr = (String) jsonPayload.get(KMSRESTConstants.IV_FIELD);
  String encMaterialStr = 
      (String) jsonPayload.get(KMSRESTConstants.MATERIAL_FIELD);
  Object retJSON;
  if (eekOp.equals(KMSRESTConstants.EEK_DECRYPT)) {
    assertAccess(KMSACLs.Type.DECRYPT_EEK, user, KMSOp.DECRYPT_EEK, keyName);
    KMSClientProvider.checkNotNull(ivStr, KMSRESTConstants.IV_FIELD);
    final byte[] iv = Base64.decodeBase64(ivStr);
    KMSClientProvider.checkNotNull(encMaterialStr,
        KMSRESTConstants.MATERIAL_FIELD);
    final byte[] encMaterial = Base64.decodeBase64(encMaterialStr);

    KeyProvider.KeyVersion retKeyVersion = user.doAs(
        new PrivilegedExceptionAction<KeyVersion>() {
          @Override
          public KeyVersion run() throws Exception {
            return provider.decryptEncryptedKey(
                new KMSClientProvider.KMSEncryptedKeyVersion(keyName,
                    versionName, iv, KeyProviderCryptoExtension.EEK,
                    encMaterial)
            );
          }
        }
    );

    retJSON = KMSServerJSONUtils.toJSON(retKeyVersion);
    kmsAudit.ok(user, KMSOp.DECRYPT_EEK, keyName, "");
  } else {
    throw new IllegalArgumentException("Wrong " + KMSRESTConstants.EEK_OP +
        " value, it must be " + KMSRESTConstants.EEK_GENERATE + " or " +
        KMSRESTConstants.EEK_DECRYPT);
  }
  KMSWebApp.getDecryptEEKCallsMeter().mark();
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(retJSON)
      .build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:52,代码来源:KMS.java

示例4: decryptEncryptedKey

@SuppressWarnings("rawtypes")
@POST
@Path(KMSRESTConstants.KEY_VERSION_RESOURCE + "/{versionName:.*}/" +
    KMSRESTConstants.EEK_SUB_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response decryptEncryptedKey(
    @PathParam("versionName") final String versionName,
    @QueryParam(KMSRESTConstants.EEK_OP) String eekOp,
    Map jsonPayload)
    throws Exception {
  try {
    LOG.trace("Entering decryptEncryptedKey method.");
    UserGroupInformation user = HttpUserGroupInformation.get();
    KMSClientProvider.checkNotEmpty(versionName, "versionName");
    KMSClientProvider.checkNotNull(eekOp, "eekOp");
    LOG.debug("Decrypting key for {}, the edek Operation is {}.",
            versionName, eekOp);

    final String keyName = (String) jsonPayload.get(
            KMSRESTConstants.NAME_FIELD);
    String ivStr = (String) jsonPayload.get(KMSRESTConstants.IV_FIELD);
    String encMaterialStr =
            (String) jsonPayload.get(KMSRESTConstants.MATERIAL_FIELD);
    Object retJSON;
    if (eekOp.equals(KMSRESTConstants.EEK_DECRYPT)) {
      assertAccess(KMSACLs.Type.DECRYPT_EEK, user, KMSOp.DECRYPT_EEK,
              keyName);
      KMSClientProvider.checkNotNull(ivStr, KMSRESTConstants.IV_FIELD);
      final byte[] iv = Base64.decodeBase64(ivStr);
      KMSClientProvider.checkNotNull(encMaterialStr,
              KMSRESTConstants.MATERIAL_FIELD);
      final byte[] encMaterial = Base64.decodeBase64(encMaterialStr);

      KeyProvider.KeyVersion retKeyVersion = user.doAs(
              new PrivilegedExceptionAction<KeyVersion>() {
              @Override
                public KeyVersion run() throws Exception {
                return provider.decryptEncryptedKey(
                          new KMSClientProvider.KMSEncryptedKeyVersion(
                                  keyName, versionName, iv,
                                          KeyProviderCryptoExtension.EEK,
                                          encMaterial)
                  );
              }
            }
      );

      retJSON = KMSServerJSONUtils.toJSON(retKeyVersion);
      kmsAudit.ok(user, KMSOp.DECRYPT_EEK, keyName, "");
    } else {
      StringBuilder error;
      error = new StringBuilder("IllegalArgumentException Wrong ");
      error.append(KMSRESTConstants.EEK_OP);
      error.append(" value, it must be ");
      error.append(KMSRESTConstants.EEK_GENERATE);
      error.append(" or ");
      error.append(KMSRESTConstants.EEK_DECRYPT);
      LOG.error(error.toString());
      throw new IllegalArgumentException(error.toString());
    }
    KMSWebApp.getDecryptEEKCallsMeter().mark();
    LOG.trace("Exiting decryptEncryptedKey method.");
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(retJSON)
            .build();
  } catch (Exception e) {
    LOG.debug("Exception in decryptEncryptedKey.", e);
    throw e;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:69,代码来源:KMS.java


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