nbi.xmlsec.biocase.protocol.filter
Class RequestFilter

java.lang.Object
  extended byorg.xml.sax.helpers.XMLFilterImpl
      extended bynbi.xmlsec.biocase.protocol.filter.ProtocolFilter
          extended bynbi.xmlsec.biocase.protocol.filter.RequestFilter
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XMLFilter, XMLReader

public class RequestFilter
extends ProtocolFilter

The RequestFilter parses and evaluates requests of the BioCASE protocol. It consists of two internal filters working together:

All incoming SAX Events are forwarded to the ContentHandler.The HeaderFilterparsed the BioCASE header. The OperationTypeFilterparses the request's scan or search operation type. The request may be retrieved with the method getRequest().

Since:
Version:
$Revision: 1.22 $
Author:
Lutz Suhrbier

Field Summary
static String ACTION_REQUEST_CAPABILITIES
          PDP Action capabilities
static String ACTION_REQUEST_SCAN
          PDP Action scan
static String ACTION_REQUEST_SEARCH
          PDP Action search
(package private)  HeaderFilter headerFilter
          Subfilter for the header
static String LN_ROOT
          Local name of the root element request
(package private)  OperationTypeFilter opTypeFilter
          Subfilter for the request type
(package private)  Request request
          Request to be evaluated
static String RESOURCE_ANY
          PDP Resource any
(package private) static int trackMode
          Track mode for the filter stack
 
Fields inherited from class nbi.xmlsec.biocase.protocol.filter.ProtocolFilter
elementStack, filterMode, FILTERMODE_FILTER, FILTERMODE_NONE, FILTERMODE_PARSER, filterRoot, logger, PROT_URI_13, PROT_URI_20
 
Fields inherited from class org.xml.sax.helpers.XMLFilterImpl
 
Constructor Summary
RequestFilter(String protocolURI, int filterMode)
          Inits the filter instance.
RequestFilter(XMLReader parent, String protocolURI, int filterMode)
          Inits the filter instance with specified parent.
 
Method Summary
private  boolean evaluateRequest(String action, String resource)
          Evaluates request access for a given resource and action.
protected  PDPFilterParameter getParameter()
          Gets the parameter of this filter.
 Request getRequest()
          Gets the request
(package private)  boolean isCapabilitiesRequest()
          Checks, if the parsed header signals a capabilities request.
(package private)  boolean isScanRequest()
          Checks, if the parsed header signals a scan request.
(package private)  boolean isSearchRequest()
          Checks, if the parsed header signals a search request.
protected  nbi.xml.sax.SAXElement parseComplete(nbi.xml.sax.SAXElement element)
          Evaluates the access conditions, when PDPFilterParameterset.
protected  nbi.xml.sax.SAXElement parseElement(nbi.xml.sax.SAXElement element)
          Registers and sets the parameters for the OperationTypeFilter.
protected  nbi.xml.sax.SAXElement parseInit(nbi.xml.sax.SAXElement element)
          Registers the subfilter for the header.
 
Methods inherited from class nbi.xmlsec.biocase.protocol.filter.ProtocolFilter
characters, checkFilterParameter, endElement, filterCharacters, filterElement, getFilterMode, getFilterParameter, getProtocolURI, isParsingComplete, registerSubFilter, setFilterParameter, setProtocolURI, startElement, unregisterSubFilter
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LN_ROOT

public static final String LN_ROOT
Local name of the root element request

See Also:
Constant Field Values

ACTION_REQUEST_CAPABILITIES

public static final String ACTION_REQUEST_CAPABILITIES
PDP Action capabilities

See Also:
Constant Field Values

ACTION_REQUEST_SCAN

public static final String ACTION_REQUEST_SCAN
PDP Action scan

See Also:
Constant Field Values

ACTION_REQUEST_SEARCH

public static final String ACTION_REQUEST_SEARCH
PDP Action search

See Also:
Constant Field Values

RESOURCE_ANY

public static final String RESOURCE_ANY
PDP Resource any

See Also:
Constant Field Values

