This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 4667ce7d08 Save protocols attributes for SSLHostConfig
4667ce7d08 is described below

commit 4667ce7d084f58d5e459db3d27ea1c12463e7b88
Author: remm <[email protected]>
AuthorDate: Thu Nov 14 14:00:15 2024 +0100

    Save protocols attributes for SSLHostConfig
---
 .../catalina/storeconfig/SSLHostConfigSF.java      | 40 ++++++++++++++++++++++
 webapps/docs/changelog.xml                         |  4 +++
 2 files changed, 44 insertions(+)

diff --git a/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java 
b/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
index 44bad1d973..ea6344fd79 100644
--- a/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
+++ b/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
@@ -19,6 +19,8 @@ package org.apache.catalina.storeconfig;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.net.SSLHostConfig;
 import org.apache.tomcat.util.net.SSLHostConfigCertificate;
 import org.apache.tomcat.util.net.SSLHostConfigCertificate.Type;
@@ -29,6 +31,44 @@ import org.apache.tomcat.util.net.openssl.OpenSSLConf;
  */
 public class SSLHostConfigSF extends StoreFactoryBase {
 
+    private static Log log = LogFactory.getLog(SSLHostConfigSF.class);
+
+    @Override
+    public void store(PrintWriter aWriter, int indent, Object aElement) throws 
Exception {
+        StoreDescription elementDesc = 
getRegistry().findDescription(aElement.getClass());
+        if (elementDesc != null) {
+            if (log.isTraceEnabled()) {
+                log.trace(sm.getString("factory.storeTag", 
elementDesc.getTag(), aElement));
+            }
+            getStoreAppender().printIndent(aWriter, indent + 2);
+            aWriter.print("<");
+            aWriter.print(elementDesc.getTag());
+            if (elementDesc.isAttributes() && aElement != null) {
+                // Add protocols attribute
+                SSLHostConfig bean2 = (SSLHostConfig) 
getStoreAppender().defaultInstance(aElement);
+                SSLHostConfig sslHostConfig = (SSLHostConfig) aElement;
+                if 
(!bean2.getProtocols().equals(sslHostConfig.getProtocols())) {
+                    StringBuffer protocolsValue = new StringBuffer();
+                    for (String protocol : sslHostConfig.getProtocols()) {
+                        protocolsValue.append('+').append(protocol);
+                    }
+                    if (!protocolsValue.isEmpty()) {
+                        getStoreAppender().printValue(aWriter, indent, 
"protocols", protocolsValue.toString());
+                    }
+                }
+                getStoreAppender().printAttributes(aWriter, indent, aElement, 
elementDesc);
+            }
+            aWriter.println(">");
+            storeChildren(aWriter, indent + 2, aElement, elementDesc);
+            getStoreAppender().printIndent(aWriter, indent + 2);
+            getStoreAppender().printCloseTag(aWriter, elementDesc);
+        } else {
+            if (log.isWarnEnabled()) {
+                log.warn(sm.getString("factory.storeNoDescriptor", 
aElement.getClass()));
+            }
+        }
+    }
+
     /**
      * Store nested SSLHostConfigCertificate elements.
      * <p>
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d3f03b7422..349814e596 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,10 @@
         <code>HttpServletResponse.sendEarlyHints()</code>. (markt)
       </add>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
+      <fix>
+        Add special handling for the <code>protocols</code> attribute of
+        <code>SSLHostConfig</code> in storeconfig. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to