in encryption/src/main/java/org/apache/solr/encryption/EncryptionDirectory.java [251:272]
public IndexInput openInput(String fileName, IOContext context) throws IOException {
IndexInput indexInput = in.openInput(fileName, context);
if (!shouldCheckEncryptionWhenReading) {
// Return the IndexInput directly as we know it is not encrypted.
return indexInput;
}
boolean success = false;
try {
String keyRef = getKeyRefForReading(indexInput);
if (keyRef != null) {
// The IndexInput has to be wrapped to be decrypted with the key.
indexInput = new DecryptingIndexInput(indexInput, getKeySecret(keyRef), encrypterFactory);
}
success = true;
} finally {
if (!success) {
// Something went wrong. Close the IndexInput before the exception continues.
IOUtils.closeWhileHandlingException(indexInput);
}
}
return indexInput;
}