lvfangmin commented on a change in pull request #924: ZOOKEEPER-3371: Port 
unification for Jetty admin server
URL: https://github.com/apache/zookeeper/pull/924#discussion_r285746634
 
 

 ##########
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/JettyAdminServer.java
 ##########
 @@ -67,24 +80,75 @@
     private final String commandUrl;
     private ZooKeeperServer zkServer;
 
-    public JettyAdminServer() throws AdminServerException {
+    public JettyAdminServer() throws AdminServerException, IOException, 
GeneralSecurityException {
         this(System.getProperty("zookeeper.admin.serverAddress", 
DEFAULT_ADDRESS),
              Integer.getInteger("zookeeper.admin.serverPort", DEFAULT_PORT),
              Integer.getInteger("zookeeper.admin.idleTimeout", 
DEFAULT_IDLE_TIMEOUT),
-             System.getProperty("zookeeper.admin.commandURL", 
DEFAULT_COMMAND_URL));
+             System.getProperty("zookeeper.admin.commandURL", 
DEFAULT_COMMAND_URL),
+             Integer.getInteger("zookeeper.admin.httpVersion", 
DEFAULT_HTTP_VERSION),
+             Boolean.getBoolean("zookeeper.admin.portUnification"));
     }
 
-    public JettyAdminServer(String address, int port, int timeout, String 
commandUrl) {
+    public JettyAdminServer(String address,
+                            int port,
+                            int timeout,
+                            String commandUrl,
+                            int httpVersion,
+                            boolean portUnification) throws IOException, 
GeneralSecurityException {
         this.port = port;
         this.idleTimeout = timeout;
         this.commandUrl = commandUrl;
         this.address = address;
 
         server = new Server();
-        ServerConnector connector = new ServerConnector(server);
+        ServerConnector connector = null;
+
+        if (!portUnification) {
+            connector = new ServerConnector(server);
+        } else {
+            SecureRequestCustomizer customizer = new SecureRequestCustomizer();
+            customizer.setStsMaxAge(DEFAULT_STS_MAX_AGE);
+            customizer.setStsIncludeSubDomains(true);
+
+            HttpConfiguration config = new HttpConfiguration();
+            config.setSecureScheme("https");
+            config.addCustomizer(customizer);
+
+            try(QuorumX509Util x509Util = new QuorumX509Util()) {
 
 Review comment:
   nit: space after try

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to