com.ibm.maf.atp
Class AtpConnectionImpl

java.lang.Object
  extended byjava.net.URLConnection
      extended bycom.ibm.maf.atp.AtpConnectionImpl
All Implemented Interfaces:
AtpConstants

public class AtpConnectionImpl
extends java.net.URLConnection
implements AtpConstants

An instance of this class creates a communication link between an application and an atp server.

Version:
1.10 $Date :$
Author:
Danny B. Lange, Mitsuru Oshima

Field Summary
private  Connection _connection
           
private  java.io.InputStream _inputStream
           
private  ContentOutputStream _outputStream
           
private  int _request_type
           
private  Name agent_name
           
(package private) static AgentProfile agent_profile
           
static int ATP_DEFAULT_PORT
          Default port number to receive atp messages.
protected static java.lang.String ATP_VERSION
           
protected static java.lang.String CRLF
           
(package private) static java.util.Hashtable default_request_properties
           
private  java.lang.String from
           
private  java.util.Hashtable headers
           
private  byte[] mic
           
(package private)  java.util.Hashtable request_properties
           
private  java.lang.String securityDomainname
           
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Fields inherited from interface com.ibm.atp.AtpConstants
ATCI_REQUEST, ATCI_RESPONSE, AUTHENTICATION_MANNER_DIGEST, AUTHENTICATION_MANNER_SIGNATURE, BAD_GATEWAY, BAD_REQUEST, DISPATCH, EXCEPTION, FETCH, FORBIDDEN, FUTURE, HANDLED, ILLEGAL_REQUEST, INTERNAL_ERROR, MAX_REQUEST_TYPE, MESSAGE, MOVED, NO_AUTHENTICATION_MANNER, NOT_AUTHENTICATED, NOT_FOUND, NOT_HANDLED, NOT_IMPLEMENTED, OKAY, ONEWAY, PING, REPLY, REQUEST_TYPE_BASE, RETRACT, SERVICE_UNAVAILABLE, SYNC
 
Constructor Summary
AtpConnectionImpl(java.net.URL url)
          Create a new instance of this class.
 
Method Summary
 void close()
           
 void connect()
          Make a comminucation link with the destination.
 java.lang.String getHeaderField(java.lang.String key)
           
 java.io.InputStream getInputStream()
          Get an input stream of the communication link.
 byte[] getMIC()
           
 java.io.OutputStream getOutputStream()
          Get an output stream of the communication link.
 java.lang.String getProperty(java.lang.String key)
           
 java.lang.String getReasonPhase()
           
(package private)  SharedSecret getSharedSecret()
           
 int getStatusCode()
           
protected static int guessRequestTypeFromURL(java.net.URL url)
           
 void parseHeaders()
           
static void parseHeaders(java.io.DataInputStream di, java.util.Hashtable headers)
           
 void sendRequest()
           
protected  void sendRequestHeaders(java.io.PrintStream p)
           
 void setAgentName(Name name)
           
 void setAgentProfile(AgentProfile profile)
           
 void setMIC(byte[] bytes)
           
 void setRequestProperty(java.lang.String key, java.lang.String value)
           
 void setRequestType(int i)
           
 void setSender(java.lang.String address)
           
private static void verboseOut(java.lang.String msg)
           
 
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getLastModified, getPermission, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATP_DEFAULT_PORT

public static final int ATP_DEFAULT_PORT
Default port number to receive atp messages.

See Also:
Constant Field Values

CRLF

protected static final java.lang.String CRLF
See Also:
Constant Field Values

ATP_VERSION

protected static final java.lang.String ATP_VERSION
See Also:
Constant Field Values

default_request_properties

static java.util.Hashtable default_request_properties

agent_profile

static AgentProfile agent_profile

_request_type

private int _request_type

_inputStream

private java.io.InputStream _inputStream

_outputStream

private ContentOutputStream _outputStream

_connection

private Connection _connection

from

private java.lang.String from

agent_name

private Name agent_name

securityDomainname

private java.lang.String securityDomainname

mic

private byte[] mic

request_properties

java.util.Hashtable request_properties

headers

private java.util.Hashtable headers
Constructor Detail

AtpConnectionImpl

public AtpConnectionImpl(java.net.URL url)
                  throws java.io.IOException
Create a new instance of this class.

Parameters:
url - a destination URL to which the application connects. The protocol is "atp".
Method Detail

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

connect

public void connect()
             throws java.io.IOException
Make a comminucation link with the destination.

Throws:
java.io.IOException - if can not make a communication link.

getHeaderField

public java.lang.String getHeaderField(java.lang.String key)

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get an input stream of the communication link.

Returns:
an input stream.
Throws:
java.io.IOException - if the communication link has a problem.

getMIC

public byte[] getMIC()

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get an output stream of the communication link. If the destination is out of firewall and a proxy is specified, an output stream connected to the proxy will be returned, The stream will add the destination atp address to top of an output data. The proxy reads the address, takes it away and forewards the ramained data to the specified destination.

Returns:
an output stream.
Throws:
java.io.IOException - if the communication link has a problem.

getProperty

public java.lang.String getProperty(java.lang.String key)

getReasonPhase

public java.lang.String getReasonPhase()

getSharedSecret

SharedSecret getSharedSecret()

getStatusCode

public int getStatusCode()

guessRequestTypeFromURL

protected static int guessRequestTypeFromURL(java.net.URL url)
                                      throws java.io.IOException
Throws:
java.io.IOException

parseHeaders

public void parseHeaders()
                  throws java.io.IOException
Throws:
java.io.IOException

parseHeaders

public static void parseHeaders(java.io.DataInputStream di,
                                java.util.Hashtable headers)
                         throws java.io.IOException
Throws:
java.io.IOException

sendRequest

public void sendRequest()
                 throws java.io.IOException
Throws:
java.io.IOException

sendRequestHeaders

protected void sendRequestHeaders(java.io.PrintStream p)
                           throws java.io.IOException
Throws:
java.io.IOException

setAgentName

public void setAgentName(Name name)

setAgentProfile

public void setAgentProfile(AgentProfile profile)

setMIC

public void setMIC(byte[] bytes)

setRequestProperty

public void setRequestProperty(java.lang.String key,
                               java.lang.String value)

setRequestType

public void setRequestType(int i)

setSender

public void setSender(java.lang.String address)

verboseOut

private static void verboseOut(java.lang.String msg)