Example usage for org.apache.hadoop.crypto CipherSuite getConfigSuffix

List of usage examples for org.apache.hadoop.crypto CipherSuite getConfigSuffix

Introduction

In this page you can find the example usage for org.apache.hadoop.crypto CipherSuite getConfigSuffix.

Prototype

public String getConfigSuffix() 

Source Link

Document

Returns suffix of cipher suite configuration.

Usage

From source file:com.mellanox.r4h.DFSClient.java

License:Apache License

/**
 * Obtain a CryptoCodec based on the CipherSuite set in a FileEncryptionInfo
 * and the available CryptoCodecs configured in the Configuration.
 * /*from  w  w w .  j a va 2 s. c o m*/
 * @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;
}