|
11 | 11 | import java.nio.file.Path; |
12 | 12 | import java.nio.file.Paths; |
13 | 13 | import java.util.stream.Stream; |
| 14 | +import org.apache.catalina.Host; |
14 | 15 | import org.apache.catalina.LifecycleException; |
15 | 16 | import org.apache.catalina.LifecycleListener; |
16 | 17 | import org.apache.catalina.Service; |
17 | 18 | import org.apache.catalina.connector.Connector; |
18 | 19 | import org.apache.catalina.core.StandardContext; |
19 | 20 | import org.apache.catalina.loader.WebappLoader; |
20 | 21 | import org.apache.catalina.startup.Tomcat; |
| 22 | +import org.apache.coyote.http11.Http11NioProtocol; |
| 23 | +import org.apache.coyote.http11.Http11Protocol; |
21 | 24 | import org.apache.naming.resources.VirtualDirContext; |
22 | 25 |
|
23 | 26 | public class TomcatFactory { |
@@ -51,10 +54,12 @@ private TomcatConfiguration getConfiguration() { |
51 | 54 |
|
52 | 55 | public Tomcat getTomcat() throws IOException { |
53 | 56 | Tomcat tomcat = new Tomcat(); |
| 57 | + Host host = tomcat.getHost(); |
| 58 | + host.setName("localhost"); |
54 | 59 | tomcat.setBaseDir(getConfiguration().getTomcatBaseDir()); |
55 | 60 | tomcat.setPort(getConfiguration().getTomcatPort()); |
56 | 61 | tomcat.getServer().setPort(getConfiguration().getTomcatServerPort()); |
57 | | - createDefaultConnector(tomcat); |
| 62 | + configureDefaultConnector(tomcat); |
58 | 63 | addUserWithRole(tomcat, "CN=Alfresco Repository Client, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB", null, "repoclient"); |
59 | 64 | addUserWithRole(tomcat, "CN=Alfresco Repository, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB", null, "repository"); |
60 | 65 | Path webapps = Paths.get(getConfiguration().getWebappsPath()); |
@@ -121,19 +126,15 @@ private void addWebapp(Tomcat tomcat, Path path) { |
121 | 126 | } |
122 | 127 | } |
123 | 128 |
|
124 | | - private void createDefaultConnector(Tomcat tomcat) { |
125 | | - Connector connector = getConnector(tomcat, |
126 | | - "HTTP/1.1", |
127 | | - getConfiguration().getTomcatPort(), |
128 | | - false, |
129 | | - "http", |
130 | | - getConfiguration().getTomcatMaxThreads(), |
131 | | - getConfiguration().getTomcatMaxHttpHeaderSize(), |
132 | | - getConfiguration().getTomcatRelaxedPathChars(), |
133 | | - getConfiguration().getTomcatRelaxedQueryChars() |
134 | | - ); |
135 | | - connector.setRedirectPort(getConfiguration().getTomcatSslPort()); |
136 | | - tomcat.setConnector(connector); |
| 129 | + private void configureDefaultConnector(Tomcat tomcat) { |
| 130 | + Connector connector = tomcat.getConnector(); |
| 131 | + connector.setProperty("connectionTimeout", "240000"); |
| 132 | + connector.setURIEncoding(StandardCharsets.UTF_8.name()); |
| 133 | + Http11Protocol protocol = (Http11Protocol) connector.getProtocolHandler(); |
| 134 | + protocol.setMaxThreads(getConfiguration().getTomcatMaxThreads()); |
| 135 | + protocol.setMaxHttpHeaderSize(getConfiguration().getTomcatMaxHttpHeaderSize()); |
| 136 | + protocol.setRelaxedPathChars(getConfiguration().getTomcatRelaxedPathChars()); |
| 137 | + protocol.setRelaxedQueryChars(getConfiguration().getTomcatRelaxedQueryChars()); |
137 | 138 | } |
138 | 139 |
|
139 | 140 | private void addUserWithRole(Tomcat tomcat, String username, String password, String role) { |
|
0 commit comments