NetNfcGDbusSecureElement *object;
GDBusMethodInvocation *invocation;
net_nfc_target_handle_s *handle;
+ guint se_type;
};
typedef struct _SeDataApdu SeDataApdu;
GDBusMethodInvocation *invocation;
net_nfc_target_handle_s *handle;
GVariant *data;
+ guint se_type;
};
typedef struct _SeSetPreferred SeSetPreferred;
return result;
}
-static bool _se_is_uicc_handle(net_nfc_target_handle_s * handle)
-{
- return (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL && (TapiHandle *) handle == gdbus_uicc_handle);
-}
/* LCOV_EXCL_STOP */
static void _se_uicc_close(net_nfc_target_handle_s * handle)
static void se_close_secure_element_thread_func(gpointer user_data)
{
SeDataHandle *detail = (SeDataHandle *) user_data;
- net_nfc_error_e result;
+ net_nfc_error_e result = NET_NFC_INVALID_HANDLE;
g_assert(detail != NULL);
g_assert(detail->object != NULL);
g_assert(detail->invocation != NULL);
- if (_se_is_uicc_handle(detail->handle) == true) {
- _se_uicc_close(detail->handle);
+ if(net_nfc_server_gdbus_check_client_context(g_dbus_method_invocation_get_sender(detail->invocation)) == true) {
+ if (detail->se_type == NET_NFC_SE_TYPE_UICC && gdbus_uicc_handle != NULL && gdbus_uicc_ready == SE_UICC_READY ) {
+ _se_uicc_close((net_nfc_target_handle_s *)gdbus_uicc_handle);
result = NET_NFC_OK;
- } else if (net_nfc_server_se_is_ese_handle(detail->handle) == true) {
+ } else if (detail->se_type == NET_NFC_SE_TYPE_ESE && gdbus_ese_handle != NULL ) {
/* decrease client reference count */
net_nfc_server_gdbus_decrease_se_count(g_dbus_method_invocation_get_sender(detail->invocation));
result = net_nfc_server_se_close_ese();
} else {
result = NET_NFC_INVALID_HANDLE;
+ }
}
net_nfc_gdbus_secure_element_complete_close_secure_element(detail->object, detail->invocation, result);
data->object = g_object_ref(object);
data->invocation = g_object_ref(invocation);
- data->handle = (net_nfc_target_handle_s *) (intptr_t)arg_handle;
+ data->se_type = arg_handle;
if (net_nfc_server_controller_async_queue_push_force(se_close_secure_element_thread_func, data) == FALSE) {
/* return error if queue was blocked */
static void se_get_atr_thread_func(gpointer user_data)
{
SeDataHandle *detail = (SeDataHandle *) user_data;
- net_nfc_error_e result = NET_NFC_OK;
+ net_nfc_error_e result = NET_NFC_INVALID_HANDLE;
data_s *atr = NULL;
GVariant *data;
g_assert(detail->object != NULL);
g_assert(detail->invocation != NULL);
- if (_se_is_uicc_handle(detail->handle) == true) {
- if (_se_uicc_get_atr(detail->handle, &atr) == true)
+ if(net_nfc_server_gdbus_check_client_context(g_dbus_method_invocation_get_sender(detail->invocation)) == true) {
+ if (detail->se_type == NET_NFC_SE_TYPE_UICC && gdbus_uicc_handle != NULL && gdbus_uicc_ready == SE_UICC_READY ) {
+ if (_se_uicc_get_atr((net_nfc_target_handle_s *)gdbus_uicc_handle, &atr) == true)
result = NET_NFC_OK;
else
result = NET_NFC_OPERATION_FAIL;
- } else if (net_nfc_server_se_is_ese_handle(detail->handle) == true) {
- net_nfc_controller_secure_element_get_atr(detail->handle, &atr, &result);
+ } else if (detail->se_type == NET_NFC_SE_TYPE_ESE && gdbus_ese_handle != NULL) {
+ net_nfc_controller_secure_element_get_atr(gdbus_ese_handle, &atr, &result);
} else {
DEBUG_ERR_MSG("invalid se handle");
result = NET_NFC_INVALID_HANDLE;
+ }
}
-
data = net_nfc_util_gdbus_data_to_variant(atr);
net_nfc_gdbus_secure_element_complete_get_atr(detail->object, detail->invocation, result, data);
data->object = g_object_ref(object);
data->invocation = g_object_ref(invocation);
- data->handle = (net_nfc_target_handle_s *) (intptr_t)arg_handle;
+ data->se_type = arg_handle;
if (net_nfc_server_controller_async_queue_push_force(se_get_atr_thread_func, data) == FALSE) {
/* return error if queue was blocked */
static void se_open_secure_element_thread_func(gpointer user_data)
{
SeDataSeType *detail = (SeDataSeType *) user_data;
+ // as handle is not used by client except to check NULL
+ // instead handle, pass se_type for further ese-communication
+ // all operation will be done in ese through gdbus_ese_handle/gdbus_uicc_handle which is static
net_nfc_target_handle_s *handle = NULL;
net_nfc_error_e result = NET_NFC_OK;
#ifdef ACCESS_CONTROL
END:
#endif
- net_nfc_gdbus_secure_element_complete_open_secure_element(detail->object, detail->invocation, result, (intptr_t) handle);
+ // As handle which is a pointer should not be exposed instead handle , passing se_type as handle is not required by ese-client app
+ net_nfc_gdbus_secure_element_complete_open_secure_element(detail->object, detail->invocation, result, detail->se_type);
g_object_unref(detail->invocation);
g_object_unref(detail->object);
g_assert(detail->invocation != NULL);
net_nfc_util_gdbus_variant_to_data_s(detail->data, &apdu_data);
-
- if (_se_is_uicc_handle(detail->handle) == true) {
- ret = _se_uicc_send_apdu(detail->handle, &apdu_data, &response);
+ if(net_nfc_server_gdbus_check_client_context(g_dbus_method_invocation_get_sender(detail->invocation)) == true) {
+ if (detail->se_type == NET_NFC_SE_TYPE_UICC && gdbus_uicc_handle != NULL && gdbus_uicc_ready == SE_UICC_READY ) {
+ ret = _se_uicc_send_apdu((net_nfc_target_handle_s *)gdbus_uicc_handle, &apdu_data, &response);
if (ret == false) {
DEBUG_ERR_MSG("_se_uicc_send_apdu failed");
} else {
result = NET_NFC_OK;
}
- } else if (net_nfc_server_se_is_ese_handle(detail->handle) == true) {
- ret = net_nfc_controller_secure_element_send_apdu(detail->handle, &apdu_data, &response, &result);
+ } else if (detail->se_type == NET_NFC_SE_TYPE_ESE && gdbus_ese_handle != NULL) {
+ ret = net_nfc_controller_secure_element_send_apdu(gdbus_ese_handle, &apdu_data, &response, &result);
} else {
- result = NET_NFC_INVALID_HANDLE;
+ result = NET_NFC_INVALID_HANDLE;
+ }
}
rspdata = net_nfc_util_gdbus_data_to_variant(response);
data->object = g_object_ref(object);
data->invocation = g_object_ref(invocation);
- data->handle = (net_nfc_target_handle_s *) (intptr_t)arg_handle;
data->data = g_variant_ref(apdudata);
+ data->se_type = arg_handle;
if (net_nfc_server_controller_async_queue_push_force(se_send_apdu_thread_func, data) == FALSE) {
/* return error if queue was blocked */