public class CssUrlAuthorizationProcessor extends CssUrlRewritingProcessor
This needs to be paired with the CssUrlRewritingProcessor for expected functionality.
It addresses a specific use case where a combination of pre/post processors are modifying URLs so that the ResourceAuthorizationManager no longer recognizes them to be retrieved from the classpath.
For example, assets stored in LESS variables are manipulated by both the CSS URL rewriter, which generates the first entry in the ResourceAuthorizationManager, and then the LESS compiler, which does not update the ResourceAuthorizationManager. This post processor simply adds any missing entries in ResourceAuthorizationManager for assets loaded from the classpath.
It should be noted that this processor exposes you to considerable risk if you use dynamic CSS provided by users, because it authorizes any and all asset loads if they are found in your CSS/LESS. It is not suitable for use in those conditions since it would allow users to retrieve any data from your classpath.
Adapted fromCssUrlRewritingProcessor and AbstractCssUrlRewritingProcessor| Constructor and Description |
|---|
CssUrlAuthorizationProcessor() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
onUrlReplaced(String replacedUrl)
Invoked when an url is replaced.
|
void |
process(Reader reader,
Writer writer)
Perform actual resource processing.
|
protected String |
replaceImageUrl(String cssUri,
String imageUrl)
Replace provided url with the new url if needed.
|
isUriAllowed, onProcessCompletedgetUrlPrefix, isImportAware, isReplaceNeeded, newCssUrlInspector, process, replaceDeclarationpublic static final String ALIAS
public void process(Reader reader, Writer writer) throws IOException
ResourcePostProcessorprocess in interface ResourcePostProcessorprocess in class AbstractCssUrlRewritingProcessorreader - source stream.writer - destination stream.IOExceptionprotected String replaceImageUrl(String cssUri, String imageUrl)
CssUrlRewritingProcessorreplaceImageUrl in class CssUrlRewritingProcessorcssUri - Uri of the parsed css.imageUrl - to replace.protected void onUrlReplaced(String replacedUrl)
AbstractCssUrlRewritingProcessoronUrlReplaced in class CssUrlRewritingProcessorreplacedUrl - the newly computed url created as a result of url rewriting.Copyright © 2008-2014. All Rights Reserved.