Package org.apache.tomcat.jni.socket
Class AprSocketContext
- java.lang.Object
-
- org.apache.tomcat.jni.socket.AprSocketContext
-
public class AprSocketContext extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAprSocketContext.BlockingPollHandlerCallback for poll events, will be invoked in a thread pool.static interfaceAprSocketContext.HostInfoLoaderDelegates loading of persistent info about a host - public certs, tickets, config, persistent info etc.static interfaceAprSocketContext.NonBlockingPollHandlerAdditional callbacks for non-blocking.static interfaceAprSocketContext.RawDataHandlerCalled when a chunk of data is sent or received.static interfaceAprSocketContext.TlsCertVerifierCalled in SSL mode after the handshake is completed.
-
Constructor Summary
Constructors Constructor Description AprSocketContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longallocatePoller(int size, long pool)protected voidconnectBlocking(AprSocket apr)voidcustomVerification(AprSocketContext.TlsCertVerifier verifier)protected voidfinalize()To clean the pools - we could track if all channels are closed, but this seems simpler and safer.intgetBacklog()booleangetDeferAccept()protected ExecutorgetExecutor()HostInfogetHostInfo(String host, int port, boolean ssl)Override or use hostInfoLoader to implement persistent/memcache storage.intgetPollerThreadCount()StringgetSSLCipherSuite()booleanisServer()voidlisten(int port)protected voidonSocket(AprSocket s)Called on each accepted socket (for servers) or after connection (client) after handshake.protected voidrawData(AprSocket ch, boolean inp, byte[] data, int pos, int len, int requested, boolean closed)voidsetBacklog(int backlog)voidsetDeferAccept(boolean deferAccept)Defer accept.voidsetHostLoader(AprSocketContext.HostInfoLoader handler)AprSocketContextsetKeys(String certPemFile, String keyDerFile)Set certificate, will also enable TLS mode.voidsetMaxconnections(int maxCon)voidsetNpn(byte[] data)voidsetNpn(String npn)For client: - ClientHello will include the npn extension ( the ID == 0x3374) - if ServerHello includes a list of protocols - select one - send it after ChangeCipherSpec and before Finish For server: - if ClientHello includes the npn extension -- will send this string as list of supported protocols in ServerHello - read the selection before Finish.voidsetPollerThreadCount(int pollerThreadCount)voidsetSSLCipherSuite(String SSLCipherSuite)voidsetSslProtocol(String protocol)voidsetTcpNoDelay(boolean b)voidsetTicketKey(byte[] key48Bytes)AprSocketContextsetTls()All accepted/connected sockets will start handshake automatically.AprSocketsocket(long socket)AprSocketsocket(String host, int port, boolean ssl)Get a socket for connectiong to host:port.AprSocketsocket(HostInfo hi)voidstop()
-
-
-
Method Detail
-
setPollerThreadCount
public void setPollerThreadCount(int pollerThreadCount)
-
getPollerThreadCount
public int getPollerThreadCount()
-
setMaxconnections
public void setMaxconnections(int maxCon)
-
setBacklog
public void setBacklog(int backlog)
-
getBacklog
public int getBacklog()
-
setDeferAccept
public void setDeferAccept(boolean deferAccept)
Defer accept.
-
getDeferAccept
public boolean getDeferAccept()
-
setNpn
public void setNpn(String npn)
For client: - ClientHello will include the npn extension ( the ID == 0x3374) - if ServerHello includes a list of protocols - select one - send it after ChangeCipherSpec and before Finish For server: - if ClientHello includes the npn extension -- will send this string as list of supported protocols in ServerHello - read the selection before Finish.- Parameters:
npn-
-
setNpn
public void setNpn(byte[] data)
-
setHostLoader
public void setHostLoader(AprSocketContext.HostInfoLoader handler)
-
isServer
public boolean isServer()
-
getExecutor
protected Executor getExecutor()
-
setTls
public AprSocketContext setTls()
All accepted/connected sockets will start handshake automatically.
-
setTcpNoDelay
public void setTcpNoDelay(boolean b)
-
setSslProtocol
public void setSslProtocol(String protocol)
-
setTicketKey
public void setTicketKey(byte[] key48Bytes)
-
customVerification
public void customVerification(AprSocketContext.TlsCertVerifier verifier)
-
setKeys
public AprSocketContext setKeys(String certPemFile, String keyDerFile)
Set certificate, will also enable TLS mode.
-
getSSLCipherSuite
public String getSSLCipherSuite()
-
setSSLCipherSuite
public void setSSLCipherSuite(String SSLCipherSuite)
-
getHostInfo
public HostInfo getHostInfo(String host, int port, boolean ssl)
Override or use hostInfoLoader to implement persistent/memcache storage.
-
rawData
protected void rawData(AprSocket ch, boolean inp, byte[] data, int pos, int len, int requested, boolean closed)
-
listen
public void listen(int port) throws IOException- Throws:
IOException
-
socket
public AprSocket socket(String host, int port, boolean ssl)
Get a socket for connectiong to host:port.
-
socket
public AprSocket socket(long socket)
-
connectBlocking
protected void connectBlocking(AprSocket apr) throws IOException
- Throws:
IOException
-
finalize
protected void finalize() throws ThrowableTo clean the pools - we could track if all channels are closed, but this seems simpler and safer.
-
stop
public void stop()
-
onSocket
protected void onSocket(AprSocket s)
Called on each accepted socket (for servers) or after connection (client) after handshake.
-
allocatePoller
protected long allocatePoller(int size, long pool)
-
-