ajanta.server
Class AgentServer

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--ajanta.server.AgentServer
All Implemented Interfaces:
AServer, java.rmi.Remote, Reportable, Resource, java.io.Serializable

public class AgentServer
extends java.rmi.server.UnicastRemoteObject
implements AServer, Resource, Reportable

Ajanta provides a generic agent server that can be suitably extended by a programmer to define an application-specific server. It supports several important functions:
1. Agent Transfer Protocol for agent migration to/from other servers.
2. Execution of visiting agents within secure protection domains.
3. Secure access to server resources for agents.
4. Primitives for inter-agent communication, resource access and migration.
5. Secure agent control and monitoring functions for agent creators.
The server's agent environment object acts as the interface between agents and the services provided at the host. Agents can invoke operations on their environment that allow them to migrate, communicate, access resources, etc. Each server maintains a domain registry that keeps track of the agents currently executing on it. A server usually provides access to some application-defined resources. Such resources are registered in the server's resource registry. This registry maps the URN of a resource to its object reference. A server has to explicitly make a resource visible to visiting agents by registering it in the resource registry by using the registerResource function.

See Also:
Serialized Form

Field Summary
protected  ajanta.server.ATPListener atp
          thread which handles agent transfer
protected  int atp_port
          port number on which agent transfer take place
protected  ajanta.naming.CA ca
           
protected  java.net.URL codeBase
          Code server running in this Agent Server
protected  ajanta.server.ClassServer cs
          class (code) server thread
protected  int cs_port
          port number of class (code) server thread
protected  java.util.Hashtable dd
          The domains database table -- conatin an entry for all the agent currently residing on the server
protected  java.security.Signature dsa
          DSA signature object
protected  java.security.PrivateKey dsa_priv
          DSA private key
protected  java.security.PublicKey dsa_pub
          DSA public key
protected  java.security.Signature dsa_v
          DSA object for signature verification
protected  ajanta.crypto.ElGamal eg
          ElGamal object used for encryption
protected  ajanta.crypto.EGPrivateKey eg_priv
          ElGamal private key for server's owner
protected  ajanta.crypto.EGPublicKey eg_pub
          ElGamal public key for server's owner
protected  ajanta.server.AgentEnv host
          server's context object -- an instance of this is passed to all the visting agents
protected  java.io.PrintStream logger
          a logger file output stream
protected  java.security.cert.X509Certificate myCertificate
           
protected  java.lang.String myHost
          DNS name of my host machine
protected  ajanta.naming.URN myURN
          this agent server's URN ( name )
protected  ajanta.server.NRAccess namereg
          a sycronized class for calling namereg api's
protected  java.security.cert.X509Certificate nameregistryCertificate
           
protected  java.util.Hashtable nameTGmap
          maps agent names to thread group id
protected  java.net.URL rmiRegURL
          local server specific rmi registry
protected  java.util.Hashtable rr
          The resource registry table -- contain an entry for each registered resource
protected  ajanta.server.AjantaSecurityManager securityManager
          the security manager for the server
protected  java.security.SecureRandom srand
          Secure random number generator
protected  ajanta.util.AgentTicketing tkt
          used for ticket generation/verification
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
AgentServer(java.lang.String n)
          AgentServer constructor
 
Method Summary
 ajanta.util.Ticket authenticate(ajanta.naming.URN caller, int nonce, ajanta.util.ContextObject context)
          It is used to obtain ticket from this server from a remote site.
 boolean checkAdmissionPolicy(ajanta.agent.Credentials agentCredentials, java.net.InetAddress inetAddress, ajanta.naming.URN senderAgentServerURN)
          The function returns true if the incoming agent can be accepted based on the agent server admission policy.
 byte[] decrypt(ajanta.crypto.EGCipherText cipher)
           
 void deleteDDEntry(ajanta.server.DDEntry obj)
          This function removes the calling agent DDEntry from the domain database.
 void deleteDDEntry(ajanta.naming.URN name)
          This function removes the calling agent DDEntry from the domain database.
 ajanta.crypto.EGCipherText encrypt(ajanta.crypto.EGPublicKey pk, byte[] plaintext)
           
 ajanta.server.AServer getAgentCurrentServer(ajanta.naming.URN agentURN)
          given URN of agent it locates it's current server and return reference to the server.
 ajanta.naming.CascadedCertificate getCascadedCertificate(int key_length, long duration)
           
 void getCertificiates()
           
 long getMaxDuration(ajanta.naming.URN agentURN)
           
 ajanta.server.NRAccess getNR()
          It returns a reference to NRAcess - sycronized class for calling namereg api's
 java.net.URL getRegURL()
          Return local server specific rmi registry URL.
 java.security.PrivateKey getTemporaryPrivateKey()
           
 java.security.PublicKey getTemporaryPublicKey()
           
 void launch(ajanta.agent.Agent ag, ajanta.naming.URN dest, java.lang.String method, java.lang.Class[] formals, java.lang.Object[] actuals)
          It launches a given agent to the specified destination.
 boolean logEvent(ajanta.logger.Event e)
           
static void main(java.lang.String[] args)
          Main program, which starts up the agent server This is only a generic main program.
 java.lang.String ping()
          Returns Agent Server Status.
 void recall(ajanta.naming.URN target, ajanta.naming.URN reportTo, ajanta.util.Ticket t)
          It is used to recall an agent ...which basically allow an agent to complete its task at the current server and upon completion migate it to the reportTo server ( but it aborts its prespecifed itinerary).
 void recall(ajanta.naming.URN target, ajanta.naming.URN recaller, ajanta.naming.URN reportTo)
          It is used to recall an agent ...which basically allow an agent to complete its task at the current server ( but it aborts its prespecifed itinerary) and upon completion migate it to the reportTo server.
 void registerAgent(ajanta.agent.Agent ag)
          Registers an agent with the name registry, If an older entry exists try to rebind the agent.
 ajanta.util.Ticket remoteServerTicket(ajanta.server.AServer targetServer, ajanta.naming.URN caller, int nonce, java.security.PrivateKey dsa_priv)
          It is used to do two way authentication...first it obtains a Ticket from the remote server and then using that ticket it creates another ticket and return to the caller.
 void report(ajanta.agent.Agent ag)
          This method is invoked by agents which report back to their home site, either because their task is done, or in response to reacll / retract, or because they have encountered some exception which they could not handle.
 void retract(ajanta.naming.URN target, ajanta.naming.URN reportTo, ajanta.util.Ticket t)
          It is used to retract an agent ...it preempts the agent from its current task and its prespecifed itinerary.
 void retract(ajanta.naming.URN target, ajanta.naming.URN retractor, ajanta.naming.URN reportTo)
          It is used to retract an agent ...it preempts the agent from its current task and its prespecified itinerary.
 byte[] sign(byte[] text)
           
 void terminate(ajanta.naming.URN target)
          It is used to abort an agent ...it immediately kill the agent.
 void terminate(ajanta.naming.URN target, ajanta.util.Ticket t)
          It is used to abort an agent ...it immediately kills the agent.
 boolean verify(byte[] text, byte[] sig, java.security.PublicKey pub)
           
 ajanta.naming.URN whoAreYou()
          A simple method in the AServer interface, for obtaining an agent server's URN
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

myURN

protected ajanta.naming.URN myURN
this agent server's URN ( name )


myHost

protected java.lang.String myHost
DNS name of my host machine


codeBase

protected java.net.URL codeBase
Code server running in this Agent Server


rmiRegURL

protected java.net.URL rmiRegURL
local server specific rmi registry


dd

protected java.util.Hashtable dd
The domains database table -- conatin an entry for all the agent currently residing on the server


rr

protected java.util.Hashtable rr
The resource registry table -- contain an entry for each registered resource


nameTGmap

protected java.util.Hashtable nameTGmap
maps agent names to thread group id


atp

protected ajanta.server.ATPListener atp
thread which handles agent transfer


atp_port

protected int atp_port
port number on which agent transfer take place


cs

protected ajanta.server.ClassServer cs
class (code) server thread


cs_port

protected int cs_port
port number of class (code) server thread


host

protected ajanta.server.AgentEnv host
server's context object -- an instance of this is passed to all the visting agents


eg_pub

protected ajanta.crypto.EGPublicKey eg_pub
ElGamal public key for server's owner


eg_priv

protected ajanta.crypto.EGPrivateKey eg_priv
ElGamal private key for server's owner


dsa_pub

protected java.security.PublicKey dsa_pub
DSA public key


dsa_priv

protected java.security.PrivateKey dsa_priv
DSA private key


eg

protected ajanta.crypto.ElGamal eg
ElGamal object used for encryption


dsa

protected java.security.Signature dsa
DSA signature object


tkt

protected ajanta.util.AgentTicketing tkt
used for ticket generation/verification


srand

protected java.security.SecureRandom srand
Secure random number generator


dsa_v

protected java.security.Signature dsa_v
DSA object for signature verification


securityManager

protected ajanta.server.AjantaSecurityManager securityManager
the security manager for the server


namereg

protected ajanta.server.NRAccess namereg
a sycronized class for calling namereg api's


logger

protected java.io.PrintStream logger
a logger file output stream


ca

protected ajanta.naming.CA ca

myCertificate

protected java.security.cert.X509Certificate myCertificate

nameregistryCertificate

protected java.security.cert.X509Certificate nameregistryCertificate
Constructor Detail

AgentServer

public AgentServer(java.lang.String n)
            throws java.rmi.RemoteException
AgentServer constructor

Parameters:
n - urn ( name ) of the agent server
See Also:
AgentServer
Method Detail

decrypt

public byte[] decrypt(ajanta.crypto.EGCipherText cipher)

encrypt

public ajanta.crypto.EGCipherText encrypt(ajanta.crypto.EGPublicKey pk,
                                          byte[] plaintext)

sign

public byte[] sign(byte[] text)
            throws java.security.SignatureException
java.security.SignatureException

verify

public boolean verify(byte[] text,
                      byte[] sig,
                      java.security.PublicKey pub)
               throws java.security.InvalidKeyException,
                      java.security.SignatureException
java.security.InvalidKeyException
java.security.SignatureException

whoAreYou

public ajanta.naming.URN whoAreYou()
                            throws java.rmi.RemoteException
A simple method in the AServer interface, for obtaining an agent server's URN

Specified by:
whoAreYou in interface AServer
java.rmi.RemoteException

getAgentCurrentServer

public ajanta.server.AServer getAgentCurrentServer(ajanta.naming.URN agentURN)
given URN of agent it locates it's current server and return reference to the server. Useful in recall, retract and terminate calls

Parameters:
agentURN - URN of the agent to be located
Returns:
return reference to current server of the agent
See Also:
AServer

recall

public void recall(ajanta.naming.URN target,
                   ajanta.naming.URN recaller,
                   ajanta.naming.URN reportTo)
            throws java.rmi.RemoteException
It is used to recall an agent ...which basically allow an agent to complete its task at the current server ( but it aborts its prespecifed itinerary) and upon completion migate it to the reportTo server. This do not involve authentication and will be deprecated in future release.

Specified by:
recall in interface AServer
Parameters:
target - URN of the agent to be relocated
recaller - URN of the recaller
reportTo - URN of the entity to whom agent has to report
java.rmi.RemoteException

retract

public void retract(ajanta.naming.URN target,
                    ajanta.naming.URN retractor,
                    ajanta.naming.URN reportTo)
             throws java.rmi.RemoteException
It is used to retract an agent ...it preempts the agent from its current task and its prespecified itinerary. Then immediately migate it to the reportTo server. This do not involve authentication and will be deprecated in future release.

Specified by:
retract in interface AServer
Parameters:
target - URN of the agent to be relocated
reportTo - URN of the entity to whom agent has to report
java.rmi.RemoteException

terminate

public void terminate(ajanta.naming.URN target)
               throws java.rmi.RemoteException
It is used to abort an agent ...it immediately kill the agent. This do not involve authentication and will be deprecated in future release.

Specified by:
terminate in interface AServer
Parameters:
target - URN of the agent to be terminated
java.rmi.RemoteException

ping

public java.lang.String ping()
                      throws java.rmi.RemoteException
Returns Agent Server Status. Currently "alive".

Specified by:
ping in interface AServer
java.rmi.RemoteException

authenticate

public ajanta.util.Ticket authenticate(ajanta.naming.URN caller,
                                       int nonce,
                                       ajanta.util.ContextObject context)
It is used to obtain ticket from this server from a remote site.

Specified by:
authenticate in interface AServer
Parameters:
caller - caller identity( URN )
nonce - random number used as challenge

remoteServerTicket

public ajanta.util.Ticket remoteServerTicket(ajanta.server.AServer targetServer,
                                             ajanta.naming.URN caller,
                                             int nonce,
                                             java.security.PrivateKey dsa_priv)
                                      throws java.rmi.RemoteException
It is used to do two way authentication...first it obtains a Ticket from the remote server and then using that ticket it creates another ticket and return to the caller.

Parameters:
targetServer - reference to the remote agent server
caller - URN of the caller ( server )
nonce - any random number
dsa_priv - dsa private key of the caller
Returns:
Ticket from the remote server...used for future authentication
java.rmi.RemoteException

recall

public void recall(ajanta.naming.URN target,
                   ajanta.naming.URN reportTo,
                   ajanta.util.Ticket t)
            throws java.rmi.RemoteException,
                   java.security.InvalidKeyException,
                   java.security.SignatureException
It is used to recall an agent ...which basically allow an agent to complete its task at the current server and upon completion migate it to the reportTo server ( but it aborts its prespecifed itinerary). Recaller must authenticate himself with the remote server inorder to recall the agent.Only owner, creator or gurdian are allowed to recall an agent.
     AServer targetServer = getAgentCurrentServer( agentURN );
     Ticket ticket = remoteServerTicket ( targetServer, myURN , 3000, dsa_priv );
     recall (agentURN , myURN , ticket )
 

Specified by:
recall in interface AServer
Parameters:
target - URN of the agent to be relocated
reportTo - URN of the entity to whom agent has to report
t - ticket obtained from the remote server
java.rmi.RemoteException
java.security.InvalidKeyException
java.security.SignatureException

retract

public void retract(ajanta.naming.URN target,
                    ajanta.naming.URN reportTo,
                    ajanta.util.Ticket t)
             throws java.rmi.RemoteException,
                    java.security.InvalidKeyException,
                    java.security.SignatureException
It is used to retract an agent ...it preempts the agent from its current task and its prespecifed itinerary. Then migate the agent to the reportTo server. Retractor must authenticate himself with the remote server inorder to retract the agent.Only owner, creator or gurdian are allowed to retract an agent.
     AServer targetServer = getAgentCurrentServer( agentURN );
     Ticket ticket = remoteServerTicket ( targetServer, myURN , 3000, dsa_priv );
     retract (agentURN , myURN , ticket )
 

Specified by:
retract in interface AServer
Parameters:
target - URN of the agent to be retracted
reportTo - URN of the entity to whom agent has to report
t - ticket obtained from the remote server
java.rmi.RemoteException
java.security.InvalidKeyException
java.security.SignatureException

terminate

public void terminate(ajanta.naming.URN target,
                      ajanta.util.Ticket t)
               throws java.rmi.RemoteException,
                      java.security.InvalidKeyException,
                      java.security.SignatureException
It is used to abort an agent ...it immediately kills the agent. Caller must authenticate himself with the remote server inorder to terminate the agent.Only owner, creator or gurdian are allowed to terminate an agent.
     AServer targetServer = getAgentCurrentServer( agentURN );
     Ticket ticket = remoteServerTicket ( targetServer, myURN , 3000, dsa_priv );
     terminate (agentURN  , ticket )
 

Specified by:
terminate in interface AServer
Parameters:
target - URN of the agent to be terminated
java.rmi.RemoteException
java.security.InvalidKeyException
java.security.SignatureException

launch

public void launch(ajanta.agent.Agent ag,
                   ajanta.naming.URN dest,
                   java.lang.String method,
                   java.lang.Class[] formals,
                   java.lang.Object[] actuals)
            throws LaunchFailedException
It launches a given agent to the specified destination.

Parameters:
ag - reference of the agent to be launched
dest - URN of the destination
method - name of the method to execute
formals - array of class names of method parametrs
actuals - array of objects i.e. values of the parametrs to the method
LaunchFailedException

report

public void report(ajanta.agent.Agent ag)
            throws AgentTerminateException
This method is invoked by agents which report back to their home site, either because their task is done, or in response to reacll / retract, or because they have encountered some exception which they could not handle. By default it just print a message identifying the which agent is reporting. An application' agent server shoul overide this method to provide application specific handeling.

Specified by:
report in interface Reportable
Parameters:
ag - reference of the agent reporting
AgentTerminateException

getNR

public ajanta.server.NRAccess getNR()
It returns a reference to NRAcess - sycronized class for calling namereg api's


deleteDDEntry

public void deleteDDEntry(ajanta.server.DDEntry obj)
This function removes the calling agent DDEntry from the domain database.

Parameters:
obj - reference of the DDEntry to be deleted

deleteDDEntry

public void deleteDDEntry(ajanta.naming.URN name)
This function removes the calling agent DDEntry from the domain database.


getRegURL

public java.net.URL getRegURL()
Return local server specific rmi registry URL.


registerAgent

public void registerAgent(ajanta.agent.Agent ag)
Registers an agent with the name registry, If an older entry exists try to rebind the agent.

Parameters:
ag - reference of the agent to be registered

main

public static void main(java.lang.String[] args)
Main program, which starts up the agent server This is only a generic main program. Application developers should create subclasses of AgentServer and implement their own main() methods. The only requirement is that the main program should instantiate their agent server class, and use it to launch agents into the network.


checkAdmissionPolicy

public boolean checkAdmissionPolicy(ajanta.agent.Credentials agentCredentials,
                                    java.net.InetAddress inetAddress,
                                    ajanta.naming.URN senderAgentServerURN)
The function returns true if the incoming agent can be accepted based on the agent server admission policy. The users should override this method, in their classes which inherit from AgentServer. The default implementation always returns true, which means an agent server accepts all agents.


logEvent

public boolean logEvent(ajanta.logger.Event e)

getCertificiates

public void getCertificiates()

getCascadedCertificate

public ajanta.naming.CascadedCertificate getCascadedCertificate(int key_length,
                                                                long duration)

getTemporaryPrivateKey

public java.security.PrivateKey getTemporaryPrivateKey()

getTemporaryPublicKey

public java.security.PublicKey getTemporaryPublicKey()

getMaxDuration

public long getMaxDuration(ajanta.naming.URN agentURN)