- All Implemented Interfaces:
Handler, HandlerContainer, Container, Destroyable, Dumpable, LifeCycle
Block certain Host headers to prevent DNS rebinding attacks. This Handler wraps the ContextHandlerCollection, which handles all the webapps (not just routerconsole). Therefore, this protects all the webapps. This class is NOT used for the webapp or the bare ServerSocket implementation.
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.ListenerField Summary
FieldsModifier and TypeFieldDescriptionprivate final I2PAppContextSupplies the configuration and the log.Host names the service will answer for.Fields inherited from class HandlerWrapper
_handlerFields inherited from class AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPINGConstructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate booleanShould we allow a request with this Host header? ref: https://en.wikipedia.org/wiki/DNS_rebindingprivate static StringStrip [] and port from a host headervoidhandle(String pathInContext, Request baseRequest, HttpServletRequest httpRequest, HttpServletResponse httpResponse) Block by Host header, pass everything else to the delegate.voidsetListenHosts(Set<String> hosts) Set the legal hosts.Methods inherited from class HandlerWrapper
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerMethods inherited from class AbstractHandlerContainer
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerMethods inherited from class AbstractHandler
doStart, doStop, dumpThis, getServerMethods inherited from class ContainerLifeCycle
addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansMethods inherited from class AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
Field Details
_context
Supplies the configuration and the log._listenHosts
Constructor Details
HostCheckHandler
MUST callsetListenHosts(Set)afterwards.- Parameters:
ctx- application context, used to obtain the log for rejected Host headers
Method Details
setListenHosts
handle
public void handle(String pathInContext, Request baseRequest, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException Block by Host header, pass everything else to the delegate.- Specified by:
handlein interfaceHandler- Overrides:
handlein classHandlerWrapper- Throws:
IOExceptionServletException
allowHost
Should we allow a request with this Host header? ref: https://en.wikipedia.org/wiki/DNS_rebinding- Parameters:
host- the HTTP Host header, null ok- Returns:
- true if OK
getHost