summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/app/remotemdi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde/src/app/remotemdi.cpp')
-rw-r--r--clients/tde/src/app/remotemdi.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index 5c84419..e6a2d7f 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -8,6 +8,8 @@
#include <cassert>
using namespace std;
+#include <pwd.h>
+
#include <tdeapplication.h>
#include <tdelocale.h>
#include <kdebug.h>
@@ -25,6 +27,7 @@ using namespace std;
#include <tdeactionclasses.h>
#include <kedittoolbar.h>
#include <kkeydialog.h>
+#include <libtdeldap.h>
#include "views/instrumentview.h"
#include "dialogs/selectserverdlg.h"
@@ -185,6 +188,37 @@ void RemoteMDI::startModule() {
}
}
+int RemoteMDI::getNewTicket() {
+ int ret = -1;
+
+ LDAPCredentials credentials;
+ KerberosTicketInfoList ticketList = LDAPManager::getKerberosTicketList();
+ if (ticketList.count() > 0) {
+ TQStringList princParts = TQStringList::split("@", ticketList[0].cachePrincipal);
+ credentials.username = princParts[0];
+ credentials.realm = princParts[1];
+ }
+ else {
+ struct passwd* pwd = getpwuid(geteuid());
+ if (pwd) {
+ credentials.username = TQString(pwd->pw_name);
+ }
+ }
+ int result = LDAPManager::getKerberosPassword(credentials, i18n("Please provide Kerberos credentials"), false, this);
+ if (result == KDialog::Accepted) {
+ TQString errorstring;
+ TQString service;
+ if (LDAPManager::obtainKerberosTicket(credentials, service, &errorstring) != 0) {
+ KMessageBox::error(this, i18n("<qt>Failed to obtain ticket<p>%1</qt>").arg(errorstring), i18n("Failed to obtain Kerberos ticket"));
+ }
+ else {
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
void RemoteMDI::finishConnectingToServer() {
if (!m_rsvSvrSocket) {
connToServerState = -1;
@@ -206,6 +240,7 @@ void RemoteMDI::finishConnectingToServer() {
connToServerConnecting = false;
disconnectFromServer();
KMessageBox::error(this, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed"));
+ return;
}
}
else {
@@ -220,6 +255,7 @@ void RemoteMDI::finishConnectingToServer() {
connToServerConnecting = false;
disconnectFromServer();
KMessageBox::error(this, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed"));
+ return;
}
}
break;
@@ -232,7 +268,17 @@ void RemoteMDI::finishConnectingToServer() {
connToServerState = -1;
connToServerConnecting = false;
disconnectFromServer();
- KMessageBox::error(this, i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"), i18n("Connection Failed"));
+
+ // Try to get a valid ticket
+ if (getNewTicket() == 0) {
+ // Retry connection if no obvious errors were detected
+ TQTimer::singleShot(0, this, SLOT(connectToServer()));
+ return;
+ }
+ else {
+ KMessageBox::error(this, i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"), i18n("Connection Failed"));
+ return;
+ }
}
else {
connect(m_rsvSvrSocket, SIGNAL(readyRead()), m_rsvSvrSocket, SLOT(processPendingData()));