How to protect tpk files

3377
3
07-09-2012 07:10 PM
lynnwang
New Contributor II
Hi,all!

    when I use tpk through itune sharing files,the files are public.  This may have some data security problems.  Anyone who have the tpk files can see these map using ArcMap or other apps.
    Are there some good ideas about authorize data access or encrypt the tpk files?


    thanks!
0 Kudos
3 Replies
lynnwang
New Contributor II
Any ideas?
0 Kudos
EvanKirkwood
New Contributor II
Hi,all!

    when I use tpk through itune sharing files,the files are public.  This may have some data security problems.  Anyone who have the tpk files can see these map using ArcMap or other apps.
    Are there some good ideas about authorize data access or encrypt the tpk files?


    thanks!


Hi Lynn,

iOS provides some convenient mechanisms for on-disk data encryption. I'd suggest taking a look at the setAttributes: ofItemAtPath: error: method of the NSFileManager class. You can, for example, set the NSFileProtectionCompleteUnlessOpen attribute so a file is stored in an encrypted format on disk and can only be opened while the device is unlocked. Once open, your app may continue to access the file normally, even if the user locks the device. Then, if the device is passcode protected, only users that know the passcode will be able to decrypt the file.

You can find more information about this under "Protecting Data Using On-Disk Encryption" in the Advanced App Tricks chapter the iOS App Programming Guide.

Another idea might be to move the TPK out of the app's Documents directory once it's been loaded - the list of files visible for an iOS app under iTunes File Sharing corresponds to the Documents directory within the app's "sandbox" (i.e. the portion of the iOS file system accessible to the app). After loading, you could move the TPK from the Documents directory to somewhere else - the Library directory, for instance - then use the localTiledLayerWithPath method of the AGSLocalTiledLayer class to create the tiled layer specifying the new path to the TPK file. The code would look something like this:

NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager copyItemAtPath: pathToDocumentsTPK toPath: pathToLibraryTPK error: NULL ])
 [fileManager removeItemAtPath: pathToDocumentsTPK error:nil];

AGSLocalTiledLayer* tiledLayer = [AGSLocalTiledLayer localTiledLayerWithPath: pathToLibraryTPK];


After the TPK has been moved out of the Documents directory, it would no longer appear in iTunes File Sharing. However, that also means that users would have no way to delete or update the TPK - you'd have to build functionality into your app to manage updates and deletions for TPK files, or some mechanism to move the TPK back to the Documents directory to make it accessible to users again.

Just a couple of ideas ... I'm sure there are other options as well. Hope that helps.

Evan
0 Kudos
lynnwang
New Contributor II
Evan, thank you very much for your advice. It's really useful.:o

  Still hope esri can offer a verify mechanism of tpk.:)
0 Kudos