Commit 4d31658d authored by Alexander Kanavin's avatar Alexander Kanavin

Initial commit: standalone copy of the password plugin

parents
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache
build-aux
config.*
configure
libtool
m4
.deps
.libs
stamp-h1
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src test
\ No newline at end of file
#!/bin/sh -e
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
aclocal #-I m4
autoheader
libtoolize --copy --force
autoconf
automake --add-missing --copy
autoreconf --install --force
. $srcdir/configure "$@"
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.60])
AC_INIT([gsignond-plugin-sasl], [0.1], [])
AC_CONFIG_SRCDIR([src/gsignond-sasl-plugin.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 -Wall nostdinc silent-rules subdir-objects])
# Checks for programs.
AC_PROG_CC
AM_PROG_AR
#libtool
LT_PREREQ([2.2])
LT_INIT([disable-static])
# Checks for libraries.
PKG_CHECK_MODULES([GSIGNON],
[glib-2.0 >= 2.30
gsignond
libgsasl])
AC_SUBST(GSIGNON_CFLAGS)
AC_SUBST(GSIGNON_LIBS)
# AM_PATH_CHECK() is deprecated, but check documentation fails to tell that :-/
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
AC_SUBST(CHECK_CFLAGS)
AC_SUBST(CHECK_LIBS)
PLUGINSDIR=`pkg-config gsignond --variable=pluginsdir`
AC_SUBST(PLUGINSDIR)
EXTENSIONSDIR=`pkg-config gsignond --variable=extensionsdir`
AC_SUBST(EXTENSIONSDIR)
AC_OUTPUT([
Makefile
src/Makefile
test/Makefile
])
extensionsdir = $(EXTENSIONSDIR)
pluginsdir = $(PLUGINSDIR)
plugins_LTLIBRARIES = libsasl.la
NULL=
libsasl_la_CPPFLAGS = \
$(GSIGNON_CFLAGS) \
$(NULL)
libsasl_la_LIBADD = \
$(GSIGNON_LIBS) \
$(NULL)
libsasl_la_SOURCES = \
gsignond-sasl-plugin.c \
$(NULL)
CLEANFILES =
/* 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-interface.h>
#include "gsignond-sasl-plugin.h"
#include <gsignond/gsignond-error.h>
static void gsignond_plugin_interface_init (GSignondPluginInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GSignondPasswordPlugin, gsignond_password_plugin,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GSIGNOND_TYPE_PLUGIN,
gsignond_plugin_interface_init));
static void gsignond_password_plugin_cancel (GSignondPlugin *self)
{
GError* error = g_error_new(GSIGNOND_ERROR,
GSIGNOND_ERROR_SESSION_CANCELED,
"Session canceled");
gsignond_plugin_error (self, error);
g_error_free(error);
}
static void gsignond_password_plugin_abort (GSignondPlugin *self)
{
}
static void gsignond_password_plugin_request (
GSignondPlugin *self, GSignondSessionData *session_data)
{
}
static void gsignond_password_plugin_request_initial (
GSignondPlugin *self, GSignondSessionData *session_data,
const gchar *mechanism)
{
const gchar* username = gsignond_session_data_get_username(session_data);
const gchar* secret = gsignond_session_data_get_secret(session_data);
if (secret != NULL) {
GSignondSessionData *response = gsignond_dictionary_new();
if (username != NULL)
gsignond_session_data_set_username(response, username);
gsignond_session_data_set_secret(response, secret);
gsignond_plugin_response_final(self, response);
gsignond_dictionary_free(response);
return;
}
GSignondSessionData *user_action_data = gsignond_dictionary_new();
if (username == NULL)
gsignond_session_data_set_query_username(user_action_data, TRUE);
else
gsignond_session_data_set_username(user_action_data, username);
gsignond_session_data_set_query_password(user_action_data, TRUE);
gsignond_plugin_user_action_required(self, user_action_data);
gsignond_dictionary_free(user_action_data);
}
static void gsignond_password_plugin_user_action_finished (
GSignondPlugin *self,
GSignondSessionData *session_data)
{
GSignondQueryError query_error = gsignond_session_data_get_query_error(
session_data);
const gchar* username = gsignond_session_data_get_username(session_data);
const gchar* secret = gsignond_session_data_get_secret(session_data);
if (query_error == GSIGNOND_QUERY_ERROR_NONE &&
username != NULL &&
secret != NULL) {
GSignondSessionData *response = gsignond_dictionary_new();
gsignond_session_data_set_username(response, username);
gsignond_session_data_set_secret(response, secret);
gsignond_plugin_response_final(self, response);
gsignond_dictionary_free(response);
return;
} else if (query_error == GSIGNOND_QUERY_ERROR_CANCELED) {
GError* error = g_error_new(GSIGNOND_ERROR,
GSIGNOND_ERROR_SESSION_CANCELED,
"Session canceled");
gsignond_plugin_error (self, error);
g_error_free(error);
} else {
GError* error = g_error_new(GSIGNOND_ERROR,
GSIGNOND_ERROR_USER_INTERACTION,
"userActionFinished error: %d",
query_error);
gsignond_plugin_error (self, error);
g_error_free(error);
}
}
static void gsignond_password_plugin_refresh (
GSignondPlugin *self,
GSignondSessionData *session_data)
{
gsignond_plugin_refreshed(self, session_data);
}
static void
gsignond_plugin_interface_init (GSignondPluginInterface *iface)
{
iface->cancel = gsignond_password_plugin_cancel;
iface->abort = gsignond_password_plugin_abort;
iface->request_initial = gsignond_password_plugin_request_initial;
iface->request = gsignond_password_plugin_request;
iface->user_action_finished = gsignond_password_plugin_user_action_finished;
iface->refresh = gsignond_password_plugin_refresh;
}
static void
gsignond_password_plugin_init (GSignondPasswordPlugin *self)
{
}
enum
{
PROP_0,
PROP_TYPE,
PROP_MECHANISMS
};
static void
gsignond_password_plugin_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gsignond_password_plugin_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GSignondPasswordPlugin *password_plugin = GSIGNOND_PASSWORD_PLUGIN (object);
(void) password_plugin;
gchar *mechanisms[] = { "password", NULL };
switch (prop_id)
{
case PROP_TYPE:
g_value_set_string (value, "password");
break;
case PROP_MECHANISMS:
g_value_set_boxed (value, mechanisms);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsignond_password_plugin_class_init (GSignondPasswordPluginClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = gsignond_password_plugin_set_property;
gobject_class->get_property = gsignond_password_plugin_get_property;
g_object_class_override_property (gobject_class, PROP_TYPE, "type");
g_object_class_override_property (gobject_class, PROP_MECHANISMS,
"mechanisms");
}
/* 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_PASSWORD_PLUGIN_H__
#define __GSIGNOND_PASSWORD_PLUGIN_H__
#include <glib-object.h>
#define GSIGNOND_TYPE_PASSWORD_PLUGIN (gsignond_password_plugin_get_type ())
#define GSIGNOND_PASSWORD_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_PASSWORD_PLUGIN, GSignondPasswordPlugin))
#define GSIGNOND_IS_PASSWORD_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_PASSWORD_PLUGIN))
#define GSIGNOND_PASSWORD_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSIGNOND_TYPE_PASSWORD_PLUGIN, GSignondPasswordPluginClass))
#define GSIGNOND_IS_PASSWORD_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSIGNOND_TYPE_PASSWORD_PLUGIN))
#define GSIGNOND_PASSWORD_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSIGNOND_TYPE_PASSWORD_PLUGIN, GSignondPasswordPluginClass))
typedef struct _GSignondPasswordPlugin GSignondPasswordPlugin;
typedef struct _GSignondPasswordPluginClass GSignondPasswordPluginClass;
struct _GSignondPasswordPlugin
{
GObject parent_instance;
int instance_member;
};
struct _GSignondPasswordPluginClass
{
GObjectClass parent_class;
};
GType gsignond_password_plugin_get_type (void);
#endif /* __GSIGNOND_PASSWORD_PLUGIN_H__ */
\ No newline at end of file
TESTS = saslplugintest
TESTS_ENVIRONMENT= SSO_PLUGINS_DIR=$(top_builddir)/src/.libs
check_PROGRAMS = saslplugintest
saslplugintest_SOURCES = saslplugintest.c
saslplugintest_CFLAGS = \
$(GSIGNON_CFLAGS) \
$(CHECK_CFLAGS) \
-I$(top_srcdir)/src/
saslplugintest_LDADD = \
$(top_builddir)/src/libsasl.la \
$(GSIGNON_LIBS) \
$(CHECK_LIBS)
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment