java - Location of AntiSamy policy file in web project -


i'm trying use antisamy prevent xss attacks on site. downloaded following jars , added them "/web-inf/lib"

  • antisamy-1.5.3.jar

  • nekohtml.jar

  • xercesimpl-2.5.0.jar

along policy file antisamy-slashdot-1.4.4.xml in "/web-inf".

i tried implement filter through web.xml. snippet of servlet i'm using is

public class antisamyfilter implements filter {  private static final logger log = logger.getlogger(antisamyfilter.class);  private final antisamy antisamy;  public antisamyfilter() {     try {         url url = this.getclass().getclassloader().getresource("antisamy-slashdot-1.4.4.xml");         log.info("after getresource");         policy policy = policy.getinstance(url.getfile()); //deployment fails         log.info("after policy");         antisamy = new antisamy(policy);         log.info("after antisamy");     } catch (policyexception e) {         throw new illegalstateexception(e.getmessage(), e);     } } } 

the deployment fails after policy policy = policy.getinstance(url.getfile());. it's because of path of policy file.

can please tell me policy file should kept?

the url.getfile part fails because couldn't find antisamy-slashdot-1.4.4.xml file. created package in src/my/package , changed

url url = this.getclass().getclassloader().getresource("antisamy-slashdot-1.4.4.xml"); 

to

url url = this.getclass().getclassloader().getresource("/my/package/antisamy-slashdot-1.4.4.xml"); 

i added batik.jar along other jar files. solved problem


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -