03-19-2012 10:28 AM
I have a JS extension which I include as part of my app. That extension encrypts some downloaded pictures using setControlledAccess. However, I can't open those pictures in the WebWorks part of my app! That is, I can't simply say:
The picture just won't show up.
At the same time, I'm able to open those pictures in the extension itself. I sign the whole app during build (set up WebSigner).
So… What's the problem?
Solved! Go to Solution.
03-19-2012 03:01 PM
The ControlledAccess class wraps a Java Object to secure it. It's typically used with the Runtime or Persistent Stores to securely share data between modules signed with the same key.
03-19-2012 11:04 PM
I don't use ControlledAccess. As I've said above, I use setControlledAccess (a method of ExtendedFileConnection). And, well, I encrypt (and can decrypt) files via a JS call, but that's no use to me! I need to be able to display encrypted images. If I sign the whole app with the key that is used for encryption, why can't I simply display those pictures in the HTML part of my app?
03-21-2012 05:03 PM
I don't think the application can read the file because it's not actually the application module (signed with your key) that is doing the reading. When you set the src of an image to the file system path, the Browser Rendering engine is the module that is going to do the reading, and I think that's where it falls apart.
However, since you can read your files direction in your extension, why not add a method that returns your files as Data URLs? You can encode your byte of the image as Base 64 like so:
byte encoded = Base64OutputStream.encode( data, 0, data.length, false, false ); String encodedStr = new String( encoded, UTF8_ENCODING );
Then append the data values, like "data:image/png;base64," to the front of the result and you can set this string as the src of your image object, or even use it in your css.