use of ddf.security.encryption.crypter.Crypter.CrypterException in project ddf by codice.
the class FileSystemStorageProvider method decryptStream.
private ByteSource decryptStream(InputStream contentInputStream) throws StorageException {
ByteSource output = null;
try (InputStream decryptedInputStream = crypter.decrypt(contentInputStream);
FileBackedOutputStream decryptedOutputStream = new FileBackedOutputStream(128)) {
// do not use try with resources in order to have these InputStreams in the finally block
IOUtils.copy(decryptedInputStream, decryptedOutputStream);
output = decryptedOutputStream.asByteSource();
} catch (CrypterException | IOException e) {
LOGGER.debug("Error decrypting InputStream {}. Failing StorageProvider read.", contentInputStream, e);
throw new StorageException(String.format("Cannot decrypt InputStream %s.", contentInputStream), e);
}
return output;
}
Aggregations