<div dir="ltr"><br><div class="gmail_extra"><div>Hi Summers<br class=""><br></div><div>Referring to <a href="http://aerogear-dev.1069024.n5.nabble.com/aerogear-dev-Fallback-Strat-for-DataManager-td5188.html">http://aerogear-dev.1069024.n5.nabble.com/aerogear-dev-Fallback-Strat-for-DataManager-td5188.html</a></div>
<div>where we might have async API for store in JS, I think we might benefit of async for native apps too, specially in the case of encrypted stores.</div><div><br></div><div>Something like <a href="https://github.com/rnapier/RNCryptor#asynchronous-use">https://github.com/rnapier/RNCryptor#asynchronous-use</a></div>
<div><br></div><div>Of course, it can be done in later releases. Encrypting large field, you don't want to have your UI sluggish.</div><div><br></div><div>wdyt?</div><div><br></div><div>++</div><div>Corinne</div><br><div class="gmail_quote">
On 5 November 2013 17:44, Summers Pittman <span dir="ltr"><<a href="mailto:supittma@redhat.com" target="_blank">supittma@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 11/05/2013 02:41 AM, Corinne Krych wrote:<br>
> Hello all,<br>
><br>
> I've got 2 points:<br>
><br>
> - modularity: AeroGear libs are small and modular: we have a separate aerogear-otp-ios, aerogear-push-ios-registration so that if the user wants to use aerogear without push, he can use aerogear-ios, if he needs the push-registration, he uses both. For encryption store, where do we want to put EncryptedStore? aerogear-android depends on aerogear-crypto.<br>
</div>On Android it is going into the main library. We can research slicing<br>
the client library up for 2.0, but I would like to, for now, make<br>
getting up and running with anything AeroGear on Android as simple as<br>
including the dependency.<br>
<div class="im">><br>
> - Encrypting data takes time. It would be nice to have EncryptedStore encrypts data on separate thread and provide callbacks on completion.<br>
> thoughts?<br>
</div>Then we would have an encrypted Pipe. One of the things about Stores is<br>
that they are synchronous, Pipes are asynchronous.<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5">><br>
> ++<br>
> Corinne<br>
> On Nov 4, 2013, at 5:30 PM, Daniel Passos <<a href="mailto:daniel@passos.me">daniel@passos.me</a>> wrote:<br>
><br>
>> The idea is implementing only save(add/update) and delete, using the stores we already have today by just adding crypt / decrypt and scheduling Query (readWithFilter) for the next release<br>
>> DataManager<br>
>><br>
>> public Store encryptedStore(String storeName, String passphrase) {<br>
>> // TODO Create a default passphrase-based KeyStore<br>
>> KeyStore keyStore = null;<br>
>> return encryptedStore(storeName, keyStore);<br>
>> }<br>
>><br>
>> public Store encryptedStore(String storeName, KeyStore keyStore) {<br>
>> StoreConfig storeConfig = new StoreConfig();<br>
>> storeConfig.setType(StoreTypes.ENCRYPTED_MEMORY);<br>
>> return encryptedStore(storeName, storeConfig, keyStore);<br>
>> }<br>
>><br>
>> public Store encryptedStore(String storeName, StoreConfig config, String passphrase) {<br>
>> // TODO Create a default passphrase-based KeyStore<br>
>> KeyStore keyStore = null;<br>
>> return encryptedStore(storeName, config, keyStore);<br>
>> }<br>
>><br>
>> public Store encryptedStore(String storeName, StoreConfig config, KeyStore keyStore) {<br>
>> config.setKeyStore(keyStore);<br>
>> Store store = storeFactory.createStore(config);<br>
>> stores.put(storeName, store);<br>
>> return store;<br>
>> }<br>
>><br>
>> EncryptedMemoryStore<br>
>><br>
>> public class EncryptedMemoryStore<T> implements Store<T> {<br>
>><br>
>> private final MemoryStorage<T> memoryStorage;<br>
>> private final CryptoUtils<T> cryptoUtils;<br>
>><br>
>> public EncryptedMemoryStore(IdGenerator idGenerator, KeyStore keyStore) {<br>
>> memoryStorage = new MemoryStorage(idGenerator);<br>
>> cryptoUtils = new CryptoUtils<T>(keyStore);<br>
>> }<br>
>><br>
>> @Override<br>
>> public StoreType getType() {<br>
>> return StoreTypes.ENCRYPTED_MEMORY;<br>
>> }<br>
>><br>
>> @Override<br>
>> public Collection<T> readAll() throws InvalidKeyException {<br>
>> Collection<T> encryptedCollection = memoryStorage.readAll();<br>
>> return cryptoUtils.decrypt(encryptedCollection);<br>
>> }<br>
>><br>
>> @Override<br>
>> public T read(Serializable id) throws InvalidKeyException {<br>
>> T encryptedItem = memoryStorage.read(id);<br>
>> return cryptoUtils.decrypt(encryptedItem);<br>
>> }<br>
>><br>
>> @Override<br>
>> public List<T> readWithFilter(ReadFilter filter) throws InvalidKeyException {<br>
>> List<T> encryptedList = memoryStorage.readWithFilter(filter);<br>
>> return cryptoUtils.decrypt(encryptedList);<br>
>> }<br>
>><br>
>> @Override<br>
>> public void save(T item) {<br>
>> memoryStorage.save(cryptoUtils.encrypt(item));<br>
>> }<br>
>><br>
>> @Override<br>
>> public void reset() {<br>
>> memoryStorage.reset();<br>
>> }<br>
>><br>
>> @Override<br>
>> public void remove(Serializable id) {<br>
>> memoryStorage.remove(id);<br>
>> }<br>
>><br>
>> @Override<br>
>> public boolean isEmpty() {<br>
>> return memoryStorage.isEmpty();<br>
>> }<br>
>><br>
>> }<br>
>><br>
>> CryptoUtils<br>
>><br>
>> Here is where the magic happens.<br>
>><br>
>><br>
>> public class CryptoUtils<T> {<br>
>><br>
>> private final KeyStore keyStore;<br>
>><br>
>> public CryptoUtils(KeyStore keyStore) {<br>
>> this.keyStore = keyStore;<br>
>> }<br>
>><br>
>> public Collection<T> decrypt(Collection<T> encryptedCollection) {<br>
>> List<T> decryptedList = new ArrayList<T>();<br>
>> for (T item : encryptedCollection) {<br>
>> decryptedList.add(decrypt(item));<br>
>> }<br>
>> return decryptedList;<br>
>> }<br>
>><br>
>> public List<T> decrypt(List<T> encryptedList) {<br>
>> List<T> decryptedList = new ArrayList<T>();<br>
>> for (T item : encryptedList) {<br>
>> decryptedList.add(decrypt(item));<br>
>> }<br>
>> return decryptedList;<br>
>> }<br>
>><br>
>> public T decrypt(T item) {<br>
>> // TODO Read all fields and decrypt<br>
>> return item;<br>
>> }<br>
>><br>
>> public T encrypt(T item) {<br>
>> // TODO Read all fields and encrypt<br>
>> return item;<br>
>> }<br>
>><br>
>> }<br>
>><br>
>> _______________________________________________<br>
>> aerogear-dev mailing list<br>
>> <a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
><br>
> _______________________________________________<br>
> aerogear-dev mailing list<br>
> <a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
<br>
_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
</div></div></blockquote></div><br></div></div>