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 interface
AprSocketContext.BlockingPollHandler
Callback for poll events, will be invoked in a thread pool.static interface
AprSocketContext.HostInfoLoader
Delegates loading of persistent info about a host - public certs, tickets, config, persistent info etc.static interface
AprSocketContext.NonBlockingPollHandler
Additional callbacks for non-blocking.static interface
AprSocketContext.RawDataHandler
Called when a chunk of data is sent or received.static interface
AprSocketContext.TlsCertVerifier
Called 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 long
allocatePoller(int size, long pool)
protected void
connectBlocking(AprSocket apr)
void
customVerification(AprSocketContext.TlsCertVerifier verifier)
protected void
finalize()
To clean the pools - we could track if all channels are closed, but this seems simpler and safer.int
getBacklog()
boolean
getDeferAccept()
protected Executor
getExecutor()
HostInfo
getHostInfo(String host, int port, boolean ssl)
Override or use hostInfoLoader to implement persistent/memcache storage.int
getPollerThreadCount()
String
getSSLCipherSuite()
boolean
isServer()
void
listen(int port)
protected void
onSocket(AprSocket s)
Called on each accepted socket (for servers) or after connection (client) after handshake.protected void
rawData(AprSocket ch, boolean inp, byte[] data, int pos, int len, int requested, boolean closed)
void
setBacklog(int backlog)
void
setDeferAccept(boolean deferAccept)
Defer accept.void
setHostLoader(AprSocketContext.HostInfoLoader handler)
AprSocketContext
setKeys(String certPemFile, String keyDerFile)
Set certificate, will also enable TLS mode.void
setMaxconnections(int maxCon)
void
setNpn(byte[] data)
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.void
setPollerThreadCount(int pollerThreadCount)
void
setSSLCipherSuite(String SSLCipherSuite)
void
setSslProtocol(String protocol)
void
setTcpNoDelay(boolean b)
void
setTicketKey(byte[] key48Bytes)
AprSocketContext
setTls()
All accepted/connected sockets will start handshake automatically.AprSocket
socket(long socket)
AprSocket
socket(String host, int port, boolean ssl)
Get a socket for connectiong to host:port.AprSocket
socket(HostInfo hi)
void
stop()
-
-
-
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 Throwable
To 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)
-
-