Worklight的JEG存储加密不适用于ios

时间:2016-09-19 06:02:35

标签: ios json encryption ibm-mobilefirst

我在我的应用程序中使用JSONStore来存储一些敏感数据。要加密收集,我们将使用用户名和密码传递选项,如下所述。在Android到目前为止它的工作正常,但在ios设备中,我们在从集合中检索数据时获得空白页面(在模拟器中正常工作)。我也没有得到任何错误。没有在ios中传递选项,它的工作正常。有人遇到过类似的问题吗?

factory('todoJsonStorage',['$q', function ($q) {
'use strict';

var COLLECTION_NAME = 'Users';
var collections = {
        Users: {
            searchFields: {UserId: 'string', password: 'string'}
        },
    };
var options = {};

//Optional username
options.username = 'testuser';
//Optional password
options.password = 'test123';

 //Optional local key generation flag
 options.localKeyGen = true;

var inited = false;

//checks if inited and if not inits
function initJSONStore(){
    var initDeferred = $q.defer();
    if (inited){
        initDeferred.resolve();
    } else {
        //Initialize the collection
        WL.JSONStore.init(collections,options).then(function () {
            console.log("-> JSONStore init successful");
            initDeferred.resolve();
        }).fail(function (errorObject) {
            console.log("-> JSONStore error: " + errorObject.msg);
        });

        return initDeferred.promise;
    };
}

return {
    get: function () {
        var deferred = $q.defer();
        initJSONStore().then(function(){
            WL.JSONStore.get(COLLECTION_NAME).findAll().then(function (res) {
                if (res.length > 0){
                    deferred.resolve(JSON.parse(res[0].json.data || '[]'));
                } else {
                      deferred.resolve(res);                   
                      }

            }).fail(function (errorObject) {
                console.log("JSONStore findbyid error: " + errorObject.msg);
            });
        });
        return deferred.promise;
    },

    put: function (todos) {
        WL.JSONStore.get(COLLECTION_NAME).clear();
        WL.JSONStore.get(COLLECTION_NAME).add({data:JSON.stringify(todos)});
    }
};

}])

1 个答案:

答案 0 :(得分:0)

如果您使用的是iOS 10,则必须启用Keychain Sharing Capability,否则这应该是开箱即用的。