diff options
| author | Gordon Sim <gsim@apache.org> | 2009-01-08 13:23:56 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2009-01-08 13:23:56 +0000 |
| commit | 9f1aa6c15240a758f7808e60980bb8e94ac55ca1 (patch) | |
| tree | ba1613f1bc0ba921f0f3236e32dd1e4aacdc4cdd /cpp/src | |
| parent | adf563162a591421cb7c401a9705602dfc433cc2 (diff) | |
| download | qpid-python-9f1aa6c15240a758f7808e60980bb8e94ac55ca1.tar.gz | |
QPID-976: Prompt for password if it is required and not specified through settings.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@732702 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
| -rw-r--r-- | cpp/src/qpid/client/SaslFactory.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/cpp/src/qpid/client/SaslFactory.cpp b/cpp/src/qpid/client/SaslFactory.cpp index af18c445d8..ade301648c 100644 --- a/cpp/src/qpid/client/SaslFactory.cpp +++ b/cpp/src/qpid/client/SaslFactory.cpp @@ -150,8 +150,13 @@ CyrusSasl::CyrusSasl(const ConnectionSettings& s) : conn(0), settings(s) } callbacks[i].id = SASL_CB_PASS; - callbacks[i].proc = (CallbackProc*) &getPasswordFromSettings; - callbacks[i++].context = &settings; + if (settings.password.empty()) { + callbacks[i].proc = 0; + callbacks[i++].context = 0; + } else { + callbacks[i].proc = (CallbackProc*) &getPasswordFromSettings; + callbacks[i++].context = &settings; + } callbacks[i].id = SASL_CB_LIST_END; callbacks[i].proc = 0; @@ -263,13 +268,22 @@ std::string CyrusSasl::getMechanism() void CyrusSasl::interact(sasl_interact_t* client_interact) { - std::cout << "[" << client_interact->id << "] " << client_interact->challenge << " " << client_interact->prompt; - if (client_interact->defresult) std::cout << " (" << client_interact->defresult << ")"; - std::cout << std::endl; - if (std::cin >> input) { + + if (client_interact->id == SASL_CB_PASS) { + char* password = getpass(client_interact->prompt); + input = std::string(password); client_interact->result = input.data(); client_interact->len = input.size(); - } + } else { + std::cout << client_interact->prompt; + if (client_interact->defresult) std::cout << " (" << client_interact->defresult << ")"; + std::cout << ": "; + if (std::cin >> input) { + client_interact->result = input.data(); + client_interact->len = input.size(); + } + } + } std::auto_ptr<SecurityLayer> CyrusSasl::getSecurityLayer(uint16_t maxFrameSize) |
