18 Replies Latest reply on Dec 2, 2009 10:36 PM by Joe ... Ward

    Issue with EncryptedLocalStore and air file

    jord1242 Level 1

      Ok, if I test out my app it is just fine from the adl using:

       

      >C:\air\sdk\bin\adl C:\IBM\work.......\application.xml

       

      and the app runs fine in test mode with the EncryptedLocalStore

       

      It's when I make an AIR file:

       

      C:\IBM\work.......>C:\air\sdk\bin\adt -package -storetype pkcs12 -keystore ../app.pfx app.air application.xml .

       

      password: **********

      And when I run my file it is dying at the following:
      username_data = air.EncryptedLocalStore.getItem( "username" );
      If I put a try catch around the error that is thrown is: ERROR
      Anyway I can figure out why ONLY when I run the air app it is doing this? ANy ideas on debugging? I cannot get this to access the EncryptedLocalStore only in the air app.
      Thanks for any help!
      JJ
        • 1. Re: Issue with EncryptedLocalStore and air file
          Joe ... Ward Level 4

          One thing to note is that the EncryptedLocalStore is in a  different file when you run an app that hasn't been installed.

           

          To help debug cases like this, you can install the app and then run it with adl from the app's install folder (by passing the installed application.xml file to ADL). This will give you debug information, including better error messages. You can also start up the Flash Debugger (FDB) beforehand, and ADL will connect to it.

           

          It might also help to specify a publisher ID on the command line when you run your development project from ADL since ELS uses the publisher ID as part of it's encryption algorithm.

          • 2. Re: Issue with EncryptedLocalStore and air file
            jord1242 Level 1

            Ok, it works just fine using the ADL from the installed directory. What is the flash debug thing you are talking about? Maybe I can try that with the app running.

             

            Thanks!

            JJ

            • 3. Re: Issue with EncryptedLocalStore and air file
              Joe ... Ward Level 4

              FDB is a debugger for ActionScript included with the Flex SDK. Of course, if you app works in debug mode, it might be one of "those" problems. Try the -nodebug flag to see if the problems return. You can at least get trace statements with -nodebug on.

              • 4. Re: Issue with EncryptedLocalStore and air file
                jord1242 Level 1

                Do I use the -nodebug when testing out with ADL or when rolling the new AIR file? I tried with ADL but saw nothing different in debug mode, it worked as expected. It is only when I roll the AIR file, then run the exe file that it has a problem. I just have no clue what the "problem" is. The AIR file is erroring no matter what computer I use it at.

                 

                Thanks again for all your help. I am stumped and still new to AIR.

                 

                JJ

                • 5. Re: Issue with EncryptedLocalStore and air file
                  Joe ... Ward Level 4

                  Use -nodebug when testing the installed version with ADL. This will give you the closest thing to the normal running environment of your app, while at least giving you the ability to use trace() to help debug.

                  • 6. Re: Issue with EncryptedLocalStore and air file
                    jord1242 Level 1

                    Using this:

                     

                     

                    H:\>c:\air\sdk\bin\adl -nodebug "c:\Program Files\adobe\app\app_Notifier\application.xml"

                     

                     

                    It worked just fine. And that is testing with ADL against the installed version. So not sure why the EncryptedLocalStore is failing with the actual exe file, but that is the only place it is failing, so trace statements wouldn't help me, right?

                     

                    Thanks,

                    JJ

                    • 7. Re: Issue with EncryptedLocalStore and air file
                      Joe ... Ward Level 4

                      You can't use trace statements in that case. You could display messages in the UI or log them to a file, though.

                       

                      At this point, I'd recommend that you write a simple app that sets a value and gets it back from the ELS. Test it the same way as you problem app. This should demonstrate that the ELS at least can work.

                       

                      If that fails, then it is probably a problem with your particular copy of the SDK or a problem with the instances of the AIR runtime you have installed or an obscure bug in AIR (obscure because many apps use ELS). At least those are the possibilities I can think of.

                      1 person found this helpful
                      • 8. Re: Issue with EncryptedLocalStore and air file
                        jord1242 Level 1

                        Ok, I created a brand new project, very simple, just sets and gets something from the ELS with this:

                         

                           alert(' in here 1');

                                  air.EncryptedLocalStore.setItem( "username", "blah" );

                                  var username_data = air.EncryptedLocalStore.getItem( "username" );

                               alert(username_data);

                           alert('in here 2');

                         

                         

                        Roll the AIR file, and run, and it alerts the first but does NOT alert the second, same thing happening in my project. If it was an SDK problem, then wouldn't this be happening both running from the ADL and from the AIR file?

                         

                        So suggestions? Maybe something is corrupt, which should I try first, new copy of the SDK or the AIR runtime? How do I re-install the runtime?

                         

                        Thanks again for all your help. It does appear to be something corrupt somewhere, not just in my code.

                         

                        JJ

                        • 9. Re: Issue with EncryptedLocalStore and air file
                          jord1242 Level 1

                          Any possibility it is the way I am rolling the AIR file?

                           

                          adt -package -storetype pkcs12 -keystore ../app.pfx appnotifier.air application.xml .

                          • 10. Re: Issue with EncryptedLocalStore and air file
                            sundeep.maithani Level 3

                            Hi

                            It is possible that your ELS databased is corrupt. I suggest that you try clearing any previously saved ELS data, by renaming the folder:

                            C:\Documents and Settings\<user>\Application Data\Adobe\Air\ELS

                            And try with your installed app again.

                             

                            Let me know if that works for you.

                             

                            -Thanks

                            Sundeep

                            AIR Team

                            • 11. Re: Issue with EncryptedLocalStore and air file
                              jord1242 Level 1

                              Thank you Sundeep for the help. I did rename the ELS directory, rolled a brand new AIR application (install not a replace) and it is still doing the same thing, works from the ADL but not from an AIR app.

                               

                              As this is happening on another machine as well, I would imagine it is not an issue with the AIR runtime, so maybe with the version of the SDK I have? Should I try redownloading? Is that as simple as replacing the files in c:\air\sdk with the set that I download??

                               

                              Thanks so much everyone for all your help. This is really frutrating, but mostly because I am so new to AIR development.

                               

                              JJ

                              • 12. Re: Issue with EncryptedLocalStore and air file
                                sundeep.maithani Level 3

                                Hey JJ

                                Would you mind sharing the sample air app you rolled out?

                                -Thanks

                                Sundeep

                                AIR Team

                                • 13. Re: Issue with EncryptedLocalStore and air file
                                  jord1242 Level 1

                                  It makes AJAX calls to our server and has some "sensitive" stuff in it, I could provide you the application.xml and a revised version of the login.html and login.js if that would help.

                                  • 14. Re: Issue with EncryptedLocalStore and air file
                                    jord1242 Level 1

                                    as an side, I tried downloading and replacing the SDK and it made no difference.

                                     

                                    JJ

                                    • 15. Re: Issue with EncryptedLocalStore and air file
                                      Joe ... Ward Level 4

                                      I took it on faith that your code worked in debug mode, but after examining your test code more closely, I think all you are seeing is how errors are handled differently (there might even be a bug there, since I would expect running -nodebug with ADL to behave more closely to an installed app).

                                       

                                      But the root of the problem is most likely that you are using the ELS incorrectly. You can't just read and write strings to it. You have to put your data in a ByteArray object, and you get it back as a ByteArray object. I rewrote your test code to make it work:

                                       

                                              alert(' in here 1');

                                           var name = new air.ByteArray();

                                           name.writeUTFBytes("blah");

                                            air.EncryptedLocalStore.setItem( "username", name );

                                            var username_data = air.EncryptedLocalStore.getItem( "username" );

                                            alert(username_data.readUTFBytes( username_data.bytesAvailable));

                                            alert('in here 2');

                                       

                                      There are read/write methods to put different data types into the ByteArray. Please try something like this and see if it solves your problem.

                                       

                                      I initially thought it might be the SDK until I realized that you are using html/javascript. In this case, the SDK is unlikely to be the culprit.

                                       

                                      BTW, what version of the runtime are you using?

                                       

                                      -Joe

                                      • 16. Re: Issue with EncryptedLocalStore and air file
                                        jord1242 Level 1

                                        Thanks Joe for the reply. I was getting the data back the wrong way in my app. In my test app I setup, I replaced with your code and tried from ADL and it worked, but yet again, from the installed AIR app it didn't. It gets to the first alert and nothing else happens, error is happening but not sure how to see it. Here is the full code from the example. I can provide the application.xml if that would help:

                                         

                                        <html>

                                        <head>

                                           <title>Todo List!</title>

                                           <style type="text/css">

                                           body {

                                               margin: 20px;

                                           }

                                           h1 {

                                               font-family: sans-serif;

                                           }

                                           </style>

                                           <script type="text/javascript">

                                           function remove_todo(element) {

                                               element.parentNode.removeChild(element);

                                           }

                                         

                                        alert(' in here 1');

                                             var name = new air.ByteArray();

                                             name.writeUTFBytes("blah");

                                              air.EncryptedLocalStore.setItem( "username", name );

                                              var username_data = air.EncryptedLocalStore.getItem( "username" );

                                        alert(username_data.readUTFBytes( username_data.bytesAvailable));

                                        alert('in here 2');

                                         

                                           window.onload = function() {

                                               document.getElementById('add_item').onmousedown = function() {

                                                   item_text = document.getElementById('new_text').value;

                                                   new_item = document.createElement('li');

                                                   new_a = document.createElement('a');

                                                   new_a.onmousedown = function() {

                                                       remove_todo(this.parentNode);

                                                   }

                                                   new_a.innerHTML = item_text;

                                                   new_item.appendChild(new_a);

                                                   document.getElementById('todo_items').appendChild(new_item);

                                               }

                                           }

                                           </script>

                                        </head>

                                        <body>

                                           <h1>Todo Items</h1>

                                           <p><input type="text" id="new_text" /><input type="submit" id="add_item" /></p>

                                           <ul id="todo_items">

                                           </ul>

                                        </body>

                                        </html>

                                        • 17. Re: Issue with EncryptedLocalStore and air file
                                          jord1242 Level 1

                                          My application.xml file:

                                           

                                          <?xml version="1.0" encoding="UTF-8"?>

                                          <application xmlns="http://ns.adobe.com/air/application/1.0">

                                             <id>examples.sp.todo</id>

                                             <filename>TodoList</filename>

                                             <version>1</version>

                                             <name>SitePoint.com AIR Example: Todo List</name>

                                             <description>This application helps you manage your pending tasks.</description>

                                             <initialWindow>

                                                 <content>index.html</content>

                                                 <visible>true</visible>

                                                 <width>200</width>

                                             </initialWindow>

                                          </application>

                                           

                                          And the command-line I use to roll the AIR file:

                                           

                                          C:\air\projects\hello_world>adt -package -storetype pkcs12 -keystore testCert.pfx test.air application.xml .

                                          • 18. Re: Issue with EncryptedLocalStore and air file
                                            Joe ... Ward Level 4

                                            All I can say at this point is that you last bit of code works for me both from ADL and when installed.

                                             

                                            I take that back (I thought I'd pasted your code over mine, but somehow didn't). Are you importing the AIRAliases.js file? It's not in the code you pasted above. Without that file, you can't use the "air.ClassName" form to invoke AIR APIs. You would have to use the "window.runtime.package.ClassName" form.

                                             

                                            The easiest thing to do is import it with a script tag:

                                            <script src="AIRAliases.js"></script>

                                             

                                            And copy the file from the AIR ADK into your source directory.

                                             

                                            Also, the way you have defined the name variable doesn't work since it stomps on an existing property of the JavaScript Window object.

                                             

                                            You should change application.xml namespace to http://ns.adobe.com/air/application/1.5" so that you are running against the latest API (I don't think this will solve the current issue, though).

                                             

                                            Message was edited by: Joe ... Ward