private WALHeader buildSecureWALHeader(Configuration conf, WALHeader.Builder builder)
    throws IOException {
    EncryptionTest.testKeyProvider(conf);
    EncryptionTest.testCipherProvider(conf);

    // Get an instance of our cipher
    final String cipherName =
      conf.get(HConstants.CRYPTO_WAL_ALGORITHM_CONF_KEY, HConstants.CIPHER_AES);
    Cipher cipher = Encryption.getCipher(conf, cipherName);
    if (cipher == null) {
      throw new RuntimeException("Cipher '" + cipherName + "' is not available");
    }

    // Generate a random encryption key for this WAL
    Key key = cipher.getRandomKey();
    builder.setEncryptionKey(UnsafeByteOperations.unsafeWrap(EncryptionUtil.wrapKey(conf,
      conf.get(HConstants.CRYPTO_WAL_KEY_NAME_CONF_KEY,
        conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY, User.getCurrent().getShortName())),
      key)));

    // Set up the encryptor
    Encryptor encryptor = cipher.getEncryptor();
    encryptor.setKey(key);
    this.encryptor = encryptor;
    if (LOG.isTraceEnabled()) {
      LOG.trace("Initialized secure protobuf WAL: cipher={}", cipher.getName());
    }
    builder.setWriterClsName(getWriterClassName());
    builder.setCellCodecClsName(SecureWALCellCodec.class.getName());
    return builder.build();
  }
Base class for Protobuf log writer.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java