Quantcast
Channel: Adobe Community : Popular Discussions - CQ5 (read only)
Viewing all articles
Browse latest Browse all 12476

How to access XSSAPI from custom jsp Java class?

$
0
0

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;    }
}

Viewing all articles
Browse latest Browse all 12476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>