public class AntiSamy extends Object
scan()
method holds the meat and potatoes of AntiSamy. The file
contains a number of ways for scan()
'ing depending on the
accessibility of the policy file.Modifier and Type | Method and Description |
---|---|
CleanResults |
scan(Reader reader,
Writer writer,
Policy policy)
Use this method if caller has Streams rather than Strings for I/O
Useful for servlets where the response is very large and we don't validate,
simply encode as bytes are consumed from the stream.
|
CleanResults |
scan(String taintedHTML)
The meat and potatoes.
|
CleanResults |
scan(String taintedHTML,
File policyFile)
This method wraps
scan() using the policy File object passed in. |
CleanResults |
scan(String taintedHTML,
int scanType)
This method sets
scan() to use the specified scan type. |
CleanResults |
scan(String taintedHTML,
Policy policy)
This method wraps
scan() using the Policy object passed in. |
CleanResults |
scan(String taintedHTML,
Policy policy,
int scanType)
This method wraps
scan() using the Policy object passed in and the specified scan type. |
CleanResults |
scan(String taintedHTML,
String filename)
This method wraps
scan() using the Policy in the specified file. |
public static final int DOM
public static final int SAX
public AntiSamy()
public AntiSamy(Policy policy)
public CleanResults scan(String taintedHTML) throws ScanException, PolicyException
scan()
family of methods are the
only methods the outside world should be calling to invoke AntiSamy.taintedHTML
- Untrusted HTML which may contain malicious code.CleanResults
object which contains information
about the scan (including the results).ScanException
- When there is a problem encountered
while scanning the HTML.PolicyException
- When there is a problem reading the policy file.public CleanResults scan(String taintedHTML, int scanType) throws ScanException, PolicyException
scan()
to use the specified scan type.taintedHTML
- Untrusted HTML which may contain malicious code.scanType
- The type of scan (DOM or SAX).CleanResults
object which contains information
about the scan (including the results).ScanException
- When there is a problem encountered
while scanning the HTML.PolicyException
- When there is a problem reading the policy file.public CleanResults scan(String taintedHTML, Policy policy) throws ScanException, PolicyException
scan()
using the Policy object passed in.taintedHTML
- Untrusted HTML which may contain malicious code.policy
- The custom policy to enforce.CleanResults
object which contains information
about the scan (including the results).ScanException
- When there is a problem encountered
while scanning the HTML.PolicyException
- When there is a problem reading the policy file.public CleanResults scan(String taintedHTML, Policy policy, int scanType) throws ScanException, PolicyException
scan()
using the Policy object passed in and the specified scan type.taintedHTML
- Untrusted HTML which may contain malicious code.policy
- The custom policy to enforce.scanType
- The type of scan (DOM or SAX).CleanResults
object which contains information
about the scan (including the results).ScanException
- When there is a problem encountered
while scanning the HTML.PolicyException
- When there is a problem reading the policy file.public CleanResults scan(Reader reader, Writer writer, Policy policy) throws ScanException
reader
- Reader that produces the input, possibly a little at a timewriter
- Writer that receives the cleaned output, possibly a little at a timepolicy
- Policy that directs the scanScanException
- When there is a problem encountered
while scanning the HTML.public CleanResults scan(String taintedHTML, String filename) throws ScanException, PolicyException
scan()
using the Policy in the specified file.taintedHTML
- Untrusted HTML which may contain malicious code.filename
- The file name of the custom policy to enforce.CleanResults
object which contains information
about the scan (including the results).ScanException
- When there is a problem encountered
while scanning the HTML.PolicyException
- When there is a problem reading the policy file.public CleanResults scan(String taintedHTML, File policyFile) throws ScanException, PolicyException
scan()
using the policy File object passed in.taintedHTML
- Untrusted HTML which may contain malicious code.policyFile
- The File object of the custom policy to enforce.CleanResults
object which contains information
about the scan (including the results).ScanException
- When there is a problem encountered
while scanning the HTML.PolicyException
- When there is a problem reading the policy file.Copyright © 2022. All rights reserved.