[KeyManager] Implement JS get* methods
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Thu, 23 Apr 2015 12:31:22 +0000 (14:31 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 11 May 2015 11:56:51 +0000 (20:56 +0900)
[Verification]
New methods are available:
tizen.keymanager.getKey()
tizen.keymanager.getKeyAliasList()
tizen.keymanager.getCertificate()
tizen.keymanager.getCertificatesAliasList()
tizen.keymanager.getData()
tizen.keymanager.getDataAliasList()

Change-Id: I5d1d1b165fcb06b713a1080f2a0f5efc176c6e29
Signed-off-by: Przemyslaw Ciezkowski <p.ciezkowski@samsung.com>
src/keymanager/keymanager_api.js

index 10a69ef..698da82 100644 (file)
@@ -242,27 +242,97 @@ KeyManager.prototype.loadFromPKCS12File = function() {
 };
 
 KeyManager.prototype.getKey = function() {
-
+  var args = validator.validateArgs(arguments, [
+    {
+      name: "name",
+      type: validator.Types.STRING
+    },
+    {
+      name: "password",
+      type: validator.Types.STRING,
+      nullable: true,
+      optional: true
+    }
+  ]);
+  var ret = native.callSync('KeyManager_getKey', {
+    name: args.name,
+    password: args.password
+  });
+  if (native.isFailure(ret)) {
+    throw native.getErrorObject(ret);
+  }
+  var result = native.getResultObject(ret);
+  return new Key(result.name, result.password, result.extractable, result.keyType, result.rawKey);
 };
 
 KeyManager.prototype.getKeyAliasList = function() {
-
+  var ret = native.callSync('KeyManager_getKeyAliasList', {});
+  if (native.isFailure(ret)) {
+    throw native.getErrorObject(ret);
+  }
+  return native.getResultObject(ret);
 };
 
 KeyManager.prototype.getCertificate = function() {
-
+  var args = validator.validateArgs(arguments, [
+    {
+      name: "name",
+      type: validator.Types.STRING
+    },
+    {
+      name: "password",
+      type: validator.Types.STRING,
+      optional: true
+    }
+  ]);
+  var ret = native.callSync('KeyManager_getCertificate', {
+    name: args.name,
+    password: args.password
+  });
+  if (native.isFailure(ret)) {
+    throw native.getErrorObject(ret);
+  }
+  var result = native.getResultObject(ret);
+  return new Certificate(result.name, result.password, result.extractable, result.rawCert);
 };
 
 KeyManager.prototype.getCertificatesAliasList = function() {
-
+  var ret = native.callSync('KeyManager_getCertificatesAliasList', {});
+  if (native.isFailure(ret)) {
+    throw native.getErrorObject(ret);
+  }
+  return native.getResultObject(ret);
 };
 
 KeyManager.prototype.getData = function() {
-
+  var args = validator.validateArgs(arguments, [
+    {
+      name: "name",
+      type: validator.Types.STRING
+    },
+    {
+      name: "password",
+      type: validator.Types.STRING,
+      optional: true
+    }
+  ]);
+  var ret = native.callSync('KeyManager_getData', {
+    name: args.name,
+    password: args.password
+  });
+  if (native.isFailure(ret)) {
+    throw native.getErrorObject(ret);
+  }
+  var result = native.getResultObject(ret);
+  return new Data(result.name, result.password, result.extractable, result.rawData);
 };
 
 KeyManager.prototype.getDataAliasList = function() {
-
+  var ret = native.callSync('KeyManager_getDataAliasList', {});
+  if (native.isFailure(ret)) {
+    throw native.getErrorObject(ret);
+  }
+  return native.getResultObject(ret);
 };
 
 KeyManager.prototype.allowAccessControl = function() {
@@ -295,4 +365,4 @@ tizen.Data = function(name, password, extractable) {
 };
 tizen.Data.prototype = Object.create(Data.prototype);
 
-exports = new KeyManager();
\ No newline at end of file
+exports = new KeyManager();