Topic
  • 3 replies
  • Latest Post - ‏2012-11-06T14:35:07Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic Destroy EncryptedCache won't work as expected

‏2012-11-05T14:51:28Z |
Hello everybody,
i'm using EOC to store a simple sensitive data.
The key to open the EOC is obtained by an adapter that call a Java Class (the key is a simple random hexadecimal string).

After i open my EOC adn saved my data, i close it. Then in my app there is button that when tapped call WL.EncryptedCache.destroy();

Then i could exit my app. When i re-enter, and login again, i obtain a new random hexadecimal string o open a new encrypted cache. When i call the open function, it says "ERRORS: Credentials Mismatch". Here i'll paste some code:

ON LOGIN:
WL.EncryptedCache.open( myRandomGeneratedKey, true,
function(status){
if(status == WL.EncryptedCache.OK){
WL.EncryptedCache.write("sensitiveData", "sensitiveValue",
function(status){
WL.EncryptedCache.close();
$.mobile.changePage("Other.html");
}, function(status){
if (status == WL.EncryptedCache.ERROR_EOC_CLOSED)
alert("Encrypted cache closed, write failed. error code= "+ status);
});
}
}, onOpenError);
ON LOGOUT:
WL.EncryptedCache.destroy(function(status){
if(status == WL.EncryptedCache.OK){
$.mobile.changePage("Login.html");
}
}, function(){ alert("Not destroy");});
  • rtimothy
    rtimothy
    22 Posts

    Re: Destroy EncryptedCache won't work as expected

    ‏2012-11-05T19:34:12Z  
    I'm unable to recreate this failure, what version of WL are you using?
  • rtimothy
    rtimothy
    22 Posts

    Re: Destroy EncryptedCache won't work as expected

    ‏2012-11-05T19:37:58Z  
    Also, are you running this on a device (iOS, Android, etc) or in a desktop browser (Chrome, FF, IE..)? You can try adding this code to your app, or running from the console if in a browser:

    
    
    
    for (var key in localStorage)
    {    console.log(key, 
    " = ", localStorage[key]); 
    }
    


    Is it possible that your app is trying to open with a new key twice after destroying, that appears to be the way to trigger this exception.

    --tim
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Destroy EncryptedCache won't work as expected

    ‏2012-11-06T14:35:07Z  
    • rtimothy
    • ‏2012-11-05T19:37:58Z
    Also, are you running this on a device (iOS, Android, etc) or in a desktop browser (Chrome, FF, IE..)? You can try adding this code to your app, or running from the console if in a browser:

    <pre class="jive-pre"> for (var key in localStorage) { console.log(key, " = ", localStorage[key]); } </pre>

    Is it possible that your app is trying to open with a new key twice after destroying, that appears to be the way to trigger this exception.

    --tim
    You're right, i was calling the login two times.

    This seems to be a jquery mobile issue, because going back and forward through the pages, the tap event handler (binded with jquery .on()) is fired as many times as you visit the login page.