Commit f95f904b authored by allens's avatar allens

changed from a bool to string

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@30887 18c085ea-50e0-402c-830e-de6fd14e8384
parent 30623a6d
......@@ -216,7 +216,7 @@ qtssh_handle_new_username(const char *host)
// p : The prompts for which we're gathering input.
// in : The default input values.
// inlen : The length of the default input values.
// passphrase : True if we want passphrase instead of password.
// phrase : Phrase to use in the prompt
//
// Returns:
//
......@@ -234,7 +234,7 @@ qtssh_handle_new_username(const char *host)
// ****************************************************************************
static int
qtssh_handle_password(prompts_t *p, int i, unsigned char *in, int inlen, bool passphrase)
qtssh_handle_password(prompts_t *p, int i, unsigned char *in, int inlen, std::string phrase)
{
VisItPasswordWindow win;
......@@ -243,7 +243,7 @@ getpassword:
VisItPasswordWindow::ReturnCode status = VisItPasswordWindow::PW_Rejected;
QString password = win.getPassword(QString(conf_get_str(qtssh_config, CONF_username)),
QString(conf_get_str(qtssh_config, CONF_host)),
passphrase,
QString(phrase.c_str()),
status);
int ret = -1;
......@@ -312,9 +312,11 @@ int qtssh_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
for(size_t i = 0; i < p->n_prompts; ++i)
{
if (strstr(p->prompts[i]->prompt, "assword") != NULL)
ret = qtssh_handle_password(p, i, in, inlen, false);
ret = qtssh_handle_password(p, i, in, inlen, "Password");
else if (strstr(p->prompts[i]->prompt, "asscode") != NULL)
ret = qtssh_handle_password(p, i, in, inlen, "Passcode");
else if (strstr(p->prompts[i]->prompt, "assphrase") != NULL)
ret = qtssh_handle_password(p, i, in, inlen, true);
ret = qtssh_handle_password(p, i, in, inlen, "Passphrase");
else
ret = qtssh_handle_prompt(p, i, in, inlen);
}
......
......@@ -210,19 +210,36 @@ ViewerPasswordWindow::authenticate(const char *username, const char* password, c
result += write(fd, "yes\n", 4);
pbuf = buffer;
}
else if (strstr(buffer, "assword") ||
strstr(buffer, "ASSWORD") ||
strstr(buffer, "asscode") ||
strstr(buffer, "ASSCODE") ||
strstr(buffer, "Token_Response:"))
else if (strstr(buffer, "assword") || strstr(buffer, "ASSWORD") ||
strstr(buffer, "asscode") || strstr(buffer, "ASSCODE") ||
strstr(buffer, "assphrase") || strstr(buffer, "ASSPHRASE") ||
strstr(buffer, "Token_Response:") ||
strstr(buffer, "Token Code:"))
{
std::string phrase;
if (strstr(buffer, "assword") || strstr(buffer, "ASSWORD") )
phrase = std::string("Password");
else if (strstr(buffer, "asscode") || strstr(buffer, "ASSCODE") )
phrase = std::string("Passcode");
else if (strstr(buffer, "assphrase") || strstr(buffer, "ASSPHRASE") )
phrase = std::string("Passphrase");
else if (strstr(buffer, "Token Code:") )
phrase = std::string("Token Code");
else if (strstr(buffer, "Token_Response:") )
phrase = std::string("Token Response");
// Password needed. Prompt for it and write it to the FD.
VisItPasswordWindow::ReturnCode ret = VisItPasswordWindow::PW_Accepted;
VisItPasswordWindow::ReturnCode ret =
VisItPasswordWindow::PW_Accepted;
//Start with password that was supplied by machine profile
std::string passwd = password;
if (passwd.empty()) {
passwd = instance->password(username, host, false, ret);
passwd = instance->password(username, host, phrase.c_str(), ret);
}
if (passwd.empty())
......@@ -246,33 +263,6 @@ ViewerPasswordWindow::authenticate(const char *username, const char* password, c
// the connection progress dialog.
timeout = 0;
}
else if (strstr(buffer, "assphrase"))
{
// Passphrase needed. Prompt for it and write it to the FD.
VisItPasswordWindow::ReturnCode ret = VisItPasswordWindow::PW_Accepted;
std::string passphr = instance->password(username, host, true, ret);
if (passphr.empty())
{
if (ret == VisItPasswordWindow::PW_ChangedUsername)
{
EXCEPTION0(ChangeUsernameException);
}
else
{
// User closed the window or hit cancel
EXCEPTION0(CancelledConnectException);
}
}
result += write(fd, passphr.c_str(), passphr.size());
result += write(fd, "\n", 1);
pbuf = buffer;
// We put up the password window, have zero timeout for
// the connection progress dialog.
timeout = 0;
}
else if (strstr(buffer, "Connection refused"))
{
std::string msg(std::string("The connection to ") + host + std::string(" was refused."));
......@@ -400,7 +390,8 @@ ViewerPasswordWindow::GetFailedPortForwards()
std::string
ViewerPasswordWindow::password(const char *username, const char *host,
bool passphrase, VisItPasswordWindow::ReturnCode &ret)
const char *phrase,
VisItPasswordWindow::ReturnCode &ret)
{
if(!instance)
instance = new ViewerPasswordWindow();
......@@ -414,7 +405,8 @@ ViewerPasswordWindow::password(const char *username, const char *host,
#endif
ret = VisItPasswordWindow::PW_Rejected;
pw = instance->getPassword(QString(username), QString(host), passphrase, ret);
pw = instance->getPassword(QString(username), QString(host),
QString(phrase), ret);
#if !defined(_WIN32)
ViewerBase::GetViewerMessaging()->BlockClientInput(false);
......
......@@ -100,7 +100,8 @@ public:
static std::set<int> GetFailedPortForwards();
private:
std::string password(const char *username, const char *host,
bool passphrase, VisItPasswordWindow::ReturnCode &ret);
const char *phrase,
VisItPasswordWindow::ReturnCode &ret);
static ViewerPasswordWindow *instance;
static ViewerConnectionProgressDialog *dialog;
......
......@@ -145,28 +145,26 @@ VisItPasswordWindow::~VisItPasswordWindow()
// ****************************************************************************
QString
VisItPasswordWindow::getPassword(const QString &username, const QString &host,
bool passphrase, VisItPasswordWindow::ReturnCode &ret)
VisItPasswordWindow::getPassword(const QString &username,
const QString &host,
QString phrase,
VisItPasswordWindow::ReturnCode &ret)
{
this->changedUserName = false;
const char *queryType = passphrase ? "Passphrase" : "Password";
if (passphrase)
this->setWindowTitle(tr("Enter passphrase"));
else
this->setWindowTitle(tr("Enter password"));
this->setWindowTitle(QString("Enter %1").arg(phrase));
// Set the password prompt.
QString labelText;
this->label->setTextFormat(Qt::RichText);
if(username.isEmpty() || username == QString("notset"))
labelText = QString("%1 for %2: ").arg(queryType).arg(host);
labelText = QString("%1 for %2: ").arg(phrase).arg(host);
else
{
// "nobr" means no line breaks, which is how it worked when we weren't
// using rich text.
labelText = QString("<nobr>%1 for <font color=\"red\">%2</font>@%3: </nobr>").
arg(queryType).arg(username).arg(host);
arg(phrase).arg(username).arg(host);
}
this->label->setText(labelText);
......
......@@ -71,7 +71,7 @@ public:
} ReturnCode;
QString getPassword(const QString &host, const QString &username,
bool passPhrase, ReturnCode &ret);
QString phrase, ReturnCode &ret);
private slots:
void changeUserName();
......
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