public class PackageResourceGuard extends Object implements IPackageResourceGuard
IPackageResourceGuard
. By default, the extensions 'properties',
'class' and 'java' are blocked and also files like 'log4j.xml' and 'applicationContext.xml'
A more secure implementation which by default denies access to any resource is
SecurePackageResourceGuard
Constructor and Description |
---|
PackageResourceGuard()
Construct.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(String path)
Whether the package resource that can be reached using the provided parameters may be
accessed.
|
protected boolean |
acceptExtension(String extension)
Whether the provided extension is accepted.
|
protected boolean |
acceptFile(String file)
Whether the provided filename is accepted.
|
protected Set<String> |
getBlockedExtensions()
Gets the set of extensions that are denied access.
|
protected Set<String> |
getBlockedFiles()
Gets the set of extensions that are denied access.
|
boolean |
isAllowAccessToRootResources()
Checks whether or not resources in the web root folder can be access.
|
void |
setAllowAccessToRootResources(boolean allowAccessToRootResources)
Sets whether or not resources in the web root folder can be accessed.
|
protected void |
setBlockedExtensions(Set<String> blockedExtensions)
Sets the set of extensions that are denied access.
|
protected void |
setBlockedFiles(Set<String> blockedFiles)
Sets the set of filenames that are denied access.
|
public boolean accept(String path)
IPackageResourceGuard
accept
in interface IPackageResourceGuard
path
- The absolute path, starting from the class root (packages are separated with
forward slashes instead of dots).IPackageResourceGuard.accept(java.lang.String)
protected boolean acceptExtension(String extension)
extension
- The extension, starting from the class root (packages are separated with forward
slashes instead of dots).protected boolean acceptFile(String file)
file
- filenameprotected final Set<String> getBlockedExtensions()
protected final Set<String> getBlockedFiles()
protected final void setBlockedExtensions(Set<String> blockedExtensions)
blockedExtensions
- Set of extensions that are denied accessprotected final void setBlockedFiles(Set<String> blockedFiles)
blockedFiles
- Set of extensions that are denied accesspublic final boolean isAllowAccessToRootResources()
true
iff root resources can be accessedpublic final void setAllowAccessToRootResources(boolean allowAccessToRootResources)
allowAccessToRootResources
- Copyright © 2006–2022 Apache Software Foundation. All rights reserved.