qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1414256 - in /qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java: org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java resources/js/qpid/authorization/sasl.js
Date Tue, 27 Nov 2012 16:42:13 GMT
Author: robbie
Date: Tue Nov 27 16:42:12 2012
New Revision: 1414256

URL: http://svn.apache.org/viewvc?rev=1414256&view=rev
Log:
QPID-4475: enable the web management UI support the PLAIN mechanism for SASL login

Modified:
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/sasl.js

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java?rev=1414256&r1=1414255&r2=1414256&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
Tue Nov 27 16:42:12 2012
@@ -146,6 +146,10 @@ public class SaslServlet extends Abstrac
             {
                 if(id == null)
                 {
+                    if(LOGGER.isDebugEnabled())
+                    {
+                        LOGGER.debug("Creating SaslServer for mechanism: " + mechanism);
+                    }
                     SaslServer saslServer = subjectCreator.createSaslServer(mechanism, request.getServerName(),
null/*TODO*/);
                     evaluateSaslResponse(request, response, session, saslResponse, saslServer,
subjectCreator);
                 }

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/sasl.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/sasl.js?rev=1414256&r1=1414255&r2=1414256&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/sasl.js
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/sasl.js
Tue Nov 27 16:42:12 2012
@@ -152,10 +152,45 @@ var saslCramMD5 = function saslCramMD5(u
             });
 };
 
+var containsMechanism = function containsMechanism(mechanisms, mech)
+{
+    for (var i = 0; i < mechanisms.length; i++) {
+        if (mechanisms[i] == mech) {
+            return true;
+        }
+    }
+
+    return false;
+};
+
 var doAuthenticate = function doAuthenticate()
 {
-    saslCramMD5(dojo.byId("username").value, dojo.byId("pass").value);
-    updateAuthentication();
+    dojo.xhrGet({
+        // The URL of the request
+        url: "rest/sasl",
+        handleAs: "json"
+    }).then(function(data)
+            {
+                var mechMap = data.mechanisms;
+
+                if (containsMechanism(mechMap, "CRAM-MD5"))
+                {
+                    saslCramMD5(dojo.byId("username").value, dojo.byId("pass").value);
+                    updateAuthentication();
+                }
+                else if (containsMechanism(mechMap, "PLAIN"))
+                {
+                    saslPlain(dojo.byId("username").value, dojo.byId("pass").value);
+                    updateAuthentication();
+                }
+                else
+                {
+                    alert("No supported SASL mechanism offered: " + mechMap);
+                }
+            }
+        );
+
+
 };
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message