Class CmsProtectedStaticFileHandler
- All Implemented Interfaces:
I_CmsConfigurationParameterHandler,I_CmsNeedsAdminCmsObject,I_CmsResourceInit,I_CmsCustomLinkRenderer
Resources are accessed by appending their VFS root path to the /staticresource handler path. When resources are requested this way, they are still loaded with the normal OpenCms loader mechanism. This works for the intended use case (binary files, images) but may not work for other types.
The resources accessible through this handler can be restricted by setting regex configuration parameters for path and type which the requested resources have to match.
This can be used in combination with the CmsJsonResourceHandler class. When configured correctly (using the linkrewrite.id parameter on this handler, and a matching linkrewrite.refid on the CmsJsonResourceHandler), links to resources this handler is responsible for will be rewritten to point to the URL for the resource using this handler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConfiguration parameter that determines which authorization method to use.static final StringParameter for defining the id under which the link renderer should be registered.static final Stringstatic final StringConfiguration parameter for the path filter regex.static final StringConfiguration parameter for the type filter regex.static final StringURL prefix.Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHODFields inherited from interface org.opencms.main.I_CmsResourceInit
ATTR_ALTERNATIVE_CMS_OBJECT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfigurationParameter(String paramName, String paramValue) Adds a configuration parameter to this parameter configurable class instance.Gets the configuration data.getLink(CmsObject cms, CmsResource resource) Returns the link for the given link resource.Returns the link for the given link object.voidInitializes a configuration after all parameters have been added.initResource(CmsResource origRes, CmsObject cms, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Possibility to modify or change the CmsFile with the CmsObject.static StringmergeLinkPrefix(String prefix, String path, String query) Merges a link prefix with additional link components.voidsetAdminCmsObject(CmsObject adminCms) Sets the admin CmsObject.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opencms.main.I_CmsResourceInit
initParameters
-
Field Details
-
PARAM_LINKREWRITE_ID
Parameter for defining the id under which the link renderer should be registered.- See Also:
-
PARAM_AUTHORIZATION
Configuration parameter that determines which authorization method to use.- See Also:
-
PARAM_PATHFILTER
Configuration parameter for the path filter regex.- See Also:
-
PARAM_TYPEFILTER
Configuration parameter for the type filter regex.- See Also:
-
PREFIX
URL prefix.- See Also:
-
PARAM_LINKREWRITE_PREFIX
- See Also:
-
-
Constructor Details
-
CmsProtectedStaticFileHandler
public CmsProtectedStaticFileHandler()
-
-
Method Details
-
mergeLinkPrefix
Merges a link prefix with additional link components.- Parameters:
prefix- the prefixpath- the pathquery- the query- Returns:
- the combined link
-
addConfigurationParameter
Description copied from interface:I_CmsConfigurationParameterHandlerAdds a configuration parameter to this parameter configurable class instance.- Specified by:
addConfigurationParameterin interfaceI_CmsConfigurationParameterHandler- Parameters:
paramName- the name of the parameterparamValue- the value for the parameter- See Also:
-
getConfiguration
Description copied from interface:I_CmsResourceInitGets the configuration data.- Specified by:
getConfigurationin interfaceI_CmsConfigurationParameterHandler- Specified by:
getConfigurationin interfaceI_CmsResourceInit- Returns:
- the configuration data
- See Also:
-
getLink
Description copied from interface:I_CmsCustomLinkRendererReturns the link for the given link object.If null is returned, this means the normal link handling behavior should be used instead.
- Specified by:
getLinkin interfaceI_CmsCustomLinkRenderer- Parameters:
cms- the CMS contextlink- the link object- Returns:
- the link for the link object
- See Also:
-
getLink
Description copied from interface:I_CmsCustomLinkRendererReturns the link for the given link resource.If null is returned, this means the normal link handling behavior should be used instead.
- Specified by:
getLinkin interfaceI_CmsCustomLinkRenderer- Parameters:
cms- the CMS contextresource- the resource linked to- Returns:
- the link for the link object
- See Also:
-
initConfiguration
Description copied from interface:I_CmsConfigurationParameterHandlerInitializes a configuration after all parameters have been added.- Specified by:
initConfigurationin interfaceI_CmsConfigurationParameterHandler- See Also:
-
initResource
public CmsResource initResource(CmsResource origRes, CmsObject cms, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsResourceInitException Description copied from interface:I_CmsResourceInitPossibility to modify or change the CmsFile with the CmsObject.Caution: reading parameters from the request, destroys special characters in all parameters, because the encoding for the request was not set yet.
- Specified by:
initResourcein interfaceI_CmsResourceInit- Parameters:
origRes- the requested filecms- the current CmsObjectreq- the current requestres- the current response- Returns:
- a resource in the OpenCms VFS
- Throws:
CmsResourceInitException- if other implementations of the interface should not be executed- See Also:
-
setAdminCmsObject
Description copied from interface:I_CmsNeedsAdminCmsObjectSets the admin CmsObject.- Specified by:
setAdminCmsObjectin interfaceI_CmsNeedsAdminCmsObject- Parameters:
adminCms- a CmsObject with admin privileges- See Also:
-