You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2009/01/08 14:23:56 UTC

svn commit: r732702 - /qpid/trunk/qpid/cpp/src/qpid/client/SaslFactory.cpp

Author: gsim
Date: Thu Jan  8 05:23:56 2009
New Revision: 732702

URL: http://svn.apache.org/viewvc?rev=732702&view=rev
Log:
QPID-976: Prompt for password if it is required and not specified through settings.


Modified:
    qpid/trunk/qpid/cpp/src/qpid/client/SaslFactory.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/client/SaslFactory.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/SaslFactory.cpp?rev=732702&r1=732701&r2=732702&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/SaslFactory.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/SaslFactory.cpp Thu Jan  8 05:23:56 2009
@@ -150,8 +150,13 @@
     }
 
     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 @@
 
 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)