gboolean
gkd_login_unlock (const gchar *master)
{
	GP11Module *module;
	gboolean result;

	/* We don't support null or empty master passwords */
	if (!master || !master[0])
		return FALSE;

	module = module_instance ();

	result = unlock_or_create_login (module, master);
	if (result == TRUE)
		init_pin_for_uninitialized_slots (module, master);

	g_object_unref (module);
	return result;
}
예제 #2
0
	/**
	 * \brief Loads a module into the context.
	 *
	 * After unloading an existing module occupying Modules role, load()
	 * tries to construct a new module of the given type by passing the current
	 * context followed by the given parameters to its constructor.
	 *
	 * \tparam Module the type of module to be loaded.
	 *
	 * \return \c true if the new module as been loaded successfully
	 * \return \c false in case the existing modules \ref module_base::on_unload() "on_unload handler" refused to unload.
	 */
	template<typename Module, typename... Args> bool load(Args&&... params) {
		const detail::context_implementation::module_key_type key =
			detail::context_implementation::module_key<Module>();

		if (impl->unload_module(key)) {
			typedef typename module_default_implementation<Module>::type module_implementation_type;
			detail::context_implementation::module_value_type module_instance(new module_implementation_type(*this, std::forward<Args>(params)...));
			try {
				impl->load_module(key, module_instance);
			}
			catch(...) {
				delete module_instance;
				throw;
			}
			return true;
		}
		else {
			return false;
		}
	}
gboolean
gkd_login_change_lock (const gchar *original, const gchar *master)
{
	GP11Module *module;
	gboolean result;

	/* We don't support null or empty master passwords */
	if (!master || !master[0])
		return FALSE;
	if (original == NULL)
		original = "";

	module = module_instance ();

	result = change_or_create_login (module, original, master);
	if (result == TRUE)
		set_pin_for_any_slots (module, original, master);

	g_object_unref (module);
	return result;
}