use of org.apache.coyote.http11.Http11Nio2Protocol in project cas by apereo.
the class CasTomcatServletWebServerFactoryCustomizer method configureConnectorForProtocol.
private static void configureConnectorForProtocol(final Connector connector, final CasEmbeddedApacheTomcatHttpProxyProperties proxy) {
val handler = ReflectionUtils.findField(connector.getClass(), "protocolHandler");
if (handler != null) {
ReflectionUtils.makeAccessible(handler);
if ("HTTP/2".equalsIgnoreCase(proxy.getProtocol())) {
connector.addUpgradeProtocol(new Http2Protocol());
} else {
var protocolHandlerInstance = (AbstractProtocol) null;
switch(proxy.getProtocol()) {
case "AJP/2":
protocolHandlerInstance = new AjpNio2Protocol();
val ajp1 = AbstractAjpProtocol.class.cast(protocolHandlerInstance);
ajp1.setSecretRequired(proxy.isSecure());
ajp1.setSecret(proxy.getSecret());
break;
case "AJP/1.3":
protocolHandlerInstance = new AjpNioProtocol();
val ajp2 = AbstractAjpProtocol.class.cast(protocolHandlerInstance);
ajp2.setSecretRequired(proxy.isSecure());
ajp2.setSecret(proxy.getSecret());
break;
case "APR":
protocolHandlerInstance = new Http11AprProtocol();
break;
case "HTTP/1.2":
protocolHandlerInstance = new Http11Nio2Protocol();
break;
case "HTTP/1.1":
default:
protocolHandlerInstance = new Http11NioProtocol();
break;
}
protocolHandlerInstance.setPort(connector.getPort());
ReflectionUtils.setField(handler, connector, protocolHandlerInstance);
}
val handlerClass = ReflectionUtils.findField(connector.getClass(), "protocolHandlerClassName");
if (handlerClass != null) {
ReflectionUtils.makeAccessible(handlerClass);
ReflectionUtils.setField(handlerClass, connector, connector.getProtocolHandler().getClass().getName());
}
}
}
Aggregations