Package org.eclipse.jetty.server
Class AllowedResourceAliasChecker
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.server.AllowedResourceAliasChecker
-
- All Implemented Interfaces:
ContextHandler.AliasCheck
,LifeCycle
- Direct Known Subclasses:
SymlinkAllowedResourceAliasChecker
public class AllowedResourceAliasChecker extends AbstractLifeCycle implements ContextHandler.AliasCheck
This will approve any alias to anything inside of the
ContextHandler
s resource base which is not protected by a protected target as defined byContextHandler.getProtectedTargets()
at start.Aliases approved by this may still be able to bypass SecurityConstraints, so this class would need to be extended to enforce any additional security constraints that are required.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
AllowedResourceAliasChecker.AllowedResourceAliasCheckListener
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.file.Path
_base
private ContextHandler
_contextHandler
private AllowedResourceAliasChecker.AllowedResourceAliasCheckListener
_listener
private java.util.List<java.nio.file.Path>
_protected
protected static java.nio.file.LinkOption[]
FOLLOW_LINKS
private static Logger
LOG
protected static java.nio.file.LinkOption[]
NO_FOLLOW_LINKS
-
Constructor Summary
Constructors Constructor Description AllowedResourceAliasChecker(ContextHandler contextHandler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
check(java.lang.String pathInContext, java.nio.file.Path path)
boolean
check(java.lang.String pathInContext, Resource resource)
Check an aliasprotected void
doStart()
protected void
doStop()
protected ContextHandler
getContextHandler()
protected java.nio.file.Path
getPath(Resource resource)
private static java.nio.file.Path
getRealPath(java.nio.file.Path path)
protected void
initialize()
protected boolean
isAllowed(java.nio.file.Path path)
protected boolean
isSameFile(java.nio.file.Path path1, java.nio.file.Path path2)
java.lang.String
toString()
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
-
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
FOLLOW_LINKS
protected static final java.nio.file.LinkOption[] FOLLOW_LINKS
-
NO_FOLLOW_LINKS
protected static final java.nio.file.LinkOption[] NO_FOLLOW_LINKS
-
_contextHandler
private final ContextHandler _contextHandler
-
_protected
private final java.util.List<java.nio.file.Path> _protected
-
_listener
private final AllowedResourceAliasChecker.AllowedResourceAliasCheckListener _listener
-
_base
protected java.nio.file.Path _base
-
-
Constructor Detail
-
AllowedResourceAliasChecker
public AllowedResourceAliasChecker(ContextHandler contextHandler)
- Parameters:
contextHandler
- the context handler to use.
-
-
Method Detail
-
getContextHandler
protected ContextHandler getContextHandler()
-
initialize
protected void initialize()
-
doStart
protected void doStart() throws java.lang.Exception
- Overrides:
doStart
in classAbstractLifeCycle
- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception
- Overrides:
doStop
in classAbstractLifeCycle
- Throws:
java.lang.Exception
-
check
public boolean check(java.lang.String pathInContext, Resource resource)
Description copied from interface:ContextHandler.AliasCheck
Check an alias- Specified by:
check
in interfaceContextHandler.AliasCheck
- Parameters:
pathInContext
- The path the aliased resource was created forresource
- The aliased resourced- Returns:
- True if the resource is OK to be served.
-
check
protected boolean check(java.lang.String pathInContext, java.nio.file.Path path)
-
isAllowed
protected boolean isAllowed(java.nio.file.Path path)
-
isSameFile
protected boolean isSameFile(java.nio.file.Path path1, java.nio.file.Path path2)
-
getRealPath
private static java.nio.file.Path getRealPath(java.nio.file.Path path)
-
getPath
protected java.nio.file.Path getPath(Resource resource)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractLifeCycle
-
-