从 IBM MobileFirst 中的 JSONStore 检索加密数据
Retrieve Encrypted data from the JSONStore in IBM MobileFirst
我创建了一个 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"}}]}
如何找回加密数据?如果已经通过使用用户名和密码保护集合来进行加密。
参考资料
加密只是为了防止访问 JSONStore。
通过.init-ing它和用户名和密码,这意味着您已经成功访问它,因此您可以看到它里面的collection。
如果 .init 失败,您将根本无法检索开始的数据。
我创建了一个 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"}}]}
如何找回加密数据?如果已经通过使用用户名和密码保护集合来进行加密。
参考资料
加密只是为了防止访问 JSONStore。
通过.init-ing它和用户名和密码,这意味着您已经成功访问它,因此您可以看到它里面的collection。
如果 .init 失败,您将根本无法检索开始的数据。