【发布时间】:2015-10-06 18:17:26
【问题描述】:
我创建了一个 JSONStore 并尝试加密集合中的数据。
我的理解是,AES 加密是通过使用用户名和密码保护集合来完成的;我通过设置localKeyGen : true 成功做到了这一点。
但是我仍然收到纯文本作为响应。
JSONStore
var collectionName = 'people';
// Object that defines all the collections.
var collections = {
// Object that defines the 'people' collection.
people : {
// Object that defines the Search Fields for the 'people' collection.
searchFields : {name: 'string', age: 'integer'}
}
};
// Optional options object.
var options = {
// Optional username, default 'jsonstore'.
username : 'carlos',
// Optional password, default no password.
password : '123',
// Optional local key generation flag, default false.
localKeyGen : true
};
WL.JSONStore.init(collections, options)
.then(function () {
// Data to add, you probably want to get
// this data from a network call (e.g. Worklight Adapter).
var data = [{name: 'carlos', age: 10}];
// Optional options for add.
var addOptions = {
// Mark data as dirty (true = yes, false = no), default true.
markDirty: true
};
// Get an accessor to the people collection and add data.
return WL.JSONStore.get(collectionName).add(data, addOptions);
})
.then(function (numberOfDocumentsAdded) {
// Add was successful.
})
.fail(function (errorObject) {
// Handle failure for any of the previous JSONStore operations (init, add).
});
回应
{"collection":{"name":"people","username":"carlos","searchFields":{"name":"string","age":"integer","_id":"number"},"additionalSearchFields":{},"promise":{}},"docs":[{"_id":1,"json":{"age":10,"name":"carlos"}}]}
如何检索加密数据?如果已通过使用用户名和密码保护集合进行加密。
参考文献
【问题讨论】:
标签: encryption ibm-mobilefirst jsonstore