if(!m_socket)return-1;// Any entry into the event loop could end up deleting the socket object depending on user interaction
}
}
if(m_socket->state()!=TQSocket::Connected){
if(m_socket->state()!=TQSocket::Connected){
return-1;
return-1;
}
}
if(m_socket->setUsingKerberos(true)!=0){
if(m_socket->setUsingKerberos(true)!=0){
if(!m_socket)return-1;// Any entry into the event loop could end up deleting the socket object depending on user interaction
m_socket->close();
m_socket->close();
KMessageBox::error(0,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"));
KMessageBox::error(0,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"));
// Read magic number and proto version from server
TQ_UINT32magicnum;
TQ_UINT32protover;
ds>>magicnum;
ds>>protover;
printf("[DEBUG] Got magic number %d and protocol version %d\n\r",magicnum,protover);fflush(stdout);
// Request connection to backend server
ds<<TQString("SERV");
ds<<TQString(CLIENT_LIBRARY);
ds>>response;
printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r",response.ascii());fflush(stdout);
if(response=="OK"){
m_connectionMutex->unlock();
return0;
}
elseif(response=="ERRNOCONN"){
KMessageBox::error(0,i18n("<qt>Unable to establish connection with backend server<p>Please verify that you are currently connected to a workspace</qt>"),i18n("Connection Failed"));
m_connectionMutex->unlock();
return-1;
}
elseif(response=="ERRNOTAVL"){
KMessageBox::error(0,i18n("<qt>The backend server is not available at this time<p>Please try a different workspace, or try again later</qt>"),i18n("Connection Failed"));
m_connectionMutex->unlock();
return-1;
}
elseif(response=="ERRNOSERV"){
KMessageBox::error(0,i18n("<qt>The active laboratory workspace does not support the requested service</qt>"),i18n("Service Unavailable"));
m_connectionMutex->unlock();
return-1;
}
else{
KMessageBox::error(0,i18n("<qt>Unable to establish connection with remote server</qt>"),i18n("Connection Failed"));
m_connectionMutex->unlock();
return-1;
}
// Kerberos connection established!
m_connectionMutex->lock();
TQStringresponse;
TQDataStreamds(m_socket);
// Read magic number and proto version from server
TQ_UINT32magicnum;
TQ_UINT32protover;
ds>>magicnum;
ds>>protover;
printf("[DEBUG] Got magic number %d and protocol version %d\n\r",magicnum,protover);fflush(stdout);
// Request connection to backend server
ds<<TQString("SERV");
ds<<TQString(CLIENT_LIBRARY);
ds>>response;
printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r",response.ascii());fflush(stdout);
if(response=="OK"){
m_connectionMutex->unlock();
m_connectionMutex->unlock();
return0;
return0;
}
}
catch(exit_exception&e){
elseif(response=="ERRNOCONN"){
KMessageBox::error(0,i18n("<qt>Unable to establish connection with backend server<p>Please verify that you are currently connected to a workspace</qt>"),i18n("Connection Failed"));
m_connectionMutex->unlock();
return-1;
}
elseif(response=="ERRNOTAVL"){
KMessageBox::error(0,i18n("<qt>The backend server is not available at this time<p>Please try a different workspace, or try again later</qt>"),i18n("Connection Failed"));
m_connectionMutex->unlock();
m_connectionMutex->unlock();
return-1;
return-1;
}
}
elseif(response=="ERRNOSERV"){
KMessageBox::error(0,i18n("<qt>The active laboratory workspace does not support the requested service</qt>"),i18n("Service Unavailable"));
m_connectionMutex->unlock();
return-1;
}
else{
KMessageBox::error(0,i18n("<qt>Unable to establish connection with remote server</qt>"),i18n("Connection Failed"));
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to Kerberos failure\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
m_servActive=false;
deletem_servClientTimeout;
m_servClientTimeout=NULL;
}
m_servState=2;
}
else{
m_servClientSocket->close();
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to remote server returning %s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii(),server_reply.ascii());fflush(stdout);
}
m_servActive=false;
deletem_servClientTimeout;
m_servClientTimeout=NULL;
}
}
else{
if(!m_servClientTimeout->isActive()){
// Timeout!
m_servClientSocket->close();
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
m_servActive=false;
deletem_servClientTimeout;
m_servClientTimeout=NULL;
}
}
}
}
else{
m_servClientSocket->close();
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection terminated by remote host %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to Kerberos failure\n\r",serviceHostName.ascii(),servicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to remote server returning %s\n\r",serviceHostName.ascii(),servicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii(),server_reply.ascii());fflush(stdout);
}
}
}
}
else{
else{
clientSocket.close();
ds<<TQString("ERRNOSERV");
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",serviceHostName.ascii(),servicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);