zeus.actors.intrays
Class FIPA_2000_HTTP_Connection

java.lang.Object
  extended byzeus.actors.intrays.FIPA_2000_HTTP_Connection
All Implemented Interfaces:
java.lang.Runnable

public class FIPA_2000_HTTP_Connection
extends java.lang.Object
implements java.lang.Runnable

FIPA_2000_HTTP_Connection handles incomming connections on this host/port socket and decides whether or not they are meant for it (ie: is the name on the connection the same as the name in the init of this class)

If the connection is relevant then the data will be read, a response (as per the spec ) will be sent and the message will be decoded into a FIPA.FipaMessage and placed on the registered queue for processing by the relevant server

The class constructor takes a host a port and a name : should this agent only listen for connections for itself at this port and host? That is what is implemented here... comments on a postcard please

Since:
1.1
Author:
Simon Thompson

Field Summary
private  java.lang.String host
           
protected  int MAX_CONTENT_LENGTH
          if MAX_CONTENT_LENGHT is greater than 200001 it will be ignored and max_int length content will be accepted
private  int MAX_HTTP_QUEUE
           
protected  int MAX_LINES_TO_READ_WITHOUT_SHUTTING
           
protected  int MAX_LINES_TO_READ_WITHOUT_YEILDING
          MAX_LINES_TO_READ_WITHOUT_YEILDING is used to control how many lines will be read in from a connection in one lump.
private  java.lang.String name
           
private  java.lang.String port
           
protected  Queue queue
           
private  java.lang.String response_not_ok
           
private  java.lang.String response_ok
           
private  java.net.ServerSocket serverSocket
           
 
Constructor Summary
FIPA_2000_HTTP_Connection(java.lang.String host, java.lang.String port, java.lang.String name)
           
 
Method Summary
private  java.lang.String addEscape(java.lang.String in)
           
private  void debug(java.lang.String val)
           
static void main(java.lang.String[] argv)
          main method for testing this module parameters are
 void message(FIPAPerformative aFipaMessage)
          message is used to handle the completely read and parsed message when it has come off the message queue
private  FIPAPerformative process(java.lang.String inMess, java.lang.String bound)
           
 void register(Queue q)
          hitch this connection to a message queue
 void respondNotOK(java.io.PrintWriter out)
          send a not OK response (hopefully we won't have to do this!)
 void respondOK(java.io.PrintWriter out)
          send the mandated response to a successful message reception episode (see XC00084C)
 void run()
          run method that makes sure a thread is trying to pick up inputs from a connection The loop blocks on the ServerSocket.accept() method.
private  java.lang.String stripEnvelope(java.lang.String HTTPmessage, java.lang.String bound)
          crude for the moment - this needs redoing so it is less fragile.
protected  boolean test(java.lang.String myPort, java.lang.String testHost, java.lang.String testPort)
          used to test the code here!
private  java.lang.String testAndSetBoundary(java.lang.String ln)
          pull the boundary val from the header
private  int testAndSetContentLength(java.lang.String ln)
          pull the content length from the header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected Queue queue

response_ok

private java.lang.String response_ok

response_not_ok

private java.lang.String response_not_ok

host

private java.lang.String host

name

private java.lang.String name

port

private java.lang.String port

MAX_HTTP_QUEUE

private int MAX_HTTP_QUEUE

MAX_LINES_TO_READ_WITHOUT_YEILDING

protected int MAX_LINES_TO_READ_WITHOUT_YEILDING
MAX_LINES_TO_READ_WITHOUT_YEILDING is used to control how many lines will be read in from a connection in one lump. Without this I think that a DOS attack could be mounted via a http connection just by sending it an infinitely long message: perhaps another agent could use this to prevent this agent from bidding in a round of contracts, or from sending some alert information to another agent!

This is protected to prevent it being reset in Agent specific code


MAX_LINES_TO_READ_WITHOUT_SHUTTING

protected int MAX_LINES_TO_READ_WITHOUT_SHUTTING

MAX_CONTENT_LENGTH

protected int MAX_CONTENT_LENGTH
if MAX_CONTENT_LENGHT is greater than 200001 it will be ignored and max_int length content will be accepted


serverSocket

private java.net.ServerSocket serverSocket
Constructor Detail

FIPA_2000_HTTP_Connection

public FIPA_2000_HTTP_Connection(java.lang.String host,
                                 java.lang.String port,
                                 java.lang.String name)
Method Detail

run

public void run()
run method that makes sure a thread is trying to pick up inputs from a connection

The loop blocks on the ServerSocket.accept() method. A count variable is used to prevent an DOS on this agent by yeilding after a certain number of lines have been read.

Specified by:
run in interface java.lang.Runnable

register

public void register(Queue q)
hitch this connection to a message queue


testAndSetBoundary

private java.lang.String testAndSetBoundary(java.lang.String ln)
pull the boundary val from the header


testAndSetContentLength

private int testAndSetContentLength(java.lang.String ln)
pull the content length from the header


respondOK

public void respondOK(java.io.PrintWriter out)
send the mandated response to a successful message reception episode (see XC00084C)


respondNotOK

public void respondNotOK(java.io.PrintWriter out)
send a not OK response (hopefully we won't have to do this!)

This is not something that I could see mandated in the FIPA-spec, but I think that it is a good idea - otherwise the connection remains open until a timeout.

Perhaps sufficient open connections could be used as some sort of attack on the agent.


message

public void message(FIPAPerformative aFipaMessage)
message is used to handle the completely read and parsed message when it has come off the message queue


test

protected boolean test(java.lang.String myPort,
                       java.lang.String testHost,
                       java.lang.String testPort)
used to test the code here!


main

public static void main(java.lang.String[] argv)
main method for testing this module

parameters are


process

private FIPAPerformative process(java.lang.String inMess,
                                 java.lang.String bound)

addEscape

private java.lang.String addEscape(java.lang.String in)

stripEnvelope

private java.lang.String stripEnvelope(java.lang.String HTTPmessage,
                                       java.lang.String bound)
crude for the moment - this needs redoing so it is less fragile.


debug

private void debug(java.lang.String val)


Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.