Search in sources :

Example 1 with NoFileEncrypter

use of org.apache.accumulo.core.spi.crypto.NoFileEncrypter in project accumulo by apache.

the class PrintInfo method printCryptoParams.

/**
 * Print the unencrypted parameters that tell the Crypto Service how to decrypt the file. This
 * information is useful for debugging if and how a file was encrypted.
 */
private void printCryptoParams(Path path, FileSystem fs) {
    byte[] noCryptoBytes = new NoFileEncrypter().getDecryptionParameters();
    try (FSDataInputStream fsDis = fs.open(path)) {
        long fileLength = fs.getFileStatus(path).getLen();
        fsDis.seek(fileLength - 16 - Utils.Version.size() - Long.BYTES);
        long cryptoParamOffset = fsDis.readLong();
        fsDis.seek(cryptoParamOffset);
        byte[] cryptoParams = CryptoUtils.readParams(fsDis);
        if (Arrays.equals(noCryptoBytes, cryptoParams)) {
            System.out.println("No on disk encryption detected.");
        } else {
            System.out.println("Encrypted with Params: " + Key.toPrintableString(cryptoParams, 0, cryptoParams.length, cryptoParams.length));
        }
    } catch (IOException ioe) {
        log.error("Error reading crypto params", ioe);
    }
}
Also used : NoFileEncrypter(org.apache.accumulo.core.spi.crypto.NoFileEncrypter) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 NoFileEncrypter (org.apache.accumulo.core.spi.crypto.NoFileEncrypter)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1