Added config CAPI to set eap private-key information. 59/186059/3
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 6 Aug 2018 11:19:07 +0000 (16:49 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Thu, 23 Aug 2018 10:32:22 +0000 (16:02 +0530)
Change-Id: Ief31411700e49cf4e22f06e3ad96edf795d5b48c
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/network_interface.h
include/wifi_internal.h
src/network_dbus.c
src/wifi_config.c
test/wifi_manager_test.c

index 58e646c..35c4d78 100755 (executable)
@@ -240,6 +240,7 @@ typedef struct {
 typedef struct {
        gchar *ca_cert;
        gchar *private_key;
+       gchar *private_key_password;
        gchar *client_cert;
        gchar *anonymous_identity;
        gchar *identity;
index b0857cc..f8bcf51 100755 (executable)
@@ -51,6 +51,7 @@ extern "C" {
 #define WIFI_CONFIG_EAP_CACERT                         "CACertFile"
 #define WIFI_CONFIG_EAP_CLIENTCERT                     "ClientCertFile"
 #define WIFI_CONFIG_EAP_PRIVATEKEY                     "PrivateKeyFile"
+#define WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD            "PrivateKeyPassword"
 #define WIFI_CONFIG_EAP_IDENTITY                       "Identity"
 #define WIFI_CONFIG_EAP_TYPE                           "EapType"
 #define WIFI_CONFIG_EAP_AUTH_TYPE                      "EapAuthType"
@@ -148,6 +149,7 @@ typedef struct {
 typedef struct {
        gchar *ca_cert;
        gchar *private_key;
+       gchar *private_key_password;
        gchar *client_cert;
        gchar *anonymous_identity;
        gchar *identity;
index 0d2caf6..2e8b5e6 100755 (executable)
@@ -2888,6 +2888,8 @@ int _net_dbus_config_save_eap_configurations(const gchar *config_id,
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string(eap_config->client_cert));
                if (eap_config->private_key != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string(eap_config->private_key));
+               if (eap_config->private_key_password != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD, g_variant_new_string(eap_config->private_key_password));
                if (eap_config->identity != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string(eap_config->identity));
                if (eap_config->subject_match != NULL)
index 2d3884c..a8e195b 100755 (executable)
@@ -563,6 +563,29 @@ EXPORT_API int wifi_manager_config_set_eap_client_cert_file(wifi_manager_config_
        return WIFI_MANAGER_ERROR_NONE;
 }
 
+EXPORT_API int wifi_manager_config_set_eap_private_key_info(wifi_manager_config_h config,
+               const char *file, const char *password)
+{
+       __NETWORK_CAPI_FUNC_ENTER__;
+
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       wifi_config_s *h = (wifi_config_s *)config;
+
+       if (_wifi_check_config_validity(config) == false || h->eap_config == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       h->eap_config->private_key = g_strdup(file);
+       h->eap_config->private_key_password = g_strdup(password);
+
+       __NETWORK_CAPI_FUNC_EXIT__;
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
 EXPORT_API int wifi_manager_config_get_eap_identity(wifi_manager_config_h config, char **identity)
 {
        __NETWORK_CAPI_FUNC_ENTER__;
index 5a11b14..ca2b692 100755 (executable)
@@ -2128,6 +2128,7 @@ int test_wifi_manager_config_save(void)
                char anonymous[100] = { 0, };
                char ca_cert[100] = { 0, };
                char private_key[100] = { 0, };
+               char private_key_password[100] = { 0, };
                char client_cert[100] = { 0, };
                char eap_identity[100] = { 0, };
                int eap_type;
@@ -2163,6 +2164,15 @@ int test_wifi_manager_config_save(void)
                        rv = wifi_manager_config_set_eap_type(config, eap_type);
                        if (rv != WIFI_MANAGER_ERROR_NONE)
                        return -1;
+
+                       if (eap_type == 1) {
+                               if (test_get_user_string("EAP private key file - ", private_key, 99) &&
+                                               test_get_user_string("EAP private-key password - ", private_key_password, 99)) {
+                                       rv = wifi_manager_config_set_eap_private_key_info(config, private_key, private_key_password);
+                                       if (rv != WIFI_MANAGER_ERROR_NONE)
+                                               return -1;
+                               }
+                       }
                }
 
                if (test_get_user_int("EAP auth type (None(0), PAP(1), MSCHAP(2), MSCHAPv2(3), GTC(4), MD5(5)) - (Enter for skip): ", &eap_auth_type)) {