org.owasp.validator.html
public class Policy extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Policy.ParseContext |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTION_FILTER |
static java.lang.String |
ACTION_TRUNCATE |
static java.lang.String |
ACTION_VALIDATE |
static java.lang.String |
ANCHORS_NOFOLLOW |
static java.util.regex.Pattern |
ANYTHING_REGEXP |
static java.lang.String |
CONNECTION_TIMEOUT |
static int |
DEFAULT_MAX_INPUT_SIZE |
static int |
DEFAULT_MAX_STYLESHEET_IMPORTS |
protected static java.lang.String |
DEFAULT_POLICY_URI |
protected java.util.Map<java.lang.String,java.lang.String> |
directives |
static java.lang.String |
EMBED_STYLESHEETS |
static java.lang.String |
ENTITY_ENCODE_INTL_CHARS |
static java.lang.String |
FORMAT_OUTPUT |
static java.lang.String |
OMIT_DOCTYPE_DECLARATION |
static java.lang.String |
OMIT_XML_DECLARATION |
static java.lang.String |
PRESERVE_COMMENTS |
static java.lang.String |
PRESERVE_SPACE |
protected java.util.Map<java.lang.String,Tag> |
tagRules |
static java.lang.String |
USE_XHTML |
static java.lang.String |
VALIDATE_PARAM_AS_EMBED |
Modifier | Constructor and Description |
---|---|
protected |
Policy(Policy.ParseContext parseContext) |
protected |
Policy(Policy old,
java.util.Map<java.lang.String,java.lang.String> directives,
java.util.Map<java.lang.String,Tag> tagRules) |
Modifier and Type | Method and Description |
---|---|
Policy |
cloneWithDirective(java.lang.String name,
java.lang.String value)
Creates a copy of this policy with an added/changed directive.
|
TagMatcher |
getAllowedEmptyTags()
Return all the allowed empty tags configured in the Policy.
|
AntiSamyPattern |
getCommonRegularExpressions(java.lang.String name) |
java.lang.String |
getDirective(java.lang.String name)
Return a directive value based on a lookup name.
|
Attribute |
getGlobalAttributeByName(java.lang.String name)
A simple method for returning on of the
|
static Policy |
getInstance()
This retrieves a Policy based on a default location ("resources/antisamy.xml")
|
static Policy |
getInstance(java.io.File file)
This retrieves a Policy based on the File object passed in
|
static Policy |
getInstance(java.io.InputStream inputStream)
This retrieves a Policy based on the InputStream object passed in
|
static Policy |
getInstance(java.lang.String filename)
This retrieves a Policy based on the file name passed in
|
static Policy |
getInstance(java.net.URL url)
This retrieves a Policy based on the URL object passed in.
|
protected static Policy.ParseContext |
getParseContext(org.w3c.dom.Element topLevelElement,
java.net.URL baseUrl) |
Property |
getPropertyByName(java.lang.String propertyName)
Retrieves a CSS Property from the Policy.
|
TagMatcher |
getRequiresClosingTags()
Return all the tags that are required to be closed with an end tag, even if they have no child content.
|
protected static Policy.ParseContext |
getSimpleParseContext(org.w3c.dom.Element topLevelElement) |
Tag |
getTagByLowercaseName(java.lang.String tagName)
The path to the base policy file, used to resolve relative paths when reading included files
|
protected static org.w3c.dom.Element |
getTopLevelElement(org.xml.sax.InputSource source) |
protected static org.w3c.dom.Element |
getTopLevelElement(java.net.URL baseUrl) |
static org.xml.sax.InputSource |
resolveEntity(java.lang.String systemId,
java.net.URL baseUrl)
Resolves public & system ids to files stored within the JAR.
|
public static final java.util.regex.Pattern ANYTHING_REGEXP
protected static final java.lang.String DEFAULT_POLICY_URI
public static final int DEFAULT_MAX_INPUT_SIZE
public static final int DEFAULT_MAX_STYLESHEET_IMPORTS
public static final java.lang.String OMIT_XML_DECLARATION
public static final java.lang.String OMIT_DOCTYPE_DECLARATION
public static final java.lang.String USE_XHTML
public static final java.lang.String FORMAT_OUTPUT
public static final java.lang.String EMBED_STYLESHEETS
public static final java.lang.String CONNECTION_TIMEOUT
public static final java.lang.String ANCHORS_NOFOLLOW
public static final java.lang.String VALIDATE_PARAM_AS_EMBED
public static final java.lang.String PRESERVE_SPACE
public static final java.lang.String PRESERVE_COMMENTS
public static final java.lang.String ENTITY_ENCODE_INTL_CHARS
public static final java.lang.String ACTION_VALIDATE
public static final java.lang.String ACTION_FILTER
public static final java.lang.String ACTION_TRUNCATE
protected final java.util.Map<java.lang.String,Tag> tagRules
protected final java.util.Map<java.lang.String,java.lang.String> directives
protected Policy(Policy.ParseContext parseContext) throws PolicyException
PolicyException
public Tag getTagByLowercaseName(java.lang.String tagName)
public Property getPropertyByName(java.lang.String propertyName)
propertyName
- The name of the CSS Property to look up.public static Policy getInstance() throws PolicyException
PolicyException
- If the file is not found or there is a problem parsing the file.public static Policy getInstance(java.lang.String filename) throws PolicyException
filename
- The path to the XML policy file.PolicyException
- If the file is not found or there is a problem parsing the file.public static Policy getInstance(java.io.InputStream inputStream) throws PolicyException
inputStream
- An InputStream which contains thhe XML policy information.PolicyException
- If there is a problem parsing the input stream.public static Policy getInstance(java.io.File file) throws PolicyException
file
- A File object which contains the XML policy information.PolicyException
- If the file is not found or there is a problem parsing the file.public static Policy getInstance(java.net.URL url) throws PolicyException
url
- A URL object which contains the XML policy information.PolicyException
- If the file is not found or there is a problem parsing the file.protected static Policy.ParseContext getSimpleParseContext(org.w3c.dom.Element topLevelElement) throws PolicyException
PolicyException
protected static Policy.ParseContext getParseContext(org.w3c.dom.Element topLevelElement, java.net.URL baseUrl) throws PolicyException
PolicyException
protected static org.w3c.dom.Element getTopLevelElement(java.net.URL baseUrl) throws PolicyException
PolicyException
protected static org.w3c.dom.Element getTopLevelElement(org.xml.sax.InputSource source) throws PolicyException
PolicyException
public Policy cloneWithDirective(java.lang.String name, java.lang.String value)
name
- The directive to add/modifyvalue
- The valuepublic Attribute getGlobalAttributeByName(java.lang.String name)
name
- The name of the global-attribute we want to look up.public TagMatcher getAllowedEmptyTags()
public TagMatcher getRequiresClosingTags()
public java.lang.String getDirective(java.lang.String name)
public static org.xml.sax.InputSource resolveEntity(java.lang.String systemId, java.net.URL baseUrl) throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public AntiSamyPattern getCommonRegularExpressions(java.lang.String name)
Copyright © 2014. All Rights Reserved.