Added feature check for 3.0 83/111883/1 accepted/tizen/3.0/common/20170125.122053 accepted/tizen/3.0/ivi/20170125.083824 accepted/tizen/3.0/mobile/20170125.083719 accepted/tizen/3.0/wearable/20170125.083732 submit/tizen_3.0/20170125.072819
authorManasij Sur Roy <manasij.r@samsung.com>
Tue, 24 Jan 2017 11:57:41 +0000 (17:27 +0530)
committerManasij Sur Roy <manasij.r@samsung.com>
Tue, 24 Jan 2017 11:58:30 +0000 (17:28 +0530)
Change-Id: I17d9a480bba3168f4e08d3c375eedf2d651a48a5
Signed-off-by: Manasij Sur Roy <manasij.r@samsung.com>
client/fido_uaf_authenticator.c
client/fido_uaf_client.c
common/CMakeLists.txt
common/fido_uaf_utils.c
common/fido_uaf_utils.h [new file with mode: 0644]
packaging/fido-client.spec

index 2e81a7b..15fd894 100755 (executable)
 #include "fido_internal_types.h"
 #include "fido_uaf_authenticator.h"
 #include "fido_logs.h"
+#include "fido_uaf_utils.h"
 
 EXPORT_API int
 fido_authenticator_get_title(const fido_authenticator_h auth, char **title)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        RET_IF_FAIL(title != NULL, FIDO_ERROR_INVALID_PARAMETER);
@@ -38,6 +41,9 @@ fido_authenticator_get_title(const fido_authenticator_h auth, char **title)
 EXPORT_API int
 fido_authenticator_get_aaid(const fido_authenticator_h auth, char **aaid)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        RET_IF_FAIL(aaid != NULL, FIDO_ERROR_INVALID_PARAMETER);
@@ -54,6 +60,9 @@ fido_authenticator_get_aaid(const fido_authenticator_h auth, char **aaid)
 EXPORT_API int
 fido_authenticator_get_description(const fido_authenticator_h auth, char **desc)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        RET_IF_FAIL(desc != NULL, FIDO_ERROR_INVALID_PARAMETER);
@@ -70,6 +79,9 @@ fido_authenticator_get_description(const fido_authenticator_h auth, char **desc)
 EXPORT_API int
 fido_authenticator_get_assertion_scheme(const fido_authenticator_h auth, char **scheme)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        RET_IF_FAIL(scheme != NULL, FIDO_ERROR_INVALID_PARAMETER);
@@ -86,6 +98,9 @@ fido_authenticator_get_assertion_scheme(const fido_authenticator_h auth, char **
 EXPORT_API int
 fido_authenticator_get_algorithm(const fido_authenticator_h auth, fido_auth_algo_e *algo)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -99,6 +114,9 @@ EXPORT_API int
 fido_authenticator_foreach_attestation_type(const fido_authenticator_h auth, fido_attestation_type_cb cb,
 void *user_data)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -122,6 +140,9 @@ void *user_data)
 EXPORT_API int
 fido_authenticator_get_verification_method(const fido_authenticator_h auth, fido_auth_user_verify_type_e *user_verification)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -134,6 +155,9 @@ fido_authenticator_get_verification_method(const fido_authenticator_h auth, fido
 EXPORT_API int
 fido_authenticator_get_key_protection_method(const fido_authenticator_h auth, fido_auth_key_protection_type_e *key_protection)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -146,6 +170,9 @@ fido_authenticator_get_key_protection_method(const fido_authenticator_h auth, fi
 EXPORT_API int
 fido_authenticator_get_matcher_protection_method(const fido_authenticator_h auth, fido_auth_matcher_protection_type_e *matcher_protection)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -158,6 +185,9 @@ fido_authenticator_get_matcher_protection_method(const fido_authenticator_h auth
 EXPORT_API int
 fido_authenticator_get_attachment_hint(const fido_authenticator_h auth, fido_auth_attachment_hint_e *attachment_hint)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -170,6 +200,9 @@ fido_authenticator_get_attachment_hint(const fido_authenticator_h auth, fido_aut
 EXPORT_API bool
 fido_authenticator_get_is_second_factor_only(const fido_authenticator_h auth)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               false);
+
        RET_IF_FAIL(auth != NULL, false);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -180,6 +213,9 @@ fido_authenticator_get_is_second_factor_only(const fido_authenticator_h auth)
 EXPORT_API int
 fido_authenticator_get_tc_discplay(const fido_authenticator_h auth, fido_auth_tc_display_type_e *tc_display)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        fido_authenticator_s *priv = (fido_authenticator_s*)auth;
@@ -192,6 +228,9 @@ fido_authenticator_get_tc_discplay(const fido_authenticator_h auth, fido_auth_tc
 EXPORT_API int
 fido_authenticator_get_tc_display_type(const fido_authenticator_h auth, char **tc_display_content_type)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        RET_IF_FAIL(tc_display_content_type != NULL, FIDO_ERROR_INVALID_PARAMETER);
@@ -208,6 +247,9 @@ fido_authenticator_get_tc_display_type(const fido_authenticator_h auth, char **t
 EXPORT_API int
 fido_authenticator_get_icon(const fido_authenticator_h auth, char **icon)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED,
+                               FIDO_ERROR_NOT_SUPPORTED);
+
        RET_IF_FAIL(auth != NULL, FIDO_ERROR_INVALID_PARAMETER);
 
        RET_IF_FAIL(icon != NULL, FIDO_ERROR_INVALID_PARAMETER);
index 0bb7d38..72471dc 100755 (executable)
@@ -25,6 +25,7 @@
 #include "fido-stub.h"
 #include "fido_keys.h"
 #include "fido_uaf_authenticator.h"
+#include "fido_uaf_utils.h"
 
 static Fido *_fido_dbus_obj = NULL;
 
@@ -91,6 +92,10 @@ _fido_uaf_process_operation_reply(GObject *object, GAsyncResult *res, gpointer u
        }
 
        _fido_process_cb_data_s *cb_data = (_fido_process_cb_data_s *)user_data;
+       if (cb_data == NULL) {
+               _ERR("Can not proceed since callback data is NULL");
+               return;
+       }
 
        if (cb_data->cb == NULL) {
                _ERR("Can not proceed since callback data's cb part is NULL");
@@ -128,6 +133,8 @@ _fido_uaf_process_operation_reply(GObject *object, GAsyncResult *res, gpointer u
 EXPORT_API int
 fido_foreach_authenticator(fido_authenticator_cb callback, void *user_data)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        if (callback == NULL) {
                _ERR("callback can not be NULL [FIDO_ERROR_INVALID_PARAMETER]");
                return FIDO_ERROR_INVALID_PARAMETER;
@@ -205,6 +212,8 @@ fido_foreach_authenticator(fido_authenticator_cb callback, void *user_data)
 EXPORT_API int
 fido_get_client_vendor(char **vendor_name)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        if (vendor_name == NULL)
                return FIDO_ERROR_INVALID_PARAMETER;
 
@@ -219,6 +228,8 @@ fido_get_client_vendor(char **vendor_name)
 EXPORT_API int
 fido_get_client_version(int *client_major_version, int *client_minor_version)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        if ((client_major_version == NULL) || (client_minor_version == NULL))
                return FIDO_ERROR_INVALID_PARAMETER;
 
@@ -231,6 +242,8 @@ fido_get_client_version(int *client_major_version, int *client_minor_version)
 EXPORT_API int
 fido_uaf_is_supported(const char *uaf_message_json, bool *is_supported)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        if (uaf_message_json == NULL) {
                _ERR("uaf_message_json can not be NULL [FIDO_ERROR_INVALID_PARAMETER]");
                return FIDO_ERROR_INVALID_PARAMETER;
@@ -264,6 +277,8 @@ EXPORT_API int
 fido_uaf_get_response_message(const char *uaf_request_json, const char *channel_binding_json,
        fido_uaf_response_message_cb callback, void *user_data)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        if (callback == NULL) {
                _ERR("callback can not be NULL [FIDO_ERROR_INVALID_PARAMETER]");
                return FIDO_ERROR_INVALID_PARAMETER;
@@ -297,6 +312,8 @@ fido_uaf_get_response_message(const char *uaf_request_json, const char *channel_
 EXPORT_API int
 fido_uaf_set_server_result(int response_code, const char *uaf_response_json)
 {
+       RET_IF_FAIL(is_fido_supported() == FEATURE_STATE_ENABLED, FIDO_ERROR_NOT_SUPPORTED);
+
        if (uaf_response_json == NULL) {
                _ERR("uaf_response_json can not be NULL [FIDO_ERROR_INVALID_PARAMETER]");
                return FIDO_ERROR_INVALID_PARAMETER;
index 4770bc2..9d14991 100644 (file)
@@ -18,6 +18,7 @@ pkg_check_modules(FIDO_COMMON_PKGS REQUIRED
                gio-unix-2.0
                gobject-2.0
                capi-base-common
+               capi-system-info
                json-glib-1.0
                openssl
 )
index 7bd7d3d..5aade38 100644 (file)
 
 #include <string.h>
 #include <stdlib.h>
+#include <system_info.h>
 #include "fido_logs.h"
 #include "fido_internal_types.h"
+#include "fido_uaf_utils.h"
+
+#define FEATURE_FIDO "http://tizen.org/feature/fido.uaf"
+
+static feature_state feature_supported_val = FEATURE_STATE_INVALID;
+
+feature_state
+is_fido_supported(void)
+{
+       if (feature_supported_val != FEATURE_STATE_INVALID)
+               return feature_supported_val;
+
+       bool feature_supported = false;
+       system_info_get_platform_bool(FEATURE_FIDO, &feature_supported);
+
+       feature_supported_val = feature_supported ?
+                               FEATURE_STATE_ENABLED : FEATURE_STATE_DISABLED;
+
+       return feature_supported_val;
+}
 
 void
 _free_extension(_extension_t *data)
diff --git a/common/fido_uaf_utils.h b/common/fido_uaf_utils.h
new file mode 100644 (file)
index 0000000..acd2673
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef FIDO_UAF_UTILS_H
+#define FIDO_UAF_UTILS_H
+
+typedef enum {
+       FEATURE_STATE_INVALID = -1,
+       FEATURE_STATE_DISABLED,
+       FEATURE_STATE_ENABLED
+} feature_state;
+
+feature_state is_fido_supported(void);
+
+#endif // FIDO_UAF_UTILS_H
index 1b573e8..a42c63c 100644 (file)
@@ -21,6 +21,7 @@ BuildRequires:  cmake
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(glib-2.0) >= 2.26
 BuildRequires:  pkgconfig(gio-unix-2.0)