@Override
public BlobDataSource read(final URI uri) throws IOException
{
InputStream in;
BlobURI blobUri = new BlobURI().fromURI(uri);
String keyAlias = blobUri.getEncryptionKey();
if (keyAlias != null)
{
EncryptionHandler eh = new AESEncryptionHandler();
try {
logger.debug("Decrypting object {} with key {}", uri, keyAlias);
byte[] iv = getCipherIVFromBlobName(BlobUtils.relativize(uri.getPath()));
in = eh.decrypt(CloudStoreProxy.read(uri),
Configurator.getEncryptionKey(keyAlias), iv);
} catch (GeneralSecurityException gse) {
throw new IOException("Unable to decrypt message blob: ", gse);
}
} else {
in = CloudStoreProxy.read(uri);
}
return new BlobDataSource(uri, in);
}