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 | ca74a07a2f31f3174cdec04bbf8704329f7bce6d (patch) | |
| tree | 3938b2d4b685b8d78acd0577015976d325b7f590 /qpid | |
| parent | 020483a2a66a9c0b4d5b03c021e9f0bc0f1d4e8a (diff) | |
| download | qpid-python-ca74a07a2f31f3174cdec04bbf8704329f7bce6d.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@732702 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
| -rw-r--r-- | qpid/cpp/src/qpid/client/SaslFactory.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/qpid/cpp/src/qpid/client/SaslFactory.cpp b/qpid/cpp/src/qpid/client/SaslFactory.cpp index af18c445d8..ade301648c 100644 --- a/qpid/cpp/src/qpid/client/SaslFactory.cpp +++ b/qpid/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) |
