PING Servlet

From HiWiki

Jump to: navigation, search

PING Discovery: Pilot implementasjon og utforskning av PING -> Implementation -> PING Servlet

Contents

Overview

The PING Server is a Java Servlet which runs on an Apache Tomcat web server. It has the following properties:

  • Actionresponders that handle different actions and that are fully pluggable modules
  • Extensions that are similar to actionresponders but execute their tasks after the actionresponders are finished
  • XML configuration files for security, logging, actionresponders and extensions
  • Uses Java RMI to connect to the store

One of the most important classes is PingServlet in the package org.chip.ping.server. This is where the client request is received. It extends HttpServlet and contains the methods doGet and doPost. The doPost handles the requests, so if you try to access the server with a browser, you will get an "I don't respond to get" message (because browsers use doGet). There are some other central classes. PingResponder processes the request and sends it to the correct ActionResponder who processes it according to its specified actions:

  • PingServlet: Accept the request
  • PingResponder: Process the request and send it to the correct actionResponder
  • The actionResponder: Process the request

A simplified example is shown below:


Image:big3.jpg

Configuration

A minor description of the various xml files.

Web.xml

Contains init-parameters for the PingServlet:

  • reference to responders.xml
  • reference to extensions.xml
  • Whether SSL should be enabled or not
  • configContext: Used in coherence with marshalling
  • And finally, the name of the servlet

Responders.xml

Contains information about the different actionresponders and how they should be initialized. DefaultReadActionResponder, example:

<responder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="respi:DefaultActionResponderInitType">
     <ClassName>org.chip.ping.server.responder.actionResponders.DefaultReadActionResponder</ClassName>
     <actionType>urn:org:chip:ping:action:read</actionType>
     <PingStoreConfig>
         <ClassName>org.chip.ping.recordstore.IndexedRecordStore</ClassName>
         <StoreConfig xsi:type="conf:OSStoreClientConfigType">
             <ClassName>org.chip.ping.iostore.berkeleydb.OSStoreClient</ClassName>
             <StoreLocation>//localhost/OSStoreServer</StoreLocation>
             <DatabaseName>PING_RECORDS</DatabaseName>
         </StoreConfig>
         <AuditStoreConfig xsi:type="conf:OSStoreClientConfigType">
             <ClassName>org.chip.ping.iostore.berkeleydb.OSStoreClient</ClassName>
             <StoreLocation>//localhost/OSStoreServerAudit</StoreLocation>
         </AuditStoreConfig>
     </PingStoreConfig>
     <AuditerConfig>
         <ClassName>org.chip.ping.audit.FineGrainedAuditer</ClassName>
         <StoreConfig xsi:type="conf:OSStoreClientConfigType">
             <ClassName>org.chip.ping.iostore.berkeleydb.OSStoreClient</ClassName>
             <StoreLocation>//localhost/OSStoreServer</StoreLocation>
         </StoreConfig>
     </AuditerConfig>
</responder>

Extensions.xml

Not used in the servlet demo, but schema (extensions.xsd) is defined.

<some>policy.xml

Some actionresponders have their own policy. This should be specified with a reference to the policy file in the responders.xml. The policy is used in the authorization phase of a request. See more about this in Authorization.

log4j.xml

Ping uses log4j which is a handy tool for debugging. Some of the important parameters here are the location of the log file, and appender type.

Package Descriptions

Image:ping_server.jpg

org.chip.ping.server

  • PingServlet.java

Enough said.

org.chip.ping

  • InitializationException.java
  • PingException.java

Exceptions made for the PING system.

org.chip.ping.server.responder

  • ActionResponder.java
  • MalformedRequestException.java
  • NotAuthorizedException.java
  • PingResponder.java
  • ResponderLoader.java

The following text has been borrowed from the source code:
Provides the logic for processing registered actions and maintaining information about actor sessions. Actions are registered during start-up when the controller module (see org.chip.ping.server.responder.PingResponder) of the layer is initialized. During the initialization phase, the controller reads a configuration file that contains the information necessary to instantiate modules that are registered to handle a particular action (see org.chip.ping.server.responder.ResponderLoader). The information used in instantiation typically includes definitions of data stores, authorization engines, and the type identification of actions that the module will handle. When an action request is sent to the server and passed on to the action response controller, the controller determines delegates the processing of the action to the registered module.

org.chip.ping.server.extension

  • DemoExtension.java
  • ExtensionHandler.java
  • PingActionEvent.java
  • PingActionListener.java
  • Worker.java

The following text has been borrowed from the source code:
Provides an extension mechanism for handling client requests. The extension mechanism is pluggable in the same manner as the action module is in that extensions are registered during the server initialization phase. Also like the action modules, extensions register for particular action events. The difference in the behavior of the extension is that it executes its task after the action module has finished, and the execution is asynchronous with the request. That is, a response is sent to the request in parallel with the execution of the extension process.

org.chip.ping.xacml

  • DefaultPolicyGenerator.java
  • DynamicPDP.java
  • DynamicPolicyModule.java
  • FilePDP.java
  • RecordPDP.java
  • RecordPolicyModule.java
  • RequestCtxGenerator.java

The following text has been borrowed from the source code:
Provides the logic for determining whether an actor is allowed to perform a particular action on a particular record or record element. The classes defined in this package utilize and derive from the Sun XACML libraries (http://sunxacml.sourceforge.net/). For more information about XACML, see the specifications at the OASIS website (http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xacml).

org.chip.ping.server.responder.actionResponders

  • DefaultActionResponder.java
  • DefaultAddDocumentActionResponder.java
  • DefaultAuthenticateActionResponder.java
  • DefaultCreateActionResponder.java
  • DefaultQueryActionResponder.java
  • DefaultReadActionResponder.java
  • DefaultReadDocumentActionResponder.java
  • DefaultReadDocumentFilterActionResponder.java
  • DefaultReadDocumentHeaderListActionResponder.java
  • DefaultReadFilteredDocumentsActionResponder.java
  • DefaultSendMessageActionResponder.java
  • DefaultUpdateDocumentActionResponder.java
  • TicketGenerator.java

All the classes extend DefaultActionResponder (except TicketGenerator of course). They are in charge of actually executing the corresponding actions. These are fully pluggable modules, generated from XML at initialization, and therefore easy to change. There are two interesting methods in each actionresponder which are more or less unique for each:

  • process: How to process the request
  • authorize: How to authorize the request

TicketGenerator generates a ticket for the session.

org.chip.ping.recordstore.document

  • DocumentFilter.java
  • DocumentStoreProcessor.java

org.chip.ping.recordstore

  • IndexedRecordStore.java
  • LRUPingCache.java
  • NullCache.java
  • PingCache.java
  • RecordAlreadyExistsExcpetion.java
  • RecordStore.java

This package contains classes which the PingServlet uses to communicate with the store. Also classes for caching, but the most central ones are RecordStore and IndexedRecordStore.

org.chip.ping.iostore.collections

  • SecureArrayManager.java
  • SecureCollectionManager.java
  • SecureMapManager.java

Package for secure management of data.