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/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
protected static java.nio.file.LinkOption[]
FOLLOW_LINKS
protected static java.nio.file.LinkOption[]
NO_FOLLOW_LINKS
-
Constructor Summary
Constructors Constructor Description AllowedResourceAliasChecker(ContextHandler contextHandler)
-
Method Summary
All 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)
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
-
-
-
-
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)
-
getPath
protected java.nio.file.Path getPath(Resource resource)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractLifeCycle
-
-