Agent System POND 1.0 (1.7.2000)

PkgAgentSystem
Class AMPURLConnection

java.lang.Object
  |
  +--java.net.URLConnection
        |
        +--PkgAgentSystem.AMPURLConnection

class AMPURLConnection
extends URLConnection

A connection of type "amp" to another computer, allowing to transfer an agent from the local to the remote host. It is verified in advance, whether the agent will be allowed to move there. If AgentSystem.SECURE_CONNECTION is true, Diffie-Hellman key exchange is used to encrypt the communication. Then also the identity of the remote host is verfied (challenged for knowledge of the private key). This verification is symmetric: We also have to prove our identity. Both hosts must have the same value, else the protocol will be aborted. (AMP = Agent Movement Protocol)

Version:
1.0, 1.7.2000
Author:
Michael Sonntag
See Also:
URLConnection, AgentData, ServingThread, AMPStreamHandler, AMPStreamHandlerFactory, URL

Field Summary
protected  AgentSystem ag_sys
          The associated AgentSystem.
protected  ObjectInputStream in
          The ObjectInputStream of the socket
protected  Certificate other_cert
          Certificate of the remote host
protected  PublicKey other_pub_key
          The public key of the remote host
protected  Signature other_sign
          Signature object of the remote host.
protected  Certificate our_cert
          Certificate of this AgentSystem
protected  PublicKey our_pub_key
          Our own public key (of the AgentSystem)
protected  Signature our_sign
          Signature object of this host.
protected  ObjectOutputStream out
          The ObjectOutputStream of the socket
protected static SecureRandom rnd
          A random number generator to create challenges
protected  javax.crypto.SecretKey sessionKey
          The session key for encrypting the data.
protected  Socket sock
          The socket we use to connect to the other host
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, factory, ifModifiedSince, url, useCaches
 
Constructor Summary
AMPURLConnection(URL url)
          Creates a new connection to an URL.
 
Method Summary
 void checkAcceptance(AgentData data)
          Check whether an agent will be allowed to move to the remote host.
 void connect()
          Connect to the URL.
 InputStream getInputStream()
          Returns the InputStream of this connection.
 OutputStream getOutputStream()
          Returns the OutputStream of this connection.
 Permission getPermission()
          Get the permission needed for accessing his URL.
 void sendAgent(AgentData data)
          Send an agent to the remote host.
 void setAuthenticationInfo(AgentSystem sys)
          Sets the authentication info needed for establishing the connection.
 
Methods inherited from class java.net.URLConnection
, getAllowUserInteraction, getContent, getContentEncoding, getContentHandler, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getIfModifiedSince, getLastModified, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sock

protected Socket sock
The socket we use to connect to the other host

in

protected ObjectInputStream in
The ObjectInputStream of the socket

out

protected ObjectOutputStream out
The ObjectOutputStream of the socket

sessionKey

protected javax.crypto.SecretKey sessionKey
The session key for encrypting the data. Will be null if not a secure connection

other_pub_key

protected PublicKey other_pub_key
The public key of the remote host

our_pub_key

protected PublicKey our_pub_key
Our own public key (of the AgentSystem)

other_sign

protected Signature other_sign
Signature object of the remote host. Stored just for optimization. Must be reinitialized before use

our_sign

protected Signature our_sign
Signature object of this host. Stored just for optimization. Must be reinitialized before use

our_cert

protected Certificate our_cert
Certificate of this AgentSystem

other_cert

protected Certificate other_cert
Certificate of the remote host

ag_sys

protected AgentSystem ag_sys
The associated AgentSystem. Needed for access to our public/private key, certificate and various routines.

rnd

protected static SecureRandom rnd
A random number generator to create challenges
Constructor Detail

AMPURLConnection

public AMPURLConnection(URL url)
Creates a new connection to an URL.
Parameters:
url - The URL to connect to.
Method Detail

getPermission

public Permission getPermission()
                         throws IOException
Get the permission needed for accessing his URL. If it is in the local cache or we are already connected, no permission is needed.Otherwise SocketPermission("connect") to the host and port in the url is needed.
Returns:
The necessary permission for opening the url
Overrides:
getPermission in class URLConnection
See Also:
SocketPermission

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Returns the OutputStream of this connection. Throws always an UnknownServiceException as the AMP-URLConnection does not support this (no manual handling).
Throws:
UnknownServiceException -  
Overrides:
getOutputStream in class URLConnection

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns the InputStream of this connection. Throws always an UnknownServiceException as the AMP-URLConnection does not support this (no manual handling).
Throws:
UnknownServiceException -  
Overrides:
getInputStream in class URLConnection

setAuthenticationInfo

public void setAuthenticationInfo(AgentSystem sys)
                           throws AuthenticationException
Sets the authentication info needed for establishing the connection. Needed for getting access to the keystore, containing the public and private key. The must be RSA keys (Encryption AND signing have to be possible). The public key must be in the certificate store under the name "Server RSA Certificate", The private key must be in a key-entry with name "Server RSA Private key".
Parameters:
sys - The agent system establishing this connection. Stored for later use.
Throws:
AuthenticationException - if an error occurs (Certificate or private key cannot be extracted)

connect

public void connect()
             throws IOException,
                    AuthenticationException
Connect to the URL. The initialization protocol is completed and (if it is a secure connection) the key exchange takes place and the other host is challenged.
Throws:
IOException -  
AuthenticationException -  
Overrides:
connect in class URLConnection

sendAgent

public void sendAgent(AgentData data)
               throws IOException,
                      ReceiveAgentDeniedException
Send an agent to the remote host. Will create a remote duplicate, as the local agent is NOT destroyed (Should be done by the caller). The code (package) and the agent itself is transfered.
Parameters:
the - AgentData of the agent to transfer
Throws:
IOException - if any problem with the network occurs
ReceiveAgentDeniedException - if the other hosts denies the agent access

checkAcceptance

public void checkAcceptance(AgentData data)
                     throws IOException,
                            ReceiveAgentDeniedException
Check whether an agent will be allowed to move to the remote host. Will complete silently if successful or throw a ReceiveAgentDeniedException.
Parameters:
the - AgentData of the agent to transfer
Throws:
IOException - if any problem with the network occurs
ReceiveAgentDeniedException - if the other hosts denies the agent access
See Also:
AgentData

Agent System POND 1.0 (1.7.2000)

Submit a bug

Copyright 2000 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.