org.edg.info
Class SiteFilter

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.edg.info.SiteFilter
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, java.lang.Runnable

public class SiteFilter
extends org.xml.sax.helpers.DefaultHandler
implements java.lang.Runnable

This class is used to allow/deny requests destined to a particular destination. Currently checks are only made on the RegistryServlet. Entries are examined according to the following order: 1) hosts allowed list. 2) hosts denied list. If a host is matched in step 1) then step 2) is ignored. If a host is note matched in 1) then step 2) is carried out.


Field Summary
static int ALLOW_DENY
          Constant representing allow-then-deny evaluation order
static int DENY_ALLOW
          Constant representing deny-then-allow evaluation order
 
Method Summary
 void characters(char[] ch, int start, int length)
          Called by the sax parser whenever a text element is found.
 void close()
          Terminates the thread that reads the configFile.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Method called by the sax parser when an element is terminated.
static java.lang.String extractServletName(java.lang.String urlStr)
          Extracts the servlet name from the URL e.g http://localhost:8080/R-GMA/RegistryServlet -> servletName = RegistryServlet.
static SiteFilter getInstance(java.lang.String configFile, long readPeriod)
          Obtains a singleton reference..
 boolean isHostnameDenied(java.lang.String servletName, java.lang.String hostname)
          Checks if the hostname is contained in the allow/deny access list.
 boolean isURLDenied(java.lang.String urlStr)
          Extracts the hostname from the URL and checks if its currently in the allow/denied access list.
 void run()
          DOCUMENT ME!
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Method called by the sax parser when a new element is found.
 java.lang.String toString()
          Formats the object state into xml.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALLOW_DENY

public static final int ALLOW_DENY
Constant representing allow-then-deny evaluation order

See Also:
Constant Field Values

DENY_ALLOW

public static final int DENY_ALLOW
Constant representing deny-then-allow evaluation order

See Also:
Constant Field Values
Method Detail

getInstance

public static SiteFilter getInstance(java.lang.String configFile,
                                     long readPeriod)
Obtains a singleton reference..

Parameters:
configFile -
readPeriod - Period when the configFile is read-in. If value is less than or equal to zero 0 the configFile is read-in once only.
Returns:
DOCUMENT ME!

isHostnameDenied

public boolean isHostnameDenied(java.lang.String servletName,
                                java.lang.String hostname)
Checks if the hostname is contained in the allow/deny access list.

Parameters:
servletName - the hostname is used for the comparision.
hostname - DOCUMENT ME!
Returns:
true if the URL is blocked, false otherwise.

isURLDenied

public boolean isURLDenied(java.lang.String urlStr)
Extracts the hostname from the URL and checks if its currently in the allow/denied access list.

Returns:
true if the URL is blocked or the urlStr is malformed, false otherwise.

characters

public void characters(char[] ch,
                       int start,
                       int length)
Called by the sax parser whenever a text element is found.

Specified by:
characters in interface org.xml.sax.ContentHandler
Parameters:
ch - DOCUMENT ME!
start - DOCUMENT ME!
length - DOCUMENT ME!

close

public void close()
Terminates the thread that reads the configFile.


endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
Method called by the sax parser when an element is terminated.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Parameters:
uri - DOCUMENT ME!
localName - DOCUMENT ME!
qName - DOCUMENT ME!

run

public void run()
DOCUMENT ME!

Specified by:
run in interface java.lang.Runnable

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
Method called by the sax parser when a new element is found.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Parameters:
uri - DOCUMENT ME!
localName - DOCUMENT ME!
qName - DOCUMENT ME!
attributes - DOCUMENT ME!

toString

public java.lang.String toString()
Formats the object state into xml.

Returns:
DOCUMENT ME!

extractServletName

public static java.lang.String extractServletName(java.lang.String urlStr)
Extracts the servlet name from the URL e.g http://localhost:8080/R-GMA/RegistryServlet -> servletName = RegistryServlet.

Returns: