org.owasp.validator.html
Class Policy

java.lang.Object
  extended by org.owasp.validator.html.Policy

public class Policy
extends Object

Policy.java This file holds the model for our policy engine.

Author:
Arshan Dabirsiaghi

Field Summary
static int DEFAULT_MAX_INPUT_SIZE
           
 
Method Summary
 String getDirective(String name)
          Return a directive value based on a lookup name.
 String getEntityReferenceCode(String name)
          Returns an HTML-entity number.
 Attribute getGlobalAttributeByName(String name)
          A simple method for returning on of the entries by name.
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(String filename)
          This retrieves a Policy based on the file name passed in
 Property getPropertyByName(String propertyName)
          Retrieves a CSS Property from the Policy.
 AntiSamyPattern getRegularExpression(String name)
          A simple method for returning on of the entries by name.
 Tag getTagByName(String tagName)
          Retrieves a Tag from the Policy.
 String[] getTags()
          Return all the tags accepted by the Policy object.
static void main(String[] args)
          Main test unit.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_INPUT_SIZE

public static final int DEFAULT_MAX_INPUT_SIZE
See Also:
Constant Field Values
Method Detail

getTagByName

public Tag getTagByName(String tagName)
Retrieves a Tag from the Policy.

Parameters:
tagName - The name of the Tag to look up.
Returns:
The Tag associated with the name specified, or null if none is found.

getPropertyByName

public Property getPropertyByName(String propertyName)
Retrieves a CSS Property from the Policy.

Parameters:
propertyName - The name of the CSS Property to look up.
Returns:
The CSS Property associated with the name specified, or null if none is found.

getInstance

public static Policy getInstance()
                          throws PolicyException
This retrieves a Policy based on a default location ("resources/antisamy.xml")

Returns:
A populated Policy object based on the XML policy file located in the default location.
Throws:
PolicyException - If the file is not found or there is a problem parsing the file.

getInstance

public static Policy getInstance(String filename)
                          throws PolicyException
This retrieves a Policy based on the file name passed in

Parameters:
filename - The path to the XML policy file.
Returns:
A populated Policy object based on the XML policy file located in the location passed in.
Throws:
PolicyException - If the file is not found or there is a problem parsing the file.

getInstance

public static Policy getInstance(File file)
                          throws PolicyException
This retrieves a Policy based on the File object passed in

Parameters:
file - A File object which contains the XML policy information.
Returns:
A populated Policy object based on the XML policy file pointed to by the File parameter.
Throws:
PolicyException - If the file is not found or there is a problem parsing the file.

getRegularExpression

public AntiSamyPattern getRegularExpression(String name)
A simple method for returning on of the entries by name.

Parameters:
name - The name of the common regexp we want to look up.
Returns:
An AntiSamyPattern associated with the lookup name specified.

getGlobalAttributeByName

public Attribute getGlobalAttributeByName(String name)
A simple method for returning on of the entries by name.

Parameters:
name - The name of the global-attribute we want to look up.
Returns:
An Attribute associated with the global-attribute lookup name specified.

getEntityReferenceCode

public String getEntityReferenceCode(String name)
Returns an HTML-entity number.

Parameters:
name - Return the entity code equivalent when passed the name.
Returns:
Returns &160; when passed in  .

getTags

public String[] getTags()
Return all the tags accepted by the Policy object.

Returns:
A String array of all the tag names accepted by the current Policy.

getDirective

public String getDirective(String name)
Return a directive value based on a lookup name.

Returns:
A String object containing the directive associated with the lookup name, or null if none is found.

main

public static void main(String[] args)
                 throws Exception
Main test unit.

Parameters:
args -
Throws:
Exception