Hi,
I am creating a custom tag library using http://www.cqblueprints.com/xwiki/bin/view/Blue+Prints/Writing+A+JSP+Custom+Tag+Library to produce XSS-proof links from my custom components. I have taken this to a tag since I will need to do other bits of work and to avoid writing scriptlets on the JSP files (I have posted the code at the end).
I wanted to use the XSSAPI from my Java class, but looking at the javadoc this class http://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/xss/XSSAPI.html it's an interface, when using it in a JSP file it's an object that is initialized invoking <cq:defineObjects/>
Does anyone have any ideas on how to do this? There is a method in the XSSAPI class called getRequestSpecificAPI(slingRequest) but it's not static, and I have run out of ideas right now.
@JspTag public class FixInternalLinkTag extends CqSimpleTagSupport { private String pathToPage; @Override public void doTag() throws JspException, IOException { XSSAPI xssAPI; // ToDo how to get a reference to this? urlPointingToPage = xssAPI.getValidHref(urlPointingToPage); getJspWriter().write(urlPointingToPage); } public String getPathToPage() { return pathToPage; } @JspTagAttribute(required = true, rtexprvalue = true) public void setPathToPage(String pathToPage) { this.pathToPage = pathToPage; } }