in encryption/src/main/java/org/apache/solr/encryption/EncryptionTransactionLog.java [199:225]
public OutputStream open(FileChannel channel, long position) throws IOException {
OutputStream outputStream = OUTPUT_STREAM_OPENER.open(channel, position);
if (position != 0 && ivHolder.iv == null) {
return outputStream;
}
EncryptionDirectory directory = directorySupplier.get();
try {
String keyRef = getActiveKeyRefFromCommit(directory.getLatestCommitData().data);
if (keyRef != null) {
// Get the key secret first. If it fails, we do not write anything.
byte[] keySecret = directory.getKeySecret(keyRef);
// The output stream has to be wrapped to be encrypted with the key.
writeEncryptionHeader(keyRef, outputStream);
EncryptingOutputStream eos = createEncryptingOutputStream(outputStream,
position,
ivHolder.iv,
keySecret,
directory.getEncrypterFactory());
ivHolder.iv = eos.getIv();
return eos;
}
ivHolder.iv = null;
return outputStream;
} finally {
directorySupplier.release(directory);
}
}