[KeyManager] Plugin stubs
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Thu, 23 Apr 2015 10:46:30 +0000 (12:46 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 8 May 2015 12:51:30 +0000 (21:51 +0900)
[Verification]
New namespace:
tizen.keymanager
New constructors:
tizen.Key
tizen.Certificate
tizen.Data

Change-Id: I1390feda269f80107b87453cc4cd74dce2f4a7b2
Signed-off-by: Przemyslaw Ciezkowski <p.ciezkowski@samsung.com>
packaging/webapi-plugins.spec
src/keymanager/keymanager.gyp [new file with mode: 0644]
src/keymanager/keymanager_api.js [new file with mode: 0644]
src/keymanager/keymanager_extension.cc [new file with mode: 0644]
src/keymanager/keymanager_extension.h [new file with mode: 0644]
src/keymanager/keymanager_instance.cc [new file with mode: 0644]
src/keymanager/keymanager_instance.h [new file with mode: 0644]
src/tizen-wrt.gyp

index b511cb3..12752d8 100755 (executable)
@@ -48,6 +48,7 @@ Source0:    %{name}-%{version}.tar.gz
 %define tizen_feature_fm_radio_support            1
 %endif
 %define tizen_feature_ham_support                 0
+%define tizen_feature_key_manager_support         1
 %define tizen_feature_media_controller_support    1
 %ifarch %{arm}
 # ARM
@@ -164,7 +165,7 @@ Source0:    %{name}-%{version}.tar.gz
 # I586
 %define tizen_feature_media_key_support           0
 %endif
-
+%define tizen_feature_key_manager_support         0
 %define tizen_feature_message_port_support        1
 %define tizen_feature_messaging_support           0
 
@@ -241,6 +242,7 @@ Source0:    %{name}-%{version}.tar.gz
 %define tizen_feature_filesystem_support          1
 %define tizen_feature_fm_radio_support            0
 %define tizen_feature_ham_support                 0
+%define tizen_feature_key_manager_support         0
 %define tizen_feature_media_controller_support    0
 %define tizen_feature_media_key_support           0
 %define tizen_feature_message_port_support        1
@@ -342,6 +344,10 @@ BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(push)
 %endif
 
+%if 0%{?tizen_feature_key_manager_support}
+BuildRequires: pkgconfig(key-manager)
+%endif
+
 %if 0%{?tizen_feature_media_controller_support}
 BuildRequires: pkgconfig(capi-media-controller)
 %endif
@@ -453,6 +459,7 @@ GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_exif_support=%{?tizen_feature_exif_sup
 GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_filesystem_support=%{?tizen_feature_filesystem_support}"
 GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_fm_radio_support=%{?tizen_feature_fm_radio_support}"
 GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_ham_support=%{?tizen_feature_ham_support}"
+GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_key_manager_support=%{?tizen_feature_key_manager_support}"
 GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_media_controller_support=%{?tizen_feature_media_controller_support}"
 GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_media_key_support=%{?tizen_feature_media_key_support}"
 GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_message_port_support=%{?tizen_feature_message_port_support}"
diff --git a/src/keymanager/keymanager.gyp b/src/keymanager/keymanager.gyp
new file mode 100644 (file)
index 0000000..99ae7ff
--- /dev/null
@@ -0,0 +1,30 @@
+{
+  'includes':[
+    '../common/common.gypi',
+  ],
+  'targets': [
+    {
+      'target_name': 'tizen_keymanager',
+      'type': 'loadable_module',
+      'dependencies': [
+        '../common/common.gyp:tizen_common',
+      ],
+      'sources': [
+        'keymanager_api.js',
+        'keymanager_extension.cc',
+        'keymanager_extension.h',
+        'keymanager_instance.cc',
+        'keymanager_instance.h',
+      ],
+      'conditions': [
+        ['tizen == 1', {
+          'variables': {
+            'packages': [
+              'key-manager',
+            ]
+          },
+        }],
+      ],
+    },
+  ],
+}
diff --git a/src/keymanager/keymanager_api.js b/src/keymanager/keymanager_api.js
new file mode 100644 (file)
index 0000000..0ff1388
--- /dev/null
@@ -0,0 +1,180 @@
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var validator = xwalk.utils.validator;
+var converter = xwalk.utils.converter;
+
+var KeyType = {
+  "KEY_NONE": "KEY_NONE",
+  "KEY_RSA_PUBLIC": "KEY_RSA_PUBLIC",
+  "KEY_RSA_PRIVATE": "KEY_RSA_PRIVATE",
+  "KEY_ECDSA_PUBLIC": "KEY_ECDSA_PUBLIC",
+  "KEY_ECDSA_PRIVATE": "KEY_ECDSA_PRIVATE",
+  "KEY_DSA_PUBLIC": "KEY_DSA_PUBLIC",
+  "KEY_DSA_PRIVATE": "KEY_DSA_PRIVATE",
+  "KEY_AES": "KEY_AES"
+};
+
+function Key(name, password, extractable, keyType, rawKey) {
+  Object.defineProperties(this, {
+    name: {
+      value: converter.toString(name),
+      enumerable: true
+    },
+    password: {
+      value: password ? converter.toString(password) : null,
+      enumerable: true
+    },
+    extractable: {
+      value: !!extractable,//make sure it is boolean
+      enumerable: true
+    },
+    keyType: {
+      value: KeyType.hasOwnProperty(keyType) ? keyType : KeyType.KEY_NONE,
+      enumerable: true
+    },
+    rawKey: {
+      value: converter.toString(rawKey),
+      enumerable: true
+    }
+  });
+}
+
+Key.prototype.save = function() {
+
+};
+
+Key.prototype.remove = function() {
+
+};
+
+function Certificate(name, password, extractable, rawCert) {
+  Object.defineProperties(this, {
+    name: {
+      value: converter.toString(name),
+      enumerable: true
+    },
+    password: {
+      value: password ? converter.toString(password) : null,
+      enumerable: true
+    },
+    extractable: {
+      value: !!extractable,//make sure it is boolean
+      enumerable: true
+    },
+    rawCert: {
+      value: rawCert ? converter.toString(rawCert) : "",
+      enumerable: true
+    }
+  });
+}
+
+Certificate.prototype.save = function() {
+
+};
+
+Certificate.prototype.loadFromFile = function() {
+
+};
+
+Certificate.prototype.remove = function() {
+
+};
+
+function Data(name, password, extractable, rawData) {
+  Object.defineProperties(this, {
+    name: {
+      value: converter.toString(name),
+      enumerable: true
+    },
+    password: {
+      value: password ? converter.toString(password) : null,
+      enumerable: true
+    },
+    extractable: {
+      value: !!extractable,//make sure it is boolean
+      enumerable: true
+    },
+    rawData: {
+      value: rawData ? converter.toString(rawData) : "",
+      enumerable: true
+    }
+  });
+}
+
+Data.prototype.save = function() {
+
+};
+
+Data.prototype.remove = function() {
+
+};
+
+function KeyManager() {
+
+}
+
+KeyManager.prototype.generateKeyPair = function() {
+
+};
+
+KeyManager.prototype.loadFromPKCS12File = function() {
+
+};
+
+KeyManager.prototype.getKey = function() {
+
+};
+
+KeyManager.prototype.getKeyAliasList = function() {
+
+};
+
+KeyManager.prototype.getCertificate = function() {
+
+};
+
+KeyManager.prototype.getCertificatesAliasList = function() {
+
+};
+
+KeyManager.prototype.getData = function() {
+
+};
+
+KeyManager.prototype.getDataAliasList = function() {
+
+};
+
+KeyManager.prototype.allowAccessControl = function() {
+
+};
+
+KeyManager.prototype.denyAccessControl = function() {
+
+};
+
+KeyManager.prototype.createSignature = function() {
+
+};
+
+KeyManager.prototype.verifySignature = function() {
+
+};
+
+// expose only basic constructors
+tizen.Key = function(name, password, extractable) {
+    Key.call(this, name, password, extractable, KeyType.KEY_NONE, "");
+};
+tizen.Key.prototype = Object.create(Key.prototype);
+tizen.Certificate = function(name, password, extractable) {
+    Certificate.call(this, name, password, extractable, "");
+};
+tizen.Certificate.prototype = Object.create(Certificate.prototype);
+tizen.Data = function(name, password, extractable) {
+    Data.call(this, name, password, extractable, "");
+};
+tizen.Data.prototype = Object.create(Data.prototype);
+
+exports = new KeyManager();
\ No newline at end of file
diff --git a/src/keymanager/keymanager_extension.cc b/src/keymanager/keymanager_extension.cc
new file mode 100644 (file)
index 0000000..2354467
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "keymanager/keymanager_extension.h"
+
+#include "keymanager/keymanager_instance.h"
+
+namespace {
+const char* kKey = "tizen.Key";
+const char* kData = "tizen.Data";
+const char* kCertificate = "tizen.Certificate";
+}
+
+// This will be generated from keymanager_api.js
+extern const char kSource_keymanager_api[];
+
+common::Extension* CreateExtension() {
+  return new KeyManagerExtension;
+}
+
+KeyManagerExtension::KeyManagerExtension() {
+  SetExtensionName("tizen.keymanager");
+  SetJavaScriptAPI(kSource_keymanager_api);
+  const char* entry_points[] = {
+      kKey,
+      kData,
+      kCertificate,
+      NULL
+  };
+  SetExtraJSEntryPoints(entry_points);
+}
+
+KeyManagerExtension::~KeyManagerExtension() {}
+
+common::Instance* KeyManagerExtension::CreateInstance() {
+  return new extension::keymanager::KeyManagerInstance;
+}
diff --git a/src/keymanager/keymanager_extension.h b/src/keymanager/keymanager_extension.h
new file mode 100644 (file)
index 0000000..483799e
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef KEYMANAGER_KEYMANAGER_EXTENSION_H_
+#define KEYMANAGER_KEYMANAGER_EXTENSION_H_
+
+#include "common/extension.h"
+
+class KeyManagerExtension : public common::Extension {
+ public:
+  KeyManagerExtension();
+  virtual ~KeyManagerExtension();
+
+ private:
+  virtual common::Instance* CreateInstance();
+};
+
+#endif  // KEYMANAGER_KEYMANAGER_EXTENSION_H_
diff --git a/src/keymanager/keymanager_instance.cc b/src/keymanager/keymanager_instance.cc
new file mode 100644 (file)
index 0000000..090fb92
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "keymanager/keymanager_instance.h"
+
+#include <functional>
+
+#include "common/logger.h"
+#include "common/picojson.h"
+#include "common/platform_result.h"
+
+namespace extension {
+namespace keymanager {
+
+
+KeyManagerInstance::KeyManagerInstance() {
+  using namespace std::placeholders;
+
+}
+
+KeyManagerInstance::~KeyManagerInstance() {
+}
+
+} // namespace keymanager
+} // namespace extension
diff --git a/src/keymanager/keymanager_instance.h b/src/keymanager/keymanager_instance.h
new file mode 100644 (file)
index 0000000..2a67e02
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef KEYMANAGER_KEYMANAGER_INSTANCE_H_
+#define KEYMANAGER_KEYMANAGER_INSTANCE_H_
+
+#include "common/extension.h"
+
+namespace extension {
+namespace keymanager {
+
+class KeyManagerInstance : public common::ParsedInstance {
+ public:
+  KeyManagerInstance();
+  virtual ~KeyManagerInstance();
+ private:
+};
+
+} // namespace keymanager
+} // namespace extension
+
+#endif // KEYMANAGER_KEYMANAGER_INSTANCE_H_
index 1cc576b..2c434dd 100755 (executable)
           },
         ],
         [
+          'tizen_feature_key_manager_support==1', {
+            'dependencies': [
+              'keymanager/keymanager.gyp:*',
+            ],
+          },
+        ],
+        [
           'tizen_feature_media_controller_support==1', {
             'dependencies': [
               'mediacontroller/mediacontroller.gyp:*',