Module org.apache.wicket.core
Package org.apache.wicket.markup.html
Class SecurePackageResourceGuard
java.lang.Object
org.apache.wicket.markup.html.PackageResourceGuard
org.apache.wicket.markup.html.SecurePackageResourceGuard
- All Implemented Interfaces:
IPackageResourceGuard
This is a resource guard which by default denies access to all resources and thus is more secure.
All pattern are executed in the order they were provided. All pattern are executed to determine
if access can be granted or not.
Note that access to the config data such as get/setPattern() and acceptXXX() is not synchronized.
It is assumed that configuration has finished before the first request gets executed.
The rules are fairly simple. Each pattern must start with either "+" (include) or "-" (exclude).
"*" is a placeholder for zero, one or more characters within a file or directory name. "**" is a
placeholder for zero, one or more sub-directories.
Examples:
+*.gif | All gif files in all directories |
+test*.* | All files in all directories starting with "test" |
+mydir/*/*.gif | All gif files two levels below the mydir directory. E.g. mydir/dir2/test.gif |
+mydir/**/*.gif | All gif files in all directories below mydir. E.g. mydir/test.gif or mydir/dir2/dir3/test.gif |
- Author:
- Juergen Donnerstag
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
A very simple cache -
Constructor Summary
ConstructorDescriptionConstructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether the provided absolute path is accepted.void
addPattern
(String pattern) void
Gets the current list of pattern.void
Sets pattern.Methods inherited from class org.apache.wicket.markup.html.PackageResourceGuard
acceptExtension, acceptFile, getBlockedExtensions, getBlockedFiles, isAllowAccessToRootResources, setAllowAccessToRootResources, setBlockedExtensions, setBlockedFiles
-
Constructor Details
-
SecurePackageResourceGuard
public SecurePackageResourceGuard()Constructor. -
SecurePackageResourceGuard
Constructor.- Parameters:
cache
- the internal cache that will hold the results for all already checked resources. Usenull
to disable caching.
-
-
Method Details
-
clearCache
-
accept
Whether the provided absolute path is accepted.- Specified by:
accept
in interfaceIPackageResourceGuard
- Overrides:
accept
in classPackageResourceGuard
- Parameters:
path
- The absolute path, starting from the class root (packages are separated with forward slashes instead of dots).- Returns:
- True if accepted, false otherwise.
- See Also:
-
getPattern
Gets the current list of pattern. Please invoke clearCache() or setPattern(List) when finished in order to clear the cache of previous checks.- Returns:
- pattern
-
setPattern
Sets pattern.- Parameters:
pattern
- pattern
-
addPattern
- Parameters:
pattern
-
-