trackMode

static final int trackMode
Track mode for the filter stack

See Also:
Constant Field Values

headerFilter

HeaderFilter headerFilter
Subfilter for the header


opTypeFilter

OperationTypeFilter opTypeFilter
Subfilter for the request type


request

Request request
Request to be evaluated

Constructor Detail

RequestFilter

public RequestFilter(String protocolURI,
                     int filterMode)
Inits the filter instance.

Parameters:
protocolURI - protocol version URI of this filter.
filterMode - filterMode of this filter ProtocolFilter.filterMode.

RequestFilter

public RequestFilter(XMLReader parent,
                     String protocolURI,
                     int filterMode)
Inits the filter instance with specified parent.

Parameters:
parent - parent reader.
protocolURI - protocol version URI of this filter.
filterMode - filterMode of this filter ProtocolFilter.filterMode.
Method Detail

parseInit

protected nbi.xml.sax.SAXElement parseInit(nbi.xml.sax.SAXElement element)
                                    throws SAXException
Registers the subfilter for the header.

Overrides:
parseInit in class ProtocolFilter
Parameters:
element - The element of the startElement event (contains no value).
Returns:
The (modified) element or null when the event shall be removed.
Throws:
SAXException - If any parsing error occurs.
See Also:
ProtocolFilter.parseInit(SAXElement)

parseElement

protected nbi.xml.sax.SAXElement parseElement(nbi.xml.sax.SAXElement element)
                                       throws SAXException
Registers and sets the parameters for the OperationTypeFilter. This must be done here, after parsing the Request header completely.

Overrides:
parseElement in class ProtocolFilter
Parameters:
element - The element corresponding to the endElement event.
Returns:
The (modified) element or null when element shall be removed.
Throws:
SAXException - If any parsing error occurs.
See Also:
ProtocolFilter.parseElement(SAXElement)

parseComplete

protected nbi.xml.sax.SAXElement parseComplete(nbi.xml.sax.SAXElement element)
                                        throws SAXException
Evaluates the access conditions, when PDPFilterParameterset. This must be done here, when the request has been completely parsed.

Overrides:
parseComplete in class ProtocolFilter
Parameters:
element - The complete root element (including the value).
Returns:
The (modified) element or null when element shall be removed.
Throws:
SAXException - If any parsing error occurs.
See Also:
ProtocolFilter.parseComplete(SAXElement)

isCapabilitiesRequest

boolean isCapabilitiesRequest()
Checks, if the parsed header signals a capabilities request.

Returns:
true, if it's an capabilities request, false otherwise.

isScanRequest

boolean isScanRequest()
Checks, if the parsed header signals a scan request.

Returns:
true, if it's an scan request, false otherwise.

isSearchRequest

boolean isSearchRequest()
Checks, if the parsed header signals a search request.

Returns:
true, if it's an search request, false otherwise.

evaluateRequest

private boolean evaluateRequest(String action,
                                String resource)
Evaluates request access for a given resource and action. Adds the following Request elements to the environment attributes of the RequestCtx: // *
  • sendTime (Request.Header.sendTime as DateTimeAttribute)
  • source (Request.Header.source as StringAttribute)
  • requestFormat (Request.Scan|Search.requestFormat as AnyUriAttribute)
  • responseFormat (Request.Search.responseFormat as AnyUriAttribute)
  • start (Request.Search.responseFormat#start as IntegerAttribute)
  • limit (Request.Search.responseFormat#limit as IntegerAttribute)
  • count (Request.Search.responseFormat#count as BooleanAttribute)
  • Parameters:
    action - The action to be evaluated.
    resource - The resource to be evaluated.
    Returns:
    true ,if access is permitted, false otherwise.

    getParameter

    protected PDPFilterParameter getParameter()
    Gets the parameter of this filter.

    Returns:
    filter parameter.

    getRequest

    public Request getRequest()
    Gets the request

    Returns:
    Returns the request.


    Copyright © 2006 Lutz Suhrbier, Freie Universität Berlin. All Rights Reserved.