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


Java CipherSuite类代码示例

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


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

示例1: FileEncryptionInfo

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
/**
 * Create a FileEncryptionInfo.
 *
 * @param suite CipherSuite used to encrypt the file
 * @param edek encrypted data encryption key (EDEK) of the file
 * @param iv initialization vector (IV) used to encrypt the file
 * @param keyName name of the key used for the encryption zone
 * @param ezKeyVersionName name of the KeyVersion used to encrypt the
 *                         encrypted data encryption key.
 */
public FileEncryptionInfo(final CipherSuite suite,
    final CryptoProtocolVersion version, final byte[] edek,
    final byte[] iv, final String keyName, final String ezKeyVersionName) {
  checkNotNull(suite);
  checkNotNull(version);
  checkNotNull(edek);
  checkNotNull(iv);
  checkNotNull(keyName);
  checkNotNull(ezKeyVersionName);
  checkArgument(iv.length == suite.getAlgorithmBlockSize(),
      "Unexpected IV length");
  this.cipherSuite = suite;
  this.version = version;
  this.edek = edek;
  this.iv = iv;
  this.keyName = keyName;
  this.ezKeyVersionName = ezKeyVersionName;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:29,代码来源:FileEncryptionInfo.java

示例2: getCryptoCodec

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
/**
 * Obtain a CryptoCodec based on the CipherSuite set in a FileEncryptionInfo
 * and the available CryptoCodecs configured in the Configuration.
 *
 * @param conf   Configuration
 * @param feInfo FileEncryptionInfo
 * @return CryptoCodec
 * @throws IOException if no suitable CryptoCodec for the CipherSuite is
 *                     available.
 */
private static CryptoCodec getCryptoCodec(Configuration conf,
    FileEncryptionInfo feInfo) throws IOException {
  final CipherSuite suite = feInfo.getCipherSuite();
  if (suite.equals(CipherSuite.UNKNOWN)) {
    throw new IOException("NameNode specified unknown CipherSuite with ID "
        + suite.getUnknownValue() + ", cannot instantiate CryptoCodec.");
  }
  final CryptoCodec codec = CryptoCodec.getInstance(conf, suite);
  if (codec == null) {
    throw new UnknownCipherSuiteException(
        "No configuration found for the cipher suite "
        + suite.getConfigSuffix() + " prefixed with "
        + HADOOP_SECURITY_CRYPTO_CODEC_CLASSES_KEY_PREFIX
        + ". Please see the example configuration "
        + "hadoop.security.crypto.codec.classes.EXAMPLECIPHERSUITE "
        + "at core-default.xml for details.");
  }
  return codec;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:DFSClient.java

示例3: convert

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
public static CipherOption convert(CipherOptionProto proto) {
  if (proto != null) {
    CipherSuite suite = null;
    if (proto.getSuite() != null) {
      suite = convert(proto.getSuite());
    }
    byte[] inKey = null;
    if (proto.getInKey() != null) {
      inKey = proto.getInKey().toByteArray();
    }
    byte[] inIv = null;
    if (proto.getInIv() != null) {
      inIv = proto.getInIv().toByteArray();
    }
    byte[] outKey = null;
    if (proto.getOutKey() != null) {
      outKey = proto.getOutKey().toByteArray();
    }
    byte[] outIv = null;
    if (proto.getOutIv() != null) {
      outIv = proto.getOutIv().toByteArray();
    }
    return new CipherOption(suite, inKey, inIv, outKey, outIv);
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:PBHelper.java

示例4: mockCreate

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void mockCreate(ClientProtocol mcp,
    CipherSuite suite, CryptoProtocolVersion version) throws Exception {
  Mockito.doReturn(
      new HdfsFileStatus(0, false, 1, 1024, 0, 0, new FsPermission(
          (short) 777), "owner", "group", new byte[0], new byte[0],
          1010, 0, new FileEncryptionInfo(suite,
          version, new byte[suite.getAlgorithmBlockSize()],
          new byte[suite.getAlgorithmBlockSize()],
          "fakeKey", "fakeVersion"),
          (byte) 0))
      .when(mcp)
      .create(anyString(), (FsPermission) anyObject(), anyString(),
          (EnumSetWritable<CreateFlag>) anyObject(), anyBoolean(),
          anyShort(), anyLong(), (CryptoProtocolVersion[]) anyObject());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestEncryptionZones.java

示例5: getCryptoCodec

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
/**
 * Obtain a CryptoCodec based on the CipherSuite set in a FileEncryptionInfo
 * and the available CryptoCodecs configured in the Configuration.
 *
 * @param conf   Configuration
 * @param feInfo FileEncryptionInfo
 * @return CryptoCodec
 * @throws IOException if no suitable CryptoCodec for the CipherSuite is
 *                     available.
 */
private static CryptoCodec getCryptoCodec(Configuration conf,
    FileEncryptionInfo feInfo) throws IOException {
  final CipherSuite suite = feInfo.getCipherSuite();
  if (suite.equals(CipherSuite.UNKNOWN)) {
    throw new IOException("NameNode specified unknown CipherSuite with ID "
        + suite.getUnknownValue() + ", cannot instantiate CryptoCodec.");
  }
  final CryptoCodec codec = CryptoCodec.getInstance(conf, suite);
  if (codec == null) {
    throw new UnknownCipherSuiteException(
        "No configuration found for the cipher suite "
            + suite.getConfigSuffix() + " prefixed with "
            + HADOOP_SECURITY_CRYPTO_CODEC_CLASSES_KEY_PREFIX
            + ". Please see the example configuration "
            + "hadoop.security.crypto.codec.classes.EXAMPLECIPHERSUITE "
            + "at core-default.xml for details.");
  }
  return codec;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:30,代码来源:DFSClient.java

示例6: convert

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
public static CipherOption convert(HdfsProtos.CipherOptionProto proto) {
  if (proto != null) {
    CipherSuite suite = null;
    if (proto.getSuite() != null) {
      suite = convert(proto.getSuite());
    }
    byte[] inKey = null;
    if (proto.getInKey() != null) {
      inKey = proto.getInKey().toByteArray();
    }
    byte[] inIv = null;
    if (proto.getInIv() != null) {
      inIv = proto.getInIv().toByteArray();
    }
    byte[] outKey = null;
    if (proto.getOutKey() != null) {
      outKey = proto.getOutKey().toByteArray();
    }
    byte[] outIv = null;
    if (proto.getOutIv() != null) {
      outIv = proto.getOutIv().toByteArray();
    }
    return new CipherOption(suite, inKey, inIv, outKey, outIv);
  }
  return null;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:PBHelperClient.java

示例7: createEncryptionZone

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
/**
 * Create an encryption zone on directory path using the specified key.
 *
 * @param fsd fsdirectory
 * @param srcArg the path of a directory which will be the root of the
 *               encryption zone. The directory must be empty
 * @param pc permission checker to check fs permission
 * @param cipher cipher
 * @param keyName name of a key which must be present in the configured
 *                KeyProvider
 * @param logRetryCache whether to record RPC ids in editlog for retry cache
 *                      rebuilding
 * @return HdfsFileStatus
 * @throws IOException
 */
static HdfsFileStatus createEncryptionZone(final FSDirectory fsd,
    final String srcArg, final FSPermissionChecker pc, final String cipher,
    final String keyName, final boolean logRetryCache) throws IOException {
  final byte[][] pathComponents = FSDirectory
      .getPathComponentsForReservedPath(srcArg);
  final CipherSuite suite = CipherSuite.convert(cipher);
  List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
  final String src;
  // For now this is hard coded, as we only support one method.
  final CryptoProtocolVersion version =
      CryptoProtocolVersion.ENCRYPTION_ZONES;

  fsd.writeLock();
  try {
    src = fsd.resolvePath(pc, srcArg, pathComponents);
    final XAttr ezXAttr = fsd.ezManager.createEncryptionZone(src, suite,
        version, keyName);
    xAttrs.add(ezXAttr);
  } finally {
    fsd.writeUnlock();
  }
  fsd.getEditLog().logSetXAttrs(src, xAttrs, logRetryCache);
  final INodesInPath iip = fsd.getINodesInPath4Write(src, false);
  return fsd.getAuditFileInfo(iip);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:41,代码来源:FSDirEncryptionZoneOp.java

示例8: getEncryptionKeyInfo

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
static EncryptionKeyInfo getEncryptionKeyInfo(FSNamesystem fsn,
    FSPermissionChecker pc, String src,
    CryptoProtocolVersion[] supportedVersions)
    throws IOException {
  byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
  FSDirectory fsd = fsn.getFSDirectory();
  src = fsd.resolvePath(pc, src, pathComponents);
  INodesInPath iip = fsd.getINodesInPath4Write(src);
  // Nothing to do if the path is not within an EZ
  final EncryptionZone zone = FSDirEncryptionZoneOp.getEZForPath(fsd, iip);
  if (zone == null) {
    return null;
  }
  CryptoProtocolVersion protocolVersion = fsn.chooseProtocolVersion(
      zone, supportedVersions);
  CipherSuite suite = zone.getSuite();
  String ezKeyName = zone.getKeyName();

  Preconditions.checkNotNull(protocolVersion);
  Preconditions.checkNotNull(suite);
  Preconditions.checkArgument(!suite.equals(CipherSuite.UNKNOWN),
                              "Chose an UNKNOWN CipherSuite!");
  Preconditions.checkNotNull(ezKeyName);
  return new EncryptionKeyInfo(protocolVersion, suite, ezKeyName);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:FSDirWriteFileOp.java

示例9: mockCreate

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void mockCreate(ClientProtocol mcp,
    CipherSuite suite, CryptoProtocolVersion version) throws Exception {
  Mockito.doReturn(
      new HdfsFileStatus(0, false, 1, 1024, 0, 0, new FsPermission(
          (short) 777), "owner", "group", new byte[0], new byte[0],
          1010, 0, new FileEncryptionInfo(suite,
          version, new byte[suite.getAlgorithmBlockSize()],
          new byte[suite.getAlgorithmBlockSize()],
          "fakeKey", "fakeVersion"),
          (byte) 0, null))
      .when(mcp)
      .create(anyString(), (FsPermission) anyObject(), anyString(),
          (EnumSetWritable<CreateFlag>) anyObject(), anyBoolean(),
          anyShort(), anyLong(), (CryptoProtocolVersion[]) anyObject());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:TestEncryptionZones.java

示例10: setConf

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
@Override
public void setConf(Configuration conf) {
    String reEncryptionSuite = conf.get(HADOOP_SECURITY_CRYPTO_RE_ENC_SUITE_KEY,
        HADOOP_SECURITY_CRYPTO_RE_ENC_SUITE_DEFAULT);
    suite = CipherSuite.convert(reEncryptionSuite);
    this.conf = conf;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:AbstractReEncryptionKeyProvider.java

示例11: negotiateCipherOption

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
/**
 * Negotiate a cipher option which server supports.
 * 
 * @param conf the configuration
 * @param options the cipher options which client supports
 * @return CipherOption negotiated cipher option
 */
public static CipherOption negotiateCipherOption(Configuration conf,
    List<CipherOption> options) throws IOException {
  // Negotiate cipher suites if configured.  Currently, the only supported
  // cipher suite is AES/CTR/NoPadding, but the protocol allows multiple
  // values for future expansion.
  String cipherSuites = conf.get(DFS_ENCRYPT_DATA_TRANSFER_CIPHER_SUITES_KEY);
  if (cipherSuites == null || cipherSuites.isEmpty()) {
    return null;
  }
  if (!cipherSuites.equals(CipherSuite.AES_CTR_NOPADDING.getName())) {
    throw new IOException(String.format("Invalid cipher suite, %s=%s",
        DFS_ENCRYPT_DATA_TRANSFER_CIPHER_SUITES_KEY, cipherSuites));
  }
  if (options != null) {
    for (CipherOption option : options) {
      CipherSuite suite = option.getCipherSuite();
      if (suite == CipherSuite.AES_CTR_NOPADDING) {
        int keyLen = conf.getInt(
            DFS_ENCRYPT_DATA_TRANSFER_CIPHER_KEY_BITLENGTH_KEY,
            DFS_ENCRYPT_DATA_TRANSFER_CIPHER_KEY_BITLENGTH_DEFAULT) / 8;
        CryptoCodec codec = CryptoCodec.getInstance(conf, suite);
        byte[] inKey = new byte[keyLen];
        byte[] inIv = new byte[suite.getAlgorithmBlockSize()];
        byte[] outKey = new byte[keyLen];
        byte[] outIv = new byte[suite.getAlgorithmBlockSize()];
        codec.generateSecureRandom(inKey);
        codec.generateSecureRandom(inIv);
        codec.generateSecureRandom(outKey);
        codec.generateSecureRandom(outIv);
        return new CipherOption(suite, inKey, inIv, outKey, outIv);
      }
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:43,代码来源:DataTransferSaslUtil.java

示例12: EncryptionZone

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
public EncryptionZone(long id, String path, CipherSuite suite,
    CryptoProtocolVersion version, String keyName) {
  this.id = id;
  this.path = path;
  this.suite = suite;
  this.version = version;
  this.keyName = keyName;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:EncryptionZone.java

示例13: createEncryptionZone

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
XAttr createEncryptionZone(String src, CipherSuite suite,
    CryptoProtocolVersion version, String keyName)
  throws IOException {
  writeLock();
  try {
    return ezManager.createEncryptionZone(src, suite, version, keyName);
  } finally {
    writeUnlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:FSDirectory.java

示例14: createEncryptionZoneInt

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
private void createEncryptionZoneInt(final String srcArg, String cipher,
    String keyName, final boolean logRetryCache) throws IOException {
  String src = srcArg;
  HdfsFileStatus resultingStat = null;
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.WRITE);
  final byte[][] pathComponents =
    FSDirectory.getPathComponentsForReservedPath(src);
  FSPermissionChecker pc = getPermissionChecker();
  writeLock();
  try {
    checkSuperuserPrivilege();
    checkOperation(OperationCategory.WRITE);
    checkNameNodeSafeMode("Cannot create encryption zone on " + src);
    src = dir.resolvePath(pc, src, pathComponents);

    final CipherSuite suite = CipherSuite.convert(cipher);
    // For now this is hardcoded, as we only support one method.
    final CryptoProtocolVersion version =
        CryptoProtocolVersion.ENCRYPTION_ZONES;
    final XAttr ezXAttr = dir.createEncryptionZone(src, suite,
        version, keyName);
    List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
    xAttrs.add(ezXAttr);
    getEditLog().logSetXAttrs(src, xAttrs, logRetryCache);
    final INodesInPath iip = dir.getINodesInPath4Write(src, false);
    resultingStat = dir.getAuditFileInfo(iip);
  } finally {
    writeUnlock();
  }
  getEditLog().logSync();
  logAuditEvent(true, "createEncryptionZone", srcArg, null, resultingStat);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:FSNamesystem.java

示例15: EncryptionZoneInt

import org.apache.hadoop.crypto.CipherSuite; //导入依赖的package包/类
EncryptionZoneInt(long inodeId, CipherSuite suite,
    CryptoProtocolVersion version, String keyName) {
  Preconditions.checkArgument(suite != CipherSuite.UNKNOWN);
  Preconditions.checkArgument(version != CryptoProtocolVersion.UNKNOWN);
  this.inodeId = inodeId;
  this.suite = suite;
  this.version = version;
  this.keyName = keyName;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:EncryptionZoneManager.java


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