Package org.apache.coyote.ajp
Class AbstractAjpProtocol<S>
- java.lang.Object
-
- org.apache.coyote.AbstractProtocol<S>
-
- org.apache.coyote.ajp.AbstractAjpProtocol<S>
-
- Type Parameters:
S- The type of socket used by the implementation
- All Implemented Interfaces:
javax.management.MBeanRegistration,ProtocolHandler
- Direct Known Subclasses:
AjpNio2Protocol,AjpNioProtocol
public abstract class AbstractAjpProtocol<S> extends AbstractProtocol<S>
This the base implementation for the AJP protocol handlers. Implementations typically extend this base class rather than implementProtocolHandler. All of the implementations that ship with Tomcat are implemented this way.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.coyote.AbstractProtocol
AbstractProtocol.ConnectionHandler<S>, AbstractProtocol.RecycledProcessors
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringManagersmThe string manager for this package.-
Fields inherited from class org.apache.coyote.AbstractProtocol
adapter, domain, mserver, oname, processorCache, rgOname
-
-
Constructor Summary
Constructors Constructor Description AbstractAjpProtocol(AbstractEndpoint<S,?> endpoint)Creates a new AJP protocol handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddSslHostConfig(SSLHostConfig sslHostConfig)Adds an SSL host configuration.voidaddSslHostConfig(SSLHostConfig sslHostConfig, boolean replace)Adds an SSL host configuration.voidaddUpgradeProtocol(UpgradeProtocol upgradeProtocol)Adds an upgrade protocol.protected ProcessorcreateProcessor()Creates a new AJP processor.protected ProcessorcreateUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken)Creates an upgrade processor.SSLHostConfig[]findSslHostConfigs()Finds SSL host configurations.UpgradeProtocol[]findUpgradeProtocols()Finds upgrade protocols.booleangetAjpFlush()Gets whether AJP flush packets are used.java.lang.StringgetAllowedRequestAttributesPattern()Gets the pattern for allowed request attributes.protected java.util.regex.PatterngetAllowedRequestAttributesPatternInternal()Gets the compiled pattern for allowed request attributes.intgetDesiredBufferSize()Gets the desired buffer size for AJP packets.protected AbstractEndpoint<S,?>getEndpoint()Gets the endpoint.protected UpgradeProtocolgetNegotiatedProtocol(java.lang.String name)Find a suitable handler for the protocol negotiated at the network layer.intgetPacketSize()Gets the AJP packet size.protected java.lang.StringgetProtocolName()Gets the name of the protocol.protected java.lang.StringgetRequiredSecret()Deprecated.Replaced bygetSecret().protected java.lang.StringgetSecret()Gets the secret that must be included with every request.booleangetSecretRequired()Gets whether a secret is required with every request.booleangetTomcatAuthentication()Should authentication be done in the native web server layer, or in the Servlet container ?booleangetTomcatAuthorization()Should authentication be done in the native web server layer and authorization in the Servlet container?protected UpgradeProtocolgetUpgradeProtocol(java.lang.String name)Find a suitable handler for the protocol upgraded name specified.voidsetAjpFlush(boolean ajpFlush)Configure whether to aend an AJP flush packet when flushing.voidsetAllowedRequestAttributesPattern(java.lang.String allowedRequestAttributesPattern)Sets the pattern for allowed request attributes.voidsetPacketSize(int packetSize)Sets the AJP packet size.voidsetRequiredSecret(java.lang.String requiredSecret)Deprecated.Replaced bysetSecret(String).voidsetSecret(java.lang.String secret)Set the secret that must be included with every request.voidsetSecretRequired(boolean secretRequired)Sets whether a secret is required with every request.voidsetTomcatAuthentication(boolean tomcatAuthentication)Sets whether authentication should be done in Tomcat.voidsetTomcatAuthorization(boolean tomcatAuthorization)Sets whether authorization should be done by Tomcat.voidstart()Starts the AJP protocol handler.-
Methods inherited from class org.apache.coyote.AbstractProtocol
addWaitingProcessor, awaitConnectionsClose, closeServerSocketGraceful, destroy, getAcceptCount, getAcceptorThreadPriority, getAdapter, getAddress, getClientCertProvider, getConnectionCount, getConnectionLinger, getConnectionTimeout, getDomain, getExecutor, getGlobalRequestProcessorMBeanName, getHandler, getId, getKeepAliveTimeout, getLocalPort, getLog, getMaxConnections, getMaxHeaderCount, getMaxQueueSize, getMaxThreads, getMinSpareThreads, getName, getNameIndex, getNamePrefix, getObjectName, getPort, getPortOffset, getPortWithOffset, getProcessorCache, getProperty, getTcpNoDelay, getThreadPriority, getUtilityExecutor, getWaitingProcessorCount, init, isPaused, isSendfileSupported, pause, postDeregister, postRegister, preDeregister, preRegister, removeWaitingProcessor, resume, setAcceptCount, setAcceptorThreadPriority, setAdapter, setAddress, setClientCertProvider, setConnectionLinger, setConnectionTimeout, setExecutor, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxHeaderCount, setMaxQueueSize, setMaxThreads, setMinSpareThreads, setPort, setPortOffset, setProcessorCache, setProperty, setTcpNoDelay, setThreadPriority, setUtilityExecutor, startAsyncTimeout, stop, stopAsyncTimeout
-
-
-
-
Field Detail
-
sm
protected static final StringManager sm
The string manager for this package.
-
-
Constructor Detail
-
AbstractAjpProtocol
public AbstractAjpProtocol(AbstractEndpoint<S,?> endpoint)
Creates a new AJP protocol handler.- Parameters:
endpoint- The endpoint for low-level network I/O
-
-
Method Detail
-
getProtocolName
protected java.lang.String getProtocolName()
Gets the name of the protocol.- Specified by:
getProtocolNamein classAbstractProtocol<S>- Returns:
- the protocol name
-
getEndpoint
protected AbstractEndpoint<S,?> getEndpoint()
Gets the endpoint. Overridden to make getter accessible to other classes in this package.- Overrides:
getEndpointin classAbstractProtocol<S>- Returns:
- the endpoint
-
getNegotiatedProtocol
protected UpgradeProtocol getNegotiatedProtocol(java.lang.String name)
Find a suitable handler for the protocol negotiated at the network layer. AJP does not support protocol negotiation so this always returns null.- Specified by:
getNegotiatedProtocolin classAbstractProtocol<S>- Parameters:
name- The name of the requested negotiated protocol.- Returns:
- The instance where
UpgradeProtocol.getAlpnName()matches the requested protocol
-
getUpgradeProtocol
protected UpgradeProtocol getUpgradeProtocol(java.lang.String name)
Find a suitable handler for the protocol upgraded name specified. This is used for direct connection protocol selection. AJP does not support protocol upgrade so this always returns null.- Specified by:
getUpgradeProtocolin classAbstractProtocol<S>- Parameters:
name- The name of the requested negotiated protocol.- Returns:
- The instance where
UpgradeProtocol.getAlpnName()matches the requested protocol
-
getAjpFlush
public boolean getAjpFlush()
Gets whether AJP flush packets are used.- Returns:
trueif flush packets are used
-
setAjpFlush
public void setAjpFlush(boolean ajpFlush)
Configure whether to aend an AJP flush packet when flushing. A flush packet is a zero byte AJP13 SEND_BODY_CHUNK packet. mod_jk and mod_proxy_ajp interpret this as a request to flush data to the client. AJP always does flush at the end of the response, so if it is not important, that the packets get streamed up to the client, do not use extra flush packets. For compatibility and to stay on the safe side, flush packets are enabled by default.- Parameters:
ajpFlush- The new flush setting
-
getTomcatAuthentication
public boolean getTomcatAuthentication()
Should authentication be done in the native web server layer, or in the Servlet container ?- Returns:
trueif authentication should be performed by Tomcat, otherwisefalse
-
setTomcatAuthentication
public void setTomcatAuthentication(boolean tomcatAuthentication)
Sets whether authentication should be done in Tomcat.- Parameters:
tomcatAuthentication-trueif authentication should be performed by Tomcat
-
getTomcatAuthorization
public boolean getTomcatAuthorization()
Should authentication be done in the native web server layer and authorization in the Servlet container?- Returns:
trueif authorization should be performed by Tomcat, otherwisefalse
-
setTomcatAuthorization
public void setTomcatAuthorization(boolean tomcatAuthorization)
Sets whether authorization should be done by Tomcat.- Parameters:
tomcatAuthorization-trueif authorization should be performed by Tomcat
-
setSecret
public void setSecret(java.lang.String secret)
Set the secret that must be included with every request.- Parameters:
secret- The required secret
-
getSecret
protected java.lang.String getSecret()
Gets the secret that must be included with every request.- Returns:
- the secret
-
setRequiredSecret
@Deprecated public void setRequiredSecret(java.lang.String requiredSecret)
Deprecated.Replaced bysetSecret(String). Will be removed in Tomcat 11 onwardsSet the required secret that must be included with every request.- Parameters:
requiredSecret- The required secret
-
getRequiredSecret
@Deprecated protected java.lang.String getRequiredSecret()
Deprecated.Replaced bygetSecret(). Will be removed in Tomcat 11 onwards- Returns:
- The current secret
-
setSecretRequired
public void setSecretRequired(boolean secretRequired)
Sets whether a secret is required with every request.- Parameters:
secretRequired-trueif a secret is required
-
getSecretRequired
public boolean getSecretRequired()
Gets whether a secret is required with every request.- Returns:
trueif a secret is required
-
setAllowedRequestAttributesPattern
public void setAllowedRequestAttributesPattern(java.lang.String allowedRequestAttributesPattern)
Sets the pattern for allowed request attributes.- Parameters:
allowedRequestAttributesPattern- The regex pattern
-
getAllowedRequestAttributesPattern
public java.lang.String getAllowedRequestAttributesPattern()
Gets the pattern for allowed request attributes.- Returns:
- the pattern string
-
getAllowedRequestAttributesPatternInternal
protected java.util.regex.Pattern getAllowedRequestAttributesPatternInternal()
Gets the compiled pattern for allowed request attributes.- Returns:
- the pattern
-
getPacketSize
public int getPacketSize()
Gets the AJP packet size.- Returns:
- the packet size
-
setPacketSize
public void setPacketSize(int packetSize)
Sets the AJP packet size.- Parameters:
packetSize- The packet size (must be at least MAX_PACKET_SIZE)
-
getDesiredBufferSize
public int getDesiredBufferSize()
Gets the desired buffer size for AJP packets.- Returns:
- the desired buffer size
-
addSslHostConfig
public void addSslHostConfig(SSLHostConfig sslHostConfig)
Adds an SSL host configuration. AJP does not support SSL so this logs a warning.- Parameters:
sslHostConfig- The SSL host configuration
-
addSslHostConfig
public void addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace)
Adds an SSL host configuration. AJP does not support SSL so this logs a warning.- Parameters:
sslHostConfig- The SSL host configurationreplace- Whether to replace existing configurations
-
findSslHostConfigs
public SSLHostConfig[] findSslHostConfigs()
Finds SSL host configurations. AJP does not support SSL so this always returns an empty array.- Returns:
- an empty array
-
addUpgradeProtocol
public void addUpgradeProtocol(UpgradeProtocol upgradeProtocol)
Adds an upgrade protocol. AJP does not support upgrade so this logs a warning.- Parameters:
upgradeProtocol- The upgrade protocol
-
findUpgradeProtocols
public UpgradeProtocol[] findUpgradeProtocols()
Finds upgrade protocols. AJP does not support upgrade so this always returns an empty array.- Returns:
- an empty array
-
createProcessor
protected Processor createProcessor()
Creates a new AJP processor.- Specified by:
createProcessorin classAbstractProtocol<S>- Returns:
- the processor
-
createUpgradeProcessor
protected Processor createUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken)
Creates an upgrade processor. AJP does not support upgrade so this always throws.- Specified by:
createUpgradeProcessorin classAbstractProtocol<S>- Parameters:
socket- The socket wrapperupgradeToken- The upgrade token- Returns:
- never returns
- Throws:
java.lang.IllegalStateException- always
-
start
public void start() throws java.lang.ExceptionStarts the AJP protocol handler. Validates that a secret is configured if required.- Specified by:
startin interfaceProtocolHandler- Overrides:
startin classAbstractProtocol<S>- Throws:
java.lang.Exception- if start fails
-
-