public class Policy extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Policy.ParseContext |
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_FILTER |
static String |
ACTION_TRUNCATE |
static String |
ACTION_VALIDATE |
static String |
ANCHORS_NOFOLLOW |
static Pattern |
ANYTHING_REGEXP |
static String |
CONNECTION_TIMEOUT |
static int |
DEFAULT_MAX_INPUT_SIZE |
static int |
DEFAULT_MAX_STYLESHEET_IMPORTS |
protected static String |
DEFAULT_POLICY_URI |
protected Map<String,String> |
directives |
static String |
EMBED_STYLESHEETS |
static String |
ENTITY_ENCODE_INTL_CHARS |
static String |
FORMAT_OUTPUT |
static String |
OMIT_DOCTYPE_DECLARATION |
static String |
OMIT_XML_DECLARATION |
static String |
PRESERVE_COMMENTS |
static String |
PRESERVE_SPACE |
protected Map<String,Tag> |
tagRules |
static String |
USE_XHTML |
static String |
VALIDATE_PARAM_AS_EMBED |
Modifier | Constructor and Description |
---|---|
protected |
Policy(Policy.ParseContext parseContext) |
protected |
Policy(Policy old,
Map<String,String> directives,
Map<String,Tag> tagRules) |
Modifier and Type | Method and Description |
---|---|
Policy |
cloneWithDirective(String name,
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(String name) |
String |
getDirective(String name)
Return a directive value based on a lookup name.
|
Attribute |
getGlobalAttributeByName(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(File file)
This retrieves a Policy based on the File object passed in
|
static Policy |
getInstance(InputStream inputStream)
This retrieves a Policy based on the InputStream object passed in
|
static Policy |
getInstance(String filename)
This retrieves a Policy based on the file name passed in
|
static Policy |
getInstance(URL url)
This retrieves a Policy based on the URL object passed in.
|
protected static Policy.ParseContext |
getParseContext(Element topLevelElement,
URL baseUrl) |
Property |
getPropertyByName(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(Element topLevelElement) |
Tag |
getTagByLowercaseName(String tagName)
The path to the base policy file, used to resolve relative paths when reading included files
|
protected static Element |
getTopLevelElement(InputSource source) |
protected static Element |
getTopLevelElement(URL baseUrl) |
static InputSource |
resolveEntity(String systemId,
URL baseUrl)
Resolves public & system ids to files stored within the JAR.
|
public static final Pattern ANYTHING_REGEXP
protected static final String DEFAULT_POLICY_URI
public static final int DEFAULT_MAX_INPUT_SIZE
public static final int DEFAULT_MAX_STYLESHEET_IMPORTS
public static final String OMIT_XML_DECLARATION
public static final String OMIT_DOCTYPE_DECLARATION
public static final String USE_XHTML
public static final String FORMAT_OUTPUT
public static final String EMBED_STYLESHEETS
public static final String CONNECTION_TIMEOUT
public static final String ANCHORS_NOFOLLOW
public static final String VALIDATE_PARAM_AS_EMBED
public static final String PRESERVE_SPACE
public static final String PRESERVE_COMMENTS
public static final String ENTITY_ENCODE_INTL_CHARS
public static final String ACTION_VALIDATE
public static final String ACTION_FILTER
public static final String ACTION_TRUNCATE
protected Policy(Policy.ParseContext parseContext) throws PolicyException
PolicyException
public Tag getTagByLowercaseName(String tagName)
public Property getPropertyByName(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(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(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(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(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(Element topLevelElement) throws PolicyException
PolicyException
protected static Policy.ParseContext getParseContext(Element topLevelElement, URL baseUrl) throws PolicyException
PolicyException
protected static Element getTopLevelElement(URL baseUrl) throws PolicyException
PolicyException
protected static Element getTopLevelElement(InputSource source) throws PolicyException
PolicyException
public Policy cloneWithDirective(String name, String value)
name
- The directive to add/modifyvalue
- The valuepublic Attribute getGlobalAttributeByName(String name)
name
- The name of the global-attribute we want to look up.public TagMatcher getAllowedEmptyTags()
public TagMatcher getRequiresClosingTags()
public String getDirective(String name)
public static InputSource resolveEntity(String systemId, URL baseUrl) throws IOException, SAXException
IOException
SAXException
public AntiSamyPattern getCommonRegularExpressions(String name)
Copyright © 2019. All rights reserved.