Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-3719

It is impossible to create two different stores with the same underlying model class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.4.0
    • 1.3.0
    • None
    • None

      Given:

      I need to create two stores which have different store names and passphrases but they are using same model class underneath.

      When:

      I call

      dataManager.encryptedStore("store1", sqlStoreConfig, "passphrase1", SimpleUser.class);
      dataManager.encryptedStore("store2", sqlStoreConfig, "passphrase2", SimpleUser.class);
      

      Then:

      I expect that when I do any operation on store2 as readAll(), no exception is thrown.

      Error stack:

      E/AndroidRuntime( 2006): org.jboss.aerogear.android.impl.crypto.InvalidKeyException: java.lang.RuntimeException: Error: 
      E/AndroidRuntime( 2006): 	at org.jboss.aerogear.android.impl.util.CryptoUtils.decrypt(CryptoUtils.java:68)
      E/AndroidRuntime( 2006): 	at org.jboss.aerogear.android.impl.datamanager.EncryptedSQLStore.readAll(EncryptedSQLStore.java:173)
      E/AndroidRuntime( 2006): 	at org.aerogear.android.offline.demo.OfflineRegistrationActivity$1$1.onSuccess(OfflineRegistrationActivity.java:99)
      E/AndroidRuntime( 2006): 	at org.aerogear.android.offline.demo.OfflineRegistrationActivity$1$1.onSuccess(OfflineRegistrationActivity.java:89)
      E/AndroidRuntime( 2006): 	at org.jboss.aerogear.android.authentication.impl.loader.support.SupportAuthenticationModuleAdapter$CallbackHandler.run(SupportAuthenticationModuleAdapter.java:302)
      E/AndroidRuntime( 2006): 	at android.os.Handler.handleCallback(Handler.java:725)
      E/AndroidRuntime( 2006): 	at android.os.Handler.dispatchMessage(Handler.java:92)
      E/AndroidRuntime( 2006): 	at android.os.Looper.loop(Looper.java:137)
      E/AndroidRuntime( 2006): 	at android.app.ActivityThread.main(ActivityThread.java:5039)
      E/AndroidRuntime( 2006): 	at java.lang.reflect.Method.invokeNative(Native Method)
      E/AndroidRuntime( 2006): 	at java.lang.reflect.Method.invoke(Method.java:511)
      E/AndroidRuntime( 2006): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
      E/AndroidRuntime( 2006): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
      E/AndroidRuntime( 2006): 	at dalvik.system.NativeStart.main(Native Method)
      E/AndroidRuntime( 2006): Caused by: java.lang.RuntimeException: Error: 
      E/AndroidRuntime( 2006): 	at org.jboss.aerogear.crypto.CryptoBox.decrypt(CryptoBox.java:167)
      E/AndroidRuntime( 2006): 	at org.jboss.aerogear.android.impl.util.CryptoUtils.decrypt(CryptoUtils.java:64)
      E/AndroidRuntime( 2006): 	... 13 more
      E/AndroidRuntime( 2006): Caused by: org.bouncycastle.crypto.InvalidCipherTextException: mac check in GCM failed
      E/AndroidRuntime( 2006): 	at org.bouncycastle.crypto.modes.GCMBlockCipher.doFinal(Unknown Source)
      E/AndroidRuntime( 2006): 	at org.jboss.aerogear.crypto.CryptoBox.decrypt(CryptoBox.java:165)
      E/AndroidRuntime( 2006): 	... 14 more
      

      Proposed change to API:

      There should be the way how to change the name of the database. Right now, its name is derived from name of the model class, it can be set as

      storeConfig.setDatabaseName("someName");
      

            supittma@redhat.com Summers Pittman (Inactive)
            smikloso Stefan Miklosovic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: