qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject qpid-broker-j git commit: QPID-7789: [Java Broker] [Management Console] Allow saslExchangeExpiry timeout to be overidden.
Date Thu, 20 Jul 2017 06:36:01 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master f2bce8185 -> a039459c1


QPID-7789: [Java Broker] [Management Console]  Allow saslExchangeExpiry timeout to be overidden.


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/a039459c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a039459c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a039459c

Branch: refs/heads/master
Commit: a039459c1ccd67ebf45842afe543bd64e52c3af1
Parents: f2bce81
Author: Keith Wall <keith.wall@gmail.com>
Authored: Thu Jul 20 07:32:51 2017 +0100
Committer: Keith Wall <keith.wall@gmail.com>
Committed: Thu Jul 20 07:34:06 2017 +0100

----------------------------------------------------------------------
 .../management/plugin/HttpManagement.java       | 10 +++++++-
 .../plugin/HttpManagementConfiguration.java     | 25 +++++++++++++-------
 .../plugin/servlet/rest/RestServlet.java        |  4 ++--
 .../plugin/servlet/rest/SaslServlet.java        |  4 ++--
 .../rest/RestUserPreferenceHandlerTest.java     |  4 ++--
 5 files changed, 32 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a039459c/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
index 4b50431..5876276 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
@@ -176,6 +176,7 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement>
implem
     private Map<HttpPort<?>, ServerConnector> _portConnectorMap = new HashMap<>();
 
     private volatile boolean _serveUncompressedDojo;
+    private volatile Long _saslExchangeExpiry;
     private volatile ExecutorService _jettyServerExecutor;
 
     @ManagedObjectFactoryConstructor
@@ -188,7 +189,8 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement>
implem
     protected void onOpen()
     {
         super.onOpen();
-        _serveUncompressedDojo =   Boolean.TRUE.equals(getContextValue(Boolean.class, "qpid.httpManagement.serveUncompressedDojo"));
+        _serveUncompressedDojo = Boolean.TRUE.equals(getContextValue(Boolean.class, "qpid.httpManagement.serveUncompressedDojo"));
+        _saslExchangeExpiry = getContextValue(Long.class, SASL_EXCHANGE_EXPIRY_CONTEXT_NAME);
     }
 
     @StateTransition(currentState = {State.UNINITIALIZED,State.ERRORED}, desiredState = State.ACTIVE)
@@ -835,6 +837,12 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement>
implem
         }
     }
 
+    @Override
+    public long getSaslExchangeExpiry()
+    {
+        return _saslExchangeExpiry;
+    }
+
     private static class QBBTrackingThreadPool extends QueuedThreadPool
     {
         private final Map<Thread, QpidByteBuffer> _cachedBufferMap = new ConcurrentHashMap<>();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a039459c/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java
b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java
index a2c4bb2..25cd9f4 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java
@@ -25,6 +25,7 @@ import java.util.Set;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.DerivedAttribute;
 import org.apache.qpid.server.model.ManagedAttribute;
 import org.apache.qpid.server.model.ManagedContextDefault;
 import org.apache.qpid.server.model.Plugin;
@@ -46,35 +47,43 @@ public interface HttpManagementConfiguration<X extends HttpManagementConfigurati
     boolean isHttpBasicAuthenticationEnabled();
 
     @ManagedAttribute( defaultValue = "600", description = "The maximum time interval, in
seconds, that Web Management will keep the session open between client accesses.")
-    public int getSessionTimeout();
+    int getSessionTimeout();
 
     @ManagedAttribute( defaultValue = "" )
-    public String getCorsAllowOrigins();
+    String getCorsAllowOrigins();
 
     @ManagedAttribute( defaultValue = "[\"HEAD\",\"GET\",\"POST\"]", validValues = {"org.apache.qpid.server.management.plugin.HttpManagement#getAllAvailableCorsMethodCombinations()"}
)
-    public Set<String> getCorsAllowMethods();
+    Set<String> getCorsAllowMethods();
 
     @ManagedAttribute( defaultValue = "Content-Type,Accept,Origin,X-Requested-With,X-Range"
)
-    public String getCorsAllowHeaders();
+    String getCorsAllowHeaders();
 
     @ManagedAttribute( defaultValue = "true" )
-    public boolean getCorsAllowCredentials();
+    boolean getCorsAllowCredentials();
 
     String HTTP_MANAGEMENT_COMPRESS_RESPONSES = "httpManagement.compressResponses";
     @ManagedContextDefault(name = HTTP_MANAGEMENT_COMPRESS_RESPONSES)
     boolean DEFAULT_COMPRESS_RESPONSES = true;
 
     @ManagedAttribute( defaultValue = "${"+HTTP_MANAGEMENT_COMPRESS_RESPONSES+"}" )
-    public boolean isCompressResponses();
+    boolean isCompressResponses();
+
+    @DerivedAttribute(description = "Length of time permitted for the SASL authentication
exchange.")
+    long getSaslExchangeExpiry();
 
     String MAX_HTTP_FILE_UPLOAD_SIZE_CONTEXT_NAME = "maxHttpFileUploadSize";
     @ManagedContextDefault( name = MAX_HTTP_FILE_UPLOAD_SIZE_CONTEXT_NAME)
-    static final long DEFAULT_MAX_UPLOAD_SIZE = 100 * 1024;
+    long DEFAULT_MAX_UPLOAD_SIZE = 100 * 1024;
 
     String PREFERENCE_OPERTAION_TIMEOUT_CONTEXT_NAME = "qpid.httpManagement.preferenceOperationTimeout";
     @SuppressWarnings("unused")
     @ManagedContextDefault( name = PREFERENCE_OPERTAION_TIMEOUT_CONTEXT_NAME)
-    long DEFAULT_PREFERENCE_OPERTAION_TIMEOUT = 10000L;
+    long DEFAULT_PREFERENCE_OPERATION_TIMEOUT = 10000L;
+
+    String SASL_EXCHANGE_EXPIRY_CONTEXT_NAME = "qpid.httpManagement.saslExchangeExpiry";
+    @SuppressWarnings("unused")
+    @ManagedContextDefault( name = SASL_EXCHANGE_EXPIRY_CONTEXT_NAME)
+    long DEFAULT_SASL_EXCHANGE_EXPIRY = 3000L;
 
     AuthenticationProvider getAuthenticationProvider(HttpServletRequest request);
     Port<?> getPort(HttpServletRequest request);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a039459c/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
index 792aec4..5e25894 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
@@ -16,7 +16,7 @@
  */
 package org.apache.qpid.server.management.plugin.servlet.rest;
 
-import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.DEFAULT_PREFERENCE_OPERTAION_TIMEOUT;
+import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.DEFAULT_PREFERENCE_OPERATION_TIMEOUT;
 import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.PREFERENCE_OPERTAION_TIMEOUT_CONTEXT_NAME;
 import static org.apache.qpid.server.management.plugin.HttpManagementUtil.ensureFilenameIsRfc2183;
 
@@ -117,7 +117,7 @@ public class RestServlet extends AbstractServlet
         Handler.register();
         Long preferenceOperationTimeout = getManagementConfiguration().getContextValue(Long.class,
PREFERENCE_OPERTAION_TIMEOUT_CONTEXT_NAME);
         _userPreferenceHandler = new RestUserPreferenceHandler(preferenceOperationTimeout
== null
-                                                                       ? DEFAULT_PREFERENCE_OPERTAION_TIMEOUT
+                                                                       ? DEFAULT_PREFERENCE_OPERATION_TIMEOUT
                                                                        : preferenceOperationTimeout);
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a039459c/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
index 98736d7..080b291 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
@@ -66,7 +66,6 @@ public class SaslServlet extends AbstractServlet
     private static final String ATTR_ID = "SaslServlet.ID";
     private static final String ATTR_SASL_NEGOTIATOR = "SaslServlet.SaslNegotiator";
     private static final String ATTR_EXPIRY = "SaslServlet.Expiry";
-    private static final long SASL_EXCHANGE_EXPIRY = 3000L;
 
     public SaslServlet()
     {
@@ -275,8 +274,9 @@ public class SaslServlet extends AbstractServlet
             String id = String.valueOf(rand.nextLong());
             HttpManagementUtil.setSessionAttribute(ATTR_ID, id, session, request);
             HttpManagementUtil.setSessionAttribute(ATTR_SASL_NEGOTIATOR, saslNegotiator,
session, request);
+            long saslExchangeExpiry = getManagementConfiguration().getSaslExchangeExpiry();
             HttpManagementUtil.setSessionAttribute(ATTR_EXPIRY,
-                                                   System.currentTimeMillis() + SASL_EXCHANGE_EXPIRY,
+                                                   System.currentTimeMillis() + saslExchangeExpiry,
                                                    session, request);
 
             outputObject.put("id", id);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a039459c/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
index 467fe64..cb82a4a 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
@@ -18,7 +18,7 @@
  */
 package org.apache.qpid.server.management.plugin.servlet.rest;
 
-import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.DEFAULT_PREFERENCE_OPERTAION_TIMEOUT;
+import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.DEFAULT_PREFERENCE_OPERATION_TIMEOUT;
 import static org.apache.qpid.server.model.preferences.PreferenceTestHelper.awaitPreferenceFuture;
 import static org.apache.qpid.server.model.preferences.PreferenceTestHelper.createPreferenceAttributes;
 import static org.mockito.Mockito.mock;
@@ -61,7 +61,7 @@ public class RestUserPreferenceHandlerTest extends QpidTestCase
     private static final String MYUSER = "myuser";
     private static final String MYUSER_SERIALIZATION = TestPrincipalUtils.getTestPrincipalSerialization(MYUSER);
 
-    private RestUserPreferenceHandler _handler = new RestUserPreferenceHandler(DEFAULT_PREFERENCE_OPERTAION_TIMEOUT);
+    private RestUserPreferenceHandler _handler = new RestUserPreferenceHandler(DEFAULT_PREFERENCE_OPERATION_TIMEOUT);
     private ConfiguredObject<?> _configuredObject;
     private UserPreferences _userPreferences;
     private Subject _subject;


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


Mime
View raw message