build-aux
*dbus*gen*
src/daemon/gsignond
-test/db/testdb
+test/db/dbtest
test/passwordplugin/passwordplugintest
stamp-h1
*service
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _GSIGNOND_PLUGIN_LOADER_H_
+#define _GSIGNOND_PLUGIN_LOADER_H_
+
+#include <gsignond/gsignond-plugin-interface.h>
+#include <gsignond/gsignond-config.h>
+
+G_BEGIN_DECLS
+
+GSignondPlugin*
+gsignond_load_plugin(GSignondConfig* config, gchar* plugin_type);
+
+G_END_DECLS
+
+#endif /* _GSIGNOND_PLUGIN_LOADER_H_ */
\ No newline at end of file
gsignond-plugin-interface.c \
gsignond-dictionary.c \
gsignond-session-data.c \
+ gsignond-plugin-loader.c \
$(NULL)
CLEANFILES =
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+
+#include "gsignond/gsignond-plugin-loader.h"
+#include "gsignond/gsignond-log.h"
+#include <gmodule.h>
+
+GSignondPlugin*
+gsignond_load_plugin(GSignondConfig* config, gchar* plugin_type)
+{
+ gchar* plugin_filename = g_module_build_path (
+ gsignond_config_get_string (config,
+ GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR),
+ plugin_type);
+ DBG("Loading plugin %s", plugin_filename);
+ GModule* plugin_module = g_module_open (plugin_filename,
+ G_MODULE_BIND_LOCAL);
+ g_free(plugin_filename);
+ if (plugin_module == NULL) {
+ DBG("Plugin couldn't be opened");
+ return;
+ }
+
+ gchar* plugin_get_type = g_strdup_printf("gsignond_%s_plugin_get_type",
+ plugin_type);
+ GType (*plugin_get_type_f)(void);
+ DBG("Resolving symbol %s", plugin_get_type);
+ gboolean symfound = g_module_symbol (plugin_module,
+ plugin_get_type, &plugin_get_type_f);
+ g_free(plugin_get_type);
+ g_module_close (plugin_module);
+ if (!symfound) {
+ DBG("Symbol couldn't be resolved");
+ return NULL;
+ }
+
+ DBG("Creating plugin object");
+ GSignondPlugin* plugin = g_object_new(plugin_get_type_f(), NULL);
+ if (plugin == NULL) {
+ DBG("Plugin couldn't be created");
+ return NULL;
+ }
+
+ return plugin;
+}
include $(top_srcdir)/common.mk
-plugins_LTLIBRARIES = libpasswordplugin.la
+plugins_LTLIBRARIES = libpassword.la
NULL=
-libpasswordplugin_la_CPPFLAGS = \
+libpassword_la_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/include \
$(GSIGNOND_CFLAGS) \
$(NULL)
-libpasswordplugin_la_LIBADD = \
+libpassword_la_LIBADD = \
$(top_builddir)/src/common/libgsignond-common.la \
$(GSIGNOND_LIBS) \
$(NULL)
-libpasswordplugin_la_SOURCES = \
+libpassword_la_SOURCES = \
gsignond-password-plugin.c \
$(NULL)
TESTS = passwordplugintest
+TESTS_ENVIRONMENT= SSO_PLUGINS_DIR=$(top_builddir)/src/plugins/password/.libs
+
check_PROGRAMS = passwordplugintest
passwordplugintest_SOURCES = passwordplugintest.c
passwordplugintest_CFLAGS = \
passwordplugintest_LDADD = \
$(top_builddir)/src/common/libgsignond-common.la \
- $(top_builddir)/src/plugins/password/libpasswordplugin.la \
+ $(top_builddir)/src/plugins/password/libpassword.la \
$(GSIGNOND_LIBS) \
- $(CHECK_LIBS)
\ No newline at end of file
+ $(CHECK_LIBS)
#include <gsignond/gsignond-session-data.h>
#include <gsignond/gsignond-plugin-interface.h>
#include <gsignond/gsignond-error.h>
-
+#include <gsignond/gsignond-plugin-loader.h>
+#include <gsignond/gsignond-config.h>
START_TEST (test_session_data)
{
}
END_TEST
-START_TEST (test_passwordplugin_create)
+static void check_plugin(GSignondPlugin* plugin)
{
- gpointer plugin;
gchar* type;
gchar** mechanisms;
-
- plugin = g_object_new(GSIGNOND_TYPE_PASSWORD_PLUGIN, NULL);
+
fail_if(plugin == NULL);
g_object_get(plugin, "type", &type, "mechanisms", &mechanisms, NULL);
g_free(type);
g_strfreev(mechanisms);
+}
+
+START_TEST (test_passwordplugin_create)
+{
+ gpointer plugin;
+
+ plugin = g_object_new(GSIGNOND_TYPE_PASSWORD_PLUGIN, NULL);
+ check_plugin(plugin);
g_object_unref(plugin);
}
END_TEST
}
END_TEST
+START_TEST (test_passwordplugin_loader)
+{
+ GSignondConfig* config = gsignond_config_new();
+ fail_if(config == NULL);
+
+ GSignondPlugin* absent_plugin = gsignond_load_plugin(config, "absentplugin");
+ fail_if(absent_plugin != NULL);
+
+ GSignondPlugin* plugin = gsignond_load_plugin(config, "password");
+ check_plugin(plugin);
+
+ g_object_unref(plugin);
+ g_object_unref(config);
+}
+END_TEST
Suite* passwordplugin_suite (void)
{
tcase_add_test (tc_core, test_passwordplugin_process);
tcase_add_test (tc_core, test_passwordplugin_user_action_finished);
tcase_add_test (tc_core, test_passwordplugin_refresh);
+ tcase_add_test (tc_core, test_passwordplugin_loader);
suite_add_tcase (s, tc_core);
return s;
}
srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
-
\ No newline at end of file
+