From: Przemyslaw Ciezkowski
Date: Thu, 23 Apr 2015 10:46:30 +0000 (+0200)
Subject: [KeyManager] Plugin stubs
X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~64
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca8adb780debeedc2b8f16fcfe15c256a197c27e;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[KeyManager] Plugin stubs
[Verification]
New namespace:
tizen.keymanager
New constructors:
tizen.Key
tizen.Certificate
tizen.Data
Change-Id: I1390feda269f80107b87453cc4cd74dce2f4a7b2
Signed-off-by: Przemyslaw Ciezkowski
---
diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec
index b511cb36..12752d8d 100755
--- a/packaging/webapi-plugins.spec
+++ b/packaging/webapi-plugins.spec
@@ -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
index 00000000..99ae7ffc
--- /dev/null
+++ b/src/keymanager/keymanager.gyp
@@ -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
index 00000000..0ff1388f
--- /dev/null
+++ b/src/keymanager/keymanager_api.js
@@ -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
index 00000000..23544674
--- /dev/null
+++ b/src/keymanager/keymanager_extension.cc
@@ -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
index 00000000..483799ef
--- /dev/null
+++ b/src/keymanager/keymanager_extension.h
@@ -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
index 00000000..090fb92f
--- /dev/null
+++ b/src/keymanager/keymanager_instance.cc
@@ -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
+
+#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
index 00000000..2a67e028
--- /dev/null
+++ b/src/keymanager/keymanager_instance.h
@@ -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_
diff --git a/src/tizen-wrt.gyp b/src/tizen-wrt.gyp
index 1cc576b0..2c434dd0 100755
--- a/src/tizen-wrt.gyp
+++ b/src/tizen-wrt.gyp
@@ -132,6 +132,13 @@
],
},
],
+ [
+ 'tizen_feature_key_manager_support==1', {
+ 'dependencies': [
+ 'keymanager/keymanager.gyp:*',
+ ],
+ },
+ ],
[
'tizen_feature_media_controller_support==1', {
'dependencies': [