|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.hd.d.pg2k.webSvr.exhibit.TunnelServlet
public final class TunnelServlet
This serves data through an HTTP tunnel from master Web-app to authorised slaves, ie is an RPC end-point. We are communicating on the client side with ExhibitDataHTTPTunnelSource and may have (at least) one long-running open connection per slave.
Takes data from whatever the DataSourceBean is using.
This allows concurrency between different slaves, and for multiple connections from each slave, though this concurrency may be limited by resource constraints.
Notice that all operations require some degree of authentication:
Note that for messages that have a MAC:
| Nested Class Summary | |
|---|---|
private static class |
TunnelServlet.WrappedIOException
|
| Field Summary | |
|---|---|
private SecurityProps |
_gSP_cache
Cached SecurityProps; private to getSecurityProps(); never null. |
private ExhibitDataTunnelSource.HIRPCCache |
_RPC_cache
Cache/lock object to optimise handling of incoming RPCs; never null. |
private static boolean |
isDebug
If debugging locally, note some activity at protocol level. |
static int |
LARGE_FRAME_BYTES
Size in bytes of 'big' frame that may require special handling; strictly positive. |
private WebUtils.ServletLoggerWithFallback |
logger
Our logger which falls back to System.out if servlet log not available; never null. |
private static int |
MAX_TYPICAL_SERVICE_TIME_MS
Maximum expected typical service time, ms. |
private DuplicateIDChecker<ROByteArray> |
messageIDs
Record of unique request packet IDs around our acceptance window; never null. |
private static long |
serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/. |
private StatsLogger.StatsConfig |
statsIDTSV
The stats set to which we log general tunnel servlet stats. |
static java.lang.String |
TSVNAME_HTTPFAIL
General stats event name: failures handling input HTTP requests. |
static java.lang.String |
TSVNAME_HTTPREJADDR
General stats event name: inbound HTTP request rejected by client IP address. |
static java.lang.String |
TSVNAME_HTTPREJID
General stats event name: inbound HTTP request rejected by ID/passwoed. |
static java.lang.String |
TSVNAME_HTTPREJOP
General stats event name: inbound HTTP request rejected by request op-code. |
static java.lang.String |
TSVNAME_HTTPREQUEST
General stats event name: inbound HTTP request. |
static java.lang.String |
TSVNAMEP_HTTPSERVICETIME
General stats event name prefix: inbound HTTP request service time (ms exponent). |
static java.lang.String |
TSVNAMEP_HTTPSLOWOP
General stats event name prefix: slow inbound HTTP request op code. |
static java.lang.String |
TSVNAMEPR_RPCTYPE
General stats event name prefix: RPC request packet type. |
| Constructor Summary | |
|---|---|
TunnelServlet()
|
|
| Method Summary | |
|---|---|
static ExhibitDataTunnelSource |
createFromContext(javax.servlet.ServletContext ctxt)
Factory method to create an instance given the ServletContext. |
void |
destroy()
Unhook from servlet logger. |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Respond to a POST request to open and use an HTTP tunnel (for a single transfer). |
private SimpleExhibitPipelineIF |
getDataSource()
Get data source/pipeline; never returns null. |
private static DataSourceBean |
getDataSourceBean(javax.servlet.ServletContext ctxt,
javax.servlet.http.HttpServletRequest request)
Get singleton (per-servlet-context) data pipeline/cache instance. |
private SecurityProps |
getSecurityProps()
Get SecurityProps (including sensitives values); never returns null. |
void |
init(javax.servlet.ServletConfig servletConfig)
Hook into servlet logger. |
private static boolean |
isPeerMirror(DataSourceBean ds,
java.net.InetAddress addr)
Returns true iff the address is that of a (peer) mirror/slave. |
private void |
writeResponsePacketToWire(javax.servlet.http.HttpServletResponse response,
javax.crypto.SecretKey xk,
javax.servlet.ServletOutputStream os,
ExhibitDataTunnelSource.RawPacket rawResponse)
Efficiently write the raw response frame/packet to the write, with a MAC if possible. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final boolean isDebug
private final WebUtils.ServletLoggerWithFallback logger
private final StatsLogger.StatsConfig statsIDTSV
public static final java.lang.String TSVNAME_HTTPREQUEST
public static final java.lang.String TSVNAMEP_HTTPSERVICETIME
public static final java.lang.String TSVNAMEP_HTTPSLOWOP
public static final java.lang.String TSVNAME_HTTPFAIL
public static final java.lang.String TSVNAME_HTTPREJADDR
public static final java.lang.String TSVNAME_HTTPREJID
public static final java.lang.String TSVNAME_HTTPREJOP
public static final java.lang.String TSVNAMEPR_RPCTYPE
private static final int MAX_TYPICAL_SERVICE_TIME_MS
This should in fact be a tiny bit less than the total RTT, since there is a short delay from when we send the last response byte to it being processed by the receiver (eg due to transmission delays), but we ignore that for now.
public static final int LARGE_FRAME_BYTES
Almost all 'normal' inbound packets should be below this threshold.
private volatile SecurityProps _gSP_cache
private final ExhibitDataTunnelSource.HIRPCCache _RPC_cache
private final DuplicateIDChecker<ROByteArray> messageIDs
We actually remember IDs for about twice the age implied by the skew so that if our clock is wrong by, or slips by, the maximum skew, we won't start admitting very old duplicate messages.
We should only add IDs if possible when we are already fairly sure of the source and when we have, for example, already checked for acceptable skew, to make any sort of DoS attack against us harder.
We should reject otherwise-acceptable messages that have an ID already present in this Map.
Thread-safe.
private static final long serialVersionUID
| Constructor Detail |
|---|
public TunnelServlet()
| Method Detail |
|---|
public void destroy()
destroy in interface javax.servlet.Servletdestroy in class javax.servlet.GenericServlet
public void init(javax.servlet.ServletConfig servletConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class javax.servlet.GenericServletjavax.servlet.ServletException
private static DataSourceBean getDataSourceBean(javax.servlet.ServletContext ctxt,
javax.servlet.http.HttpServletRequest request)
This does not cache its return value.
private SimpleExhibitPipelineIF getDataSource()
private SecurityProps getSecurityProps()
throws java.io.IOException
TunnelServlet.WrappedIOException - if SecurityProps cannot be retrieved
(eg because no local file exists)
java.io.IOException
public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException
Normal slave servers are primarily authenticated by IP address and have full real/write access.
Uploader JWS clients are authenticated by username/password, and have partial, read-only access.
doPost in class javax.servlet.http.HttpServletTunnelServlet.WrappedIOException - if an input/output error occurs
java.io.IOException
private void writeResponsePacketToWire(javax.servlet.http.HttpServletResponse response,
javax.crypto.SecretKey xk,
javax.servlet.ServletOutputStream os,
ExhibitDataTunnelSource.RawPacket rawResponse)
throws java.security.InvalidKeyException,
java.io.IOException
java.security.InvalidKeyException
java.io.IOException
private static boolean isPeerMirror(DataSourceBean ds,
java.net.InetAddress addr)
throws java.io.IOException
No local/loopback addresses are considered valid.
ds - current data source; never nulladdr - client address; never null
java.io.IOExceptionpublic static ExhibitDataTunnelSource createFromContext(javax.servlet.ServletContext ctxt)
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||