@ -8,6 +8,8 @@
# include <cassert>
# include <cassert>
using namespace std ;
using namespace std ;
# include <pwd.h>
# include <tdeapplication.h>
# include <tdeapplication.h>
# include <tdelocale.h>
# include <tdelocale.h>
# include <kdebug.h>
# include <kdebug.h>
@ -25,6 +27,7 @@ using namespace std;
# include <tdeactionclasses.h>
# include <tdeactionclasses.h>
# include <kedittoolbar.h>
# include <kedittoolbar.h>
# include <kkeydialog.h>
# include <kkeydialog.h>
# include <libtdeldap.h>
# include "views/instrumentview.h"
# include "views/instrumentview.h"
# include "dialogs/selectserverdlg.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 ( ) {
void RemoteMDI : : finishConnectingToServer ( ) {
if ( ! m_rsvSvrSocket ) {
if ( ! m_rsvSvrSocket ) {
connToServerState = - 1 ;
connToServerState = - 1 ;
@ -206,6 +240,7 @@ void RemoteMDI::finishConnectingToServer() {
connToServerConnecting = false ;
connToServerConnecting = false ;
disconnectFromServer ( ) ;
disconnectFromServer ( ) ;
KMessageBox : : error ( this , i18n ( " <qt>Unable to establish connection to remote server</qt> " ) , i18n ( " Connection Failed " ) ) ;
KMessageBox : : error ( this , i18n ( " <qt>Unable to establish connection to remote server</qt> " ) , i18n ( " Connection Failed " ) ) ;
return ;
}
}
}
}
else {
else {
@ -220,6 +255,7 @@ void RemoteMDI::finishConnectingToServer() {
connToServerConnecting = false ;
connToServerConnecting = false ;
disconnectFromServer ( ) ;
disconnectFromServer ( ) ;
KMessageBox : : error ( this , i18n ( " <qt>Unable to establish connection to remote server</qt> " ) , i18n ( " Connection Failed " ) ) ;
KMessageBox : : error ( this , i18n ( " <qt>Unable to establish connection to remote server</qt> " ) , i18n ( " Connection Failed " ) ) ;
return ;
}
}
}
}
break ;
break ;
@ -232,7 +268,17 @@ void RemoteMDI::finishConnectingToServer() {
connToServerState = - 1 ;
connToServerState = - 1 ;
connToServerConnecting = false ;
connToServerConnecting = false ;
disconnectFromServer ( ) ;
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 {
else {
connect ( m_rsvSvrSocket , SIGNAL ( readyRead ( ) ) , m_rsvSvrSocket , SLOT ( processPendingData ( ) ) ) ;
connect ( m_rsvSvrSocket , SIGNAL ( readyRead ( ) ) , m_rsvSvrSocket , SLOT ( processPendingData ( ) ) ) ;