[evolution-mapi/gnome-3-4] Kerberos authentication did not work
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi/gnome-3-4] Kerberos authentication did not work
- Date: Fri, 29 Jun 2012 10:12:34 +0000 (UTC)
commit 6f361274965240ab5597e8ee2f2b3d6e2b50f9fb
Author: Milan Crha <mcrha redhat com>
Date: Fri Jun 29 12:11:58 2012 +0200
Kerberos authentication did not work
po/POTFILES.in | 1 +
src/camel/Makefile.am | 2 +
src/camel/camel-mapi-provider.c | 4 ++
src/camel/camel-mapi-sasl-krb.c | 60 +++++++++++++++++++++++++++++++++++++++
src/camel/camel-mapi-sasl-krb.h | 59 ++++++++++++++++++++++++++++++++++++++
src/camel/camel-mapi-store.c | 31 ++++++++++++--------
6 files changed, 145 insertions(+), 12 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c44f2ec..00ad501 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,7 @@ src/addressbook/e-book-backend-mapi-gal.c
src/calendar/e-cal-backend-mapi.c
src/camel/camel-mapi-folder.c
src/camel/camel-mapi-provider.c
+src/camel/camel-mapi-sasl-krb.c
src/camel/camel-mapi-store.c
src/camel/camel-mapi-transport.c
src/libexchangemapi/e-mapi-cal-utils.c
diff --git a/src/camel/Makefile.am b/src/camel/Makefile.am
index ce4cc97..8a76c68 100644
--- a/src/camel/Makefile.am
+++ b/src/camel/Makefile.am
@@ -17,6 +17,7 @@ libcamelmapi_la_SOURCES = \
camel-mapi-provider.c \
camel-mapi-folder.c \
camel-mapi-folder-summary.c \
+ camel-mapi-sasl-krb.c \
camel-mapi-store.c \
camel-mapi-store-summary.c \
camel-mapi-transport.c
@@ -24,6 +25,7 @@ libcamelmapi_la_SOURCES = \
noinst_HEADERS = \
camel-mapi-folder.h \
camel-mapi-folder-summary.h \
+ camel-mapi-sasl-krb.h \
camel-mapi-store.h \
camel-mapi-store-summary.h \
camel-mapi-transport.h
diff --git a/src/camel/camel-mapi-provider.c b/src/camel/camel-mapi-provider.c
index e0a399f..84b2737 100644
--- a/src/camel/camel-mapi-provider.c
+++ b/src/camel/camel-mapi-provider.c
@@ -31,6 +31,7 @@
#include <gmodule.h>
+#include "camel-mapi-sasl-krb.h"
#include "camel-mapi-store.h"
#include "camel-mapi-transport.h"
@@ -114,6 +115,9 @@ camel_provider_module_init(void)
bindtextdomain (GETTEXT_PACKAGE, EXCHANGE_MAPI_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ /* register MAPIKRB auth type */
+ CAMEL_TYPE_MAPI_SASL_KRB;
+
camel_provider_register (&mapi_provider);
}
diff --git a/src/camel/camel-mapi-sasl-krb.c b/src/camel/camel-mapi-sasl-krb.c
new file mode 100644
index 0000000..317cf97
--- /dev/null
+++ b/src/camel/camel-mapi-sasl-krb.c
@@ -0,0 +1,60 @@
+/*
+ * This program 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 of the License, or (at your option) version 3.
+ *
+ * This program 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 the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include "camel-mapi-sasl-krb.h"
+
+static CamelServiceAuthType mapi_sasl_krb_auth_type = {
+ "Kerberos",
+
+ "This option will connect to the server using kerberos key.",
+
+ "MAPIKRB",
+ FALSE
+};
+
+G_DEFINE_TYPE (CamelMapiSaslKrb, camel_mapi_sasl_krb, CAMEL_TYPE_SASL)
+
+static GByteArray *
+mapi_sasl_krb_challenge_sync (CamelSasl *sasl,
+ GByteArray *token,
+ GCancellable *cancellable,
+ GError **error)
+{
+ camel_sasl_set_authenticated (sasl, TRUE);
+
+ return NULL;
+}
+
+static void
+camel_mapi_sasl_krb_class_init (CamelMapiSaslKrbClass *class)
+{
+ CamelSaslClass *sasl_class;
+
+ sasl_class = CAMEL_SASL_CLASS (class);
+ sasl_class->auth_type = &mapi_sasl_krb_auth_type;
+ sasl_class->challenge_sync = mapi_sasl_krb_challenge_sync;
+}
+
+static void
+camel_mapi_sasl_krb_init (CamelMapiSaslKrb *mapi_sasl_krb)
+{
+}
diff --git a/src/camel/camel-mapi-sasl-krb.h b/src/camel/camel-mapi-sasl-krb.h
new file mode 100644
index 0000000..9438592
--- /dev/null
+++ b/src/camel/camel-mapi-sasl-krb.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * This program 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 of the License, or (at your option) version 3.
+ *
+ * This program 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 the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef CAMEL_MAPI_SASL_KRB_H
+#define CAMEL_MAPI_SASL_KRB_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_SASL_KRB \
+ (camel_mapi_sasl_krb_get_type ())
+#define CAMEL_MAPI_SASL_KRB(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_MAPI_SASL_KRB, CamelMapiSaslKrb))
+#define CAMEL_MAPI_SASL_KRB_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_MAPI_SASL_KRB, CamelMapiSaslKrbClass))
+#define CAMEL_IS_MAPI_SASL_KRB(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_MAPI_SASL_KRB))
+#define CAMEL_IS_MAPI_SASL_KRB_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_MAPI_SASL_KRB))
+#define CAMEL_MAPI_SASL_KRB_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_MAPI_SASL_KRB, CamelMapiSaslKrbClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelMapiSaslKrb CamelMapiSaslKrb;
+typedef struct _CamelMapiSaslKrbClass CamelMapiSaslKrbClass;
+
+struct _CamelMapiSaslKrb {
+ CamelSasl parent;
+};
+
+struct _CamelMapiSaslKrbClass {
+ CamelSaslClass parent_class;
+};
+
+GType camel_mapi_sasl_krb_get_type (void);
+
+G_END_DECLS
+
+#endif /* CAMEL_MAPI_SASL_KRB_H */
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index ac781a3..13864e7 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -41,6 +41,7 @@
#include "camel-mapi-store.h"
#include "camel-mapi-folder.h"
+#include "camel-mapi-sasl-krb.h"
#include "camel-mapi-settings.h"
#include "camel-mapi-store-summary.h"
#include "camel-mapi-folder-summary.h"
@@ -1972,6 +1973,9 @@ camel_mapi_store_class_init (CamelMapiStoreClass *class)
CamelServiceClass *service_class;
CamelStoreClass *store_class;
+ /* register MAPIKRB auth type */
+ CAMEL_TYPE_MAPI_SASL_KRB;
+
g_type_class_add_private (class, sizeof (CamelMapiStorePrivate));
object_class = G_OBJECT_CLASS (class);
@@ -2101,6 +2105,7 @@ mapi_connect_sync (CamelService *service,
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
CamelServiceConnectionStatus status;
CamelSession *session;
+ EMapiProfileData empd = { 0 };
uint64_t current_size = -1, receive_quota = -1, send_quota = -1;
gchar *name;
@@ -2127,7 +2132,9 @@ mapi_connect_sync (CamelService *service,
name = camel_service_get_name (service, TRUE);
camel_operation_push_message (cancellable, _("Connecting to '%s'"), name);
- if (!camel_session_authenticate_sync (session, service, NULL, cancellable, error)) {
+ e_mapi_util_profiledata_from_settings (&empd, CAMEL_MAPI_SETTINGS (camel_service_get_settings (service)));
+
+ if (!camel_session_authenticate_sync (session, service, empd.krb_sso ? "MAPIKRB" : NULL, cancellable, error)) {
camel_operation_pop_message (cancellable);
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_service_disconnect_sync (service, TRUE, NULL);
@@ -2559,20 +2566,20 @@ mapi_authenticate_sync (CamelService *service,
profile = camel_mapi_settings_get_profile (mapi_settings);
if (empd.krb_sso) {
- if (e_mapi_util_trigger_krb_auth (&empd, error))
- return CAMEL_AUTHENTICATION_ACCEPTED;
- else
+ if (!e_mapi_util_trigger_krb_auth (&empd, error))
return CAMEL_AUTHENTICATION_ERROR;
- }
- password = camel_service_get_password (service);
+ password = NULL;
+ } else {
+ password = camel_service_get_password (service);
- if (password == NULL) {
- g_set_error_literal (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
- _("Authentication password not available"));
- return CAMEL_AUTHENTICATION_ERROR;
+ if (password == NULL) {
+ g_set_error_literal (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Authentication password not available"));
+ return CAMEL_AUTHENTICATION_ERROR;
+ }
}
store->priv->conn = e_mapi_connection_new (profile, password, cancellable, &mapi_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]