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 Details

  • 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

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • getSafeContent

      public String getSafeContent​(String content)
      Description copied from interface: IStringCleaningService
      Return a safe HTML string version of the provided content.
      Specified by:
      getSafeContent in interface IStringCleaningService
      Parameters:
      content - content to clean
      Returns:
      cleaned content
    • getTextContent

      public String getTextContent​(String content)
      Description copied from interface: IStringCleaningService
      Return a safe text string version of the provided content.
      Specified by:
      getTextContent in interface IStringCleaningService
      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