Class InetAccessHandler
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandlerContainer
org.eclipse.jetty.server.handler.HandlerWrapper
org.eclipse.jetty.server.handler.InetAccessHandler
- All Implemented Interfaces:
Handler, HandlerContainer, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
InetAddress Access Handler
Controls access to the wrapped handler using the real remote IP. Control is
provided by and IncludeExcludeSet over a InetAddressSet. This
handler uses the real internet address of the connection, not one reported in
the forwarded for headers, as this cannot be as easily forged.
Additionally, there may be times when you want to only apply this handler to a subset of your connectors. In this situation you can use connectorNames to specify the connector names that you want this IP access filter to apply to.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractHandler
AbstractHandler.ErrorDispatchHandlerNested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IncludeExcludeSet<String, InetAddress> private final IncludeExclude<String> private static final LoggerFields inherited from class HandlerWrapper
_handler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all the includes, excludes, included connector names and excluded connector names.voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.voidExcludes an InetAddress patternvoidExcludes InetAddress patternsvoidexcludeConnector(String name) Excludes a connector name.voidexcludeConnectors(String... names) Excludes connector names.voidhandle(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Checks the incoming request against the whitelist and blacklistvoidIncludes an InetAddress patternvoidIncludes InetAddress patternsvoidincludeConnector(String name) Includes a connector name.voidincludeConnectors(String... names) Includes connector names.protected booleanisAllowed(InetAddress addr, Request baseRequest, javax.servlet.http.HttpServletRequest request) Checks if specified address and request are allowed by current InetAddress rules.Methods inherited from class HandlerWrapper
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerMethods inherited from class AbstractHandlerContainer
doShutdown, expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerMethods inherited from class AbstractHandler
doError, doStart, doStop, getServerMethods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, 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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Field Details
-
LOG
-
_addrs
-
_names
-
-
Constructor Details
-
InetAccessHandler
public InetAccessHandler()
-
-
Method Details
-
clear
public void clear()Clears all the includes, excludes, included connector names and excluded connector names. -
include
Includes an InetAddress pattern- Parameters:
pattern- InetAddress pattern to include- See Also:
-
include
Includes InetAddress patterns- Parameters:
patterns- InetAddress patterns to include- See Also:
-
exclude
Excludes an InetAddress pattern- Parameters:
pattern- InetAddress pattern to exclude- See Also:
-
exclude
Excludes InetAddress patterns- Parameters:
patterns- InetAddress patterns to exclude- See Also:
-
includeConnector
Includes a connector name.- Parameters:
name- Connector name to include in this handler.
-
excludeConnector
Excludes a connector name.- Parameters:
name- Connector name to exclude in this handler.
-
includeConnectors
Includes connector names.- Parameters:
names- Connector names to include in this handler.
-
excludeConnectors
Excludes connector names.- Parameters:
names- Connector names to exclude in this handler.
-
handle
public void handle(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException Checks the incoming request against the whitelist and blacklist- Specified by:
handlein interfaceHandler- Overrides:
handlein classHandlerWrapper- Parameters:
target- The target of the request - either a URI or a name.baseRequest- The original unwrapped request object.request- The request either as theRequestobject or a wrapper of that request. Themethod can be used access the Request object if required.HttpConnection.getCurrentConnection().getHttpChannel().getRequest()response- The response as theResponseobject or a wrapper of that request. Themethod can be used access the Response object if required.HttpConnection.getCurrentConnection().getHttpChannel().getResponse()- Throws:
IOException- if unable to handle the request or response processingjavax.servlet.ServletException- if unable to handle the request or response due to underlying servlet issue
-
isAllowed
protected boolean isAllowed(InetAddress addr, Request baseRequest, javax.servlet.http.HttpServletRequest request) Checks if specified address and request are allowed by current InetAddress rules.- Parameters:
addr- the inetAddress to checkbaseRequest- the base request to checkrequest- the HttpServletRequest request to check- Returns:
- true if inetAddress and request are allowed
-
dump
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Overrides:
dumpin classContainerLifeCycle- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-