简体   繁体   English

从IBM MobileFirst中的JSONStore检索加密的数据

[英]Retrieve Encrypted data from the JSONStore in IBM MobileFirst

I have created a JSONStore and trying to encrypt the data inside the collection. 我创建了一个JSONStore并试图收集里面的数据进行加密。 My understanding is that AES encryption is done by securing the collection with a username and password; 我的理解是,AES加密是通过使用用户名和密码保护集合来完成的。 I successfully did that by setting localKeyGen : true . 我通过设置localKeyGen : true成功地做到了这localKeyGen : true

However I am still getting the plain text as the response. 但是我仍然得到了纯文本作为响应。

JSONStore 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).
});

Response 响应

{"collection":{"name":"people","username":"carlos","searchFields":{"name":"string","age":"integer","_id":"number"},"additionalSearchFields":{},"promise":{}},"docs":[{"_id":1,"json":{"age":10,"name":"carlos"}}]}

How can i retrieve the encrypted data? 如何获取加密数据? if the encryption is already happening by securing the collection with a username and password. 如果已经通过使用用户名和密码保护集合的安全性来进行加密。

References 参考

The encryption is meant only to prevent access to the JSONStore. 加密仅用于防止访问JSONStore。

By .init-ing it with the username and password, this means you have successfully accessed it and you are thus able to see the collection inside it. 通过使用用户名和密码对它进行初始化,这意味着您已经成功访问​​了它,因此可以看到其中的集合。

Had the .init failed, you would not be able at all to retrieve the data to begin with. 如果.init失败,则您将根本无法检索数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM