[KeyManager] Implement JS loadFromPKCS12File
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Thu, 23 Apr 2015 12:19:37 +0000 (14:19 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 11 May 2015 11:56:25 +0000 (20:56 +0900)
[Verification]
tizen.keymanager.loadFromPKCS12File("documents/test.pem",
    "priv1", "cert", function() {}, function() {});

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

index 47d314c..10a69ef 100644 (file)
@@ -196,7 +196,49 @@ KeyManager.prototype.generateKeyPair = function() {
 };
 
 KeyManager.prototype.loadFromPKCS12File = function() {
+  var args = validator.validateArgs(arguments, [
+    {
+      name: 'fileURI',
+      type: validator.Types.STRING
+    },
+    {
+      name: 'privKeyName',
+      type: validator.Types.STRING
+    },
+    {
+      name: 'certificateName',
+      type: validator.Types.STRING
+    },
+    {
+      name: 'successCallback',
+      type: validator.Types.FUNCTION,
+      nullable: true
+    },
+    {
+      name: 'errorCallback',
+      type: validator.Types.FUNCTION,
+      optional: true,
+      nullable: true
+    },
+    {
+      name: 'password',
+      type: validator.Types.STRING,
+      optional: true
+    }
+  ]);
 
+  native.call('KeyManager_loadFromPKCS12File', {
+    fileURI: args.fileURI,
+    privKeyName: args.privKeyName,
+    certificateName: args.certificateName,
+    password: args.password ? args.password : null
+  }, function(msg) {
+    if (native.isFailure(msg)) {
+      native.callIfPossible(args.errorCallback, native.getErrorObject(msg));
+    } else {
+      native.callIfPossible(args.successCallback);
+    }
+  });
 };
 
 KeyManager.prototype.getKey = function() {