Package org.jasig.portlet.cms.service
Class AntiSamyStringCleaningService
java.lang.Object
org.jasig.portlet.cms.service.AntiSamyStringCleaningService
- All Implemented Interfaces:
IStringCleaningService,org.springframework.beans.factory.InitializingBean
@Component public class AntiSamyStringCleaningService extends Object implements IStringCleaningService, org.springframework.beans.factory.InitializingBean
AntiSamyStringCleaningService provides an implementation of the
IStringCleaningService interface that uses OWASP's AntiSamy tool to perform
HTML string cleaning. This implementation's behavior is controlled by
a configured policy file.
- Version:
- $Revision$
- Author:
- Jen Bourey, jbourey@unicon.net
-
Constructor Summary
Constructors Constructor Description AntiSamyStringCleaningService() -
Method Summary
Modifier and Type Method Description voidafterPropertiesSet()protected org.owasp.validator.html.AntiSamygetAntiSamyInstance()Just returns a new AntiSamy instance.StringgetSafeContent(String content)Return a safe HTML string version of the provided content.StringgetTextContent(String content)Return a safe text string version of the provided content.voidsetResource(org.springframework.core.io.Resource resource)Set the resource to be used as the AntiSamy policy file.voidsetTextOnlyPolicy(org.springframework.core.io.Resource resource)Set the resource to be used as the AntiSamy policy file.
-
Constructor Details
-
AntiSamyStringCleaningService
public AntiSamyStringCleaningService()
-
-
Method Details
-
setResource
public void setResource(org.springframework.core.io.Resource resource)Set the resource to be used as the AntiSamy policy file.- Parameters:
resource- resource to use
-
setTextOnlyPolicy
public void setTextOnlyPolicy(org.springframework.core.io.Resource resource)Set the resource to be used as the AntiSamy policy file.- Parameters:
resource- resource to use
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
getSafeContent
Description copied from interface:IStringCleaningServiceReturn a safe HTML string version of the provided content.- Specified by:
getSafeContentin interfaceIStringCleaningService- Parameters:
content- content to clean- Returns:
- cleaned content
-
getTextContent
Description copied from interface:IStringCleaningServiceReturn a safe text string version of the provided content.- Specified by:
getTextContentin interfaceIStringCleaningService- Parameters:
content- content to clean- Returns:
- cleaned content
-
getAntiSamyInstance
protected org.owasp.validator.html.AntiSamy getAntiSamyInstance()Just returns a new AntiSamy instance. This method is mostly to help enable unit tests.- Returns:
- new AntiSamy instance
-