2 Replies Latest reply on Mar 18, 2013 4:38 PM by blanquish

    How to access XSSAPI from custom jsp Java class?




      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.


      public class FixInternalLinkTag extends CqSimpleTagSupport {
          private String pathToPage;
          public void doTag() throws JspException, IOException {    
                    XSSAPI xssAPI; // ToDo how to get a reference to this?
                    urlPointingToPage = xssAPI.getValidHref(urlPointingToPage);
          public String getPathToPage() {
              return pathToPage;
          @JspTagAttribute(required = true, rtexprvalue = true)
          public void setPathToPage(String pathToPage) {
              this.pathToPage = pathToPage;