@@ -14,25 +14,25 @@ class ConnectorAttributesTransformer {
1414
1515 /**
1616 * Provides attributes for non secure HTTP connector.
17- * Returns map of key:value corresponding with attributes in Tomcat server.xml.
17+ * Returns Node applicable into Tomcat server.xml.
1818 */
19- Map< String , Object > nonSecureHttpConnector () {
19+ Node nonSecureHttpConnector () {
2020 return new CommonConnectorTransformer (connector). transform()
2121 }
2222
2323 /**
2424 * Provides attributes for secure HTTP connector.
25- * Returns map of key:value corresponding with attributes in Tomcat server.xml.
25+ * Returns Node applicable into Tomcat server.xml.
2626 */
27- Map< String , Object > secureHttpConnector () {
27+ Node secureHttpConnector () {
2828 return new SecureHttpTransformer (connector). transform()
2929 }
3030
3131 /**
3232 * Provides attributes for AJP connector.
33- * Returns map of key:value corresponding with attributes in Tomcat server.xml.
33+ * Returns Node applicable into Tomcat server.xml.
3434 */
35- Map< String , Object > ajpConnector () {
35+ Node ajpConnector () {
3636 return new CommonConnectorTransformer (connector). transform()
3737 }
3838
@@ -47,51 +47,65 @@ class ConnectorAttributesTransformer {
4747 this . connector = connector
4848 }
4949
50- Map< String , Object > transform () {
51- Map<String , Object > res = [:]
50+ Node transform () {
51+ Map<String , Object > attributes = [:]
5252
53+ // -- attributes -------------------------
5354 if (connector. getPort() != null && connector. getPort() > 0 ) {
54- res . put(' port' , connector. getPort())
55+ attributes . put(' port' , connector. getPort())
5556 }
5657 if (connector. getProtocol() != null && ! connector. getProtocol(). isEmpty()) {
57- res . put(' protocol' , connector. getProtocol())
58+ attributes . put(' protocol' , connector. getProtocol())
5859 }
5960 if (connector. getSecure() != null ) {
60- res . put(' secure' , connector. getSecure())
61+ attributes . put(' secure' , connector. getSecure())
6162 }
6263 if (connector. getScheme() != null && ! connector. getScheme(). isEmpty()) {
63- res . put(' scheme' , connector. getScheme())
64+ attributes . put(' scheme' , connector. getScheme())
6465 }
6566
6667 if (connector. getMaxThreads() != null && connector. getMaxThreads() > 0 ) {
67- res . put(' maxThreads' , connector. getMaxThreads())
68+ attributes . put(' maxThreads' , connector. getMaxThreads())
6869 }
6970 if (connector. getAddress() != null && ! connector. getAddress(). isEmpty()) {
70- res . put(' address' , connector. getAddress())
71+ attributes . put(' address' , connector. getAddress())
7172 }
7273 if (connector. getConnectionTimeout() != null && connector. getConnectionTimeout() > 0 ) {
73- res . put(' connectionTimeout' , connector. getConnectionTimeout())
74+ attributes . put(' connectionTimeout' , connector. getConnectionTimeout())
7475 }
7576 if (connector. getRedirectPort() != null && connector. getRedirectPort() > 0 ) {
76- res . put(' redirectPort' , connector. getRedirectPort())
77+ attributes . put(' redirectPort' , connector. getRedirectPort())
7778 }
7879
7980 if (connector instanceof AjpConnectorTomcat ) {
8081 if (connector. getSecretRequired() != null ) {
81- res . put(' secretRequired' , connector. getSecretRequired())
82+ attributes . put(' secretRequired' , connector. getSecretRequired())
8283 }
8384
8485 if (connector. getSecret() != null && ! connector. getSecret(). isEmpty()) {
85- res . put(' secret' , connector. getSecret())
86+ attributes . put(' secret' , connector. getSecret())
8687 }
8788
8889 if (connector. getAllowedRequestAttributesPattern() != null
8990 && ! connector. getAllowedRequestAttributesPattern(). isEmpty()) {
90- res . put(' allowedRequestAttributesPattern' , connector. getAllowedRequestAttributesPattern())
91+ attributes . put(' allowedRequestAttributesPattern' , connector. getAllowedRequestAttributesPattern())
9192 }
9293 }
94+ // ---------------------
9395
94- return res
96+
97+ Node node = new Node (null , " Connector" , attributes)
98+
99+
100+ // -- sub elements -----
101+ if (connector instanceof NonSecureHttpConnectorTomcat ) {
102+ if (connector. getUpgradeProtocol() != null ) {
103+ node. appendNode(" UpgradeProtocol" , [' className' : connector. getUpgradeProtocol(). getClassName()])
104+ }
105+ }
106+ // --------------------
107+
108+ return node
95109 }
96110 }
97111
@@ -102,39 +116,69 @@ class ConnectorAttributesTransformer {
102116 this . connector = connector
103117 }
104118
105- Map<String , Object > transform () {
106- Map<String , Object > res = new CommonConnectorTransformer (connector). transform()
119+ Node transform () {
120+ Node node = new CommonConnectorTransformer (connector). transform()
121+ Map<String , Object > attributes = node. attributes()
107122
123+ // -- attributes -------------------------
108124 if (connector. getSslEnabled() != null ) {
109- res . put(' SSLEnabled' , connector. getSslEnabled())
125+ attributes . put(' SSLEnabled' , connector. getSslEnabled())
110126 }
111127
112128 // SSL BIO and NIO
113129 if (connector. getSslProtocol() != null && ! connector. getSslProtocol(). isEmpty()) {
114- res . put(' sslProtocol' , connector. getSslProtocol())
130+ attributes . put(' sslProtocol' , connector. getSslProtocol())
115131 }
116132 if (connector. getKeystoreFile() != null && ! connector. getKeystoreFile(). isEmpty()) {
117- res . put(' keystoreFile' , connector. getKeystoreFile())
133+ attributes . put(' keystoreFile' , connector. getKeystoreFile())
118134 }
119135 if (connector. getKeystorePass() != null && ! connector. getKeystorePass(). isEmpty()) {
120- res. put(' keystorePass' , connector. getKeystorePass())
136+ attributes. put(' keystorePass' , connector. getKeystorePass())
137+ }
138+ if (connector. getKeystoreType() != null && ! connector. getKeystoreType(). isEmpty()) {
139+ attributes. put(' keystoreType' , connector. getKeystoreType())
140+ }
141+ if (connector. getTruststoreFile() != null && ! connector. getTruststoreFile(). isEmpty()) {
142+ attributes. put(' truststoreFile' , connector. getTruststoreFile())
143+ }
144+ if (connector. getTruststorePass() != null && ! connector. getTruststorePass(). isEmpty()) {
145+ attributes. put(' truststorePass' , connector. getTruststorePass())
146+ }
147+ if (connector. getTruststoreType() != null && ! connector. getTruststoreType(). isEmpty()) {
148+ attributes. put(' truststoreType' , connector. getTruststoreType())
121149 }
122150 if (connector. getClientAuth() != null ) {
123- res. put(' clientAuth' , connector. getClientAuth())
151+ attributes. put(' clientAuth' , connector. getClientAuth())
152+ }
153+
154+ // HTTP2
155+ if (connector. getSslImplementationName() != null && ! connector. getSslImplementationName(). isEmpty()) {
156+ attributes. put(' sslImplementationName' , connector. getSslImplementationName())
124157 }
125158
126159 // SSL APR
127160 if (connector. getSslCertificateFile() != null && ! connector. getSslCertificateFile(). isEmpty()) {
128- res. put(' SSLCertificateFile' , connector. getSslCertificateFile())
161+ attributes. put(' SSLCertificateFile' , connector. getSslCertificateFile())
162+ }
163+ if (connector. getSslCACertificateFile() != null && ! connector. getSslCACertificateFile(). isEmpty()) {
164+ attributes. put(' SSLCACertificateFile' , connector. getSslCACertificateFile())
129165 }
130166 if (connector. getSslCertificateKeyFile() != null && ! connector. getSslCertificateKeyFile(). isEmpty()) {
131- res . put(' SSLCertificateKeyFile' , connector. getSslCertificateKeyFile())
167+ attributes . put(' SSLCertificateKeyFile' , connector. getSslCertificateKeyFile())
132168 }
133169 if (connector. getSslPassword() != null && ! connector. getSslPassword(). isEmpty()) {
134- res. put(' SSLPassword' , connector. getSslPassword())
170+ attributes. put(' SSLPassword' , connector. getSslPassword())
171+ }
172+ if (connector. getSslEnabledProtocols() != null && connector. getSslEnabledProtocols()) {
173+ attributes. put(' sslEnabledProtocols' , connector. getSslEnabledProtocols())
174+ }
175+ // ---------------------
176+
177+ if (connector. getUpgradeProtocol() != null ) {
178+ node. appendNode(" UpgradeProtocol" , [' className' : connector. getUpgradeProtocol(). getClassName()])
135179 }
136180
137- return res
181+ return node
138182 }
139183 }
140184
0 commit comments