Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.ciphercore
Class Client  view Client download Client.java

java.lang.Object
  extended bycom.ciphercore.Client

public class Client
extends java.lang.Object

Client is the class that establishes the connection with the Child. It handles all the crypto negotiation and prepares a pair of streams for communicating with your child.

Typical Usage:


 import com.ciphercore.Client;
 import com.ciphercore.Server;
 
 public class MyClient {
     
     public static void main( String[] args ) {
         
         // Instantiate a client, tell it the child type, host and port.
         Client client = new Client( "mypackage.MyChild",
                                     "localhost",
                                     Server.DEFAULT_PORT );
         
         // Tell the client to establish the connection to the child.
         client.connect();
         
         try {
             
             // Get the streams that connect to the Child.
             InputStream in = client.getBaseInputStream();
             OutputStream out = client.getBaseOutputStream();
             
             // Do whatever you do.
             while( ! finished ) {
                 ... Communicate With MyChild ...
             }
             
             // Not vital (Client closes them), but good habit.
             out.close();
             in.close();
         
         } catch( IOException e ) {
             ... handle the exception ...
         } finally {
             // Release the network connection.
             client.close();
         }
     }
 }
 


Field Summary
private  java.lang.String _advancedCfgLocation
           
private  java.io.InputStream _baseIn
           
private  java.io.OutputStream _baseOut
           
private  java.lang.String _basicCfgLocation
           
private  java.lang.String _childClassName
           
private  com.traxel.crypto.CipherPartner _cipherSelf
           
private  java.lang.String _hostName
           
private  java.lang.String _password
           
private  int _port
           
private  java.util.Properties _serverHashes
           
private  java.lang.String _serverHashesLocation
           
private  java.net.Socket _socket
           
private  java.lang.String _userName
           
static java.lang.String DEFAULT_HOST_NAME
          If no host is specified, connect to "localhost".
 
Constructor Summary
Client(java.lang.String childClassName)
          Creates a client using the default host and port.
Client(java.lang.String childClassName, java.lang.String hostName, int port)
          Creates a client using the specified host and port.
 
Method Summary
 void close()
          Closes the IO Streams and the socket.
 void connect()
          Establishes the connection as specified in the constructor.
 java.lang.String getAdvancedCfgLocation()
           
 java.io.InputStream getBaseInputStream()
          Returns the OutputStream the connects to your child's InputStream
 java.io.OutputStream getBaseOutputStream()
          Returns the InputStream that connects to your child's OutputStream
 java.lang.String getBasicCfgLocation()
           
 java.lang.String getChildClassName()
          Returns the childClassName that this client is configured for.
protected  com.traxel.crypto.CipherPartner getCipherSelf()
           
protected  javax.crypto.Cipher getDecryptCipher()
           
protected  javax.crypto.Cipher getEncryptCipher()
           
 java.lang.String getHostName()
          Returns the hostname that this client is configured for.
protected  byte[] getIv()
           
 java.lang.String getPassword()
           
 int getPort()
          Returns the port that this client is configured for.
 java.lang.String getProviderName()
           
protected  byte[] getPublicEncoded()
           
 java.lang.String getServerHash(java.lang.String serverName)
           
 java.util.Properties getServerHashes()
           
 java.lang.String getServerHashesLocation()
           
protected  java.net.Socket getSocket()
           
 java.lang.String getUserName()
           
protected  void locateFiles()
           
protected  void readAdvancedCfg()
           
protected  void readBasicCfg()
           
protected  void readServerHashes()
           
protected  void sendPassword()
           
protected  void setAdvancedCfgLocation(java.lang.String location)
           
protected  void setBaseInputStream(java.io.InputStream baseIn)
           
protected  void setBaseOutputStream(java.io.OutputStream baseOut)
           
protected  void setBasicCfgLocation(java.lang.String location)
           
protected  void setChildClassName(java.lang.String name)
           
protected  void setCipherSelf(com.traxel.crypto.CipherPartner self)
           
protected  void setHostName(java.lang.String name)
           
 void setPassword(java.lang.String password)
           
protected  void setPort(int port)
           
 void setServerHash(java.lang.String serverName, java.lang.String hashBase16)
           
protected  void setServerHashes(java.util.Properties serverHashes)
           
protected  void setServerHashesLocation(java.lang.String location)
           
protected  void setSocket(java.net.Socket socket)
           
 void setUserName(java.lang.String userName)
           
protected  void verifyServer(byte[] serverPublicEncoded)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOST_NAME

public static final java.lang.String DEFAULT_HOST_NAME
If no host is specified, connect to "localhost".

See Also:
Constant Field Values

_childClassName

private java.lang.String _childClassName

_hostName

private java.lang.String _hostName

_userName

private java.lang.String _userName

_password

private java.lang.String _password

_port

private int _port

_socket

private java.net.Socket _socket

_cipherSelf

private com.traxel.crypto.CipherPartner _cipherSelf

_baseIn

private java.io.InputStream _baseIn

_baseOut

private java.io.OutputStream _baseOut

_basicCfgLocation

private java.lang.String _basicCfgLocation

_advancedCfgLocation

private java.lang.String _advancedCfgLocation

_serverHashesLocation

private java.lang.String _serverHashesLocation

_serverHashes

private java.util.Properties _serverHashes
Constructor Detail

Client

public Client(java.lang.String childClassName)
Creates a client using the default host and port.


Client

public Client(java.lang.String childClassName,
              java.lang.String hostName,
              int port)
Creates a client using the specified host and port.

Method Detail

connect

public void connect()
             throws java.io.IOException,
                    ServerKeyException,
                    UserPasswordException
Establishes the connection as specified in the constructor. This is where host switching would be implemented if this system is intended to be capable of talking to a balanced cluster.


sendPassword

protected void sendPassword()
                     throws UserPasswordException,
                            java.io.IOException

verifyServer

protected void verifyServer(byte[] serverPublicEncoded)
                     throws ServerKeyException

close

public void close()
Closes the IO Streams and the socket.


locateFiles

protected void locateFiles()

readServerHashes

protected void readServerHashes()

readBasicCfg

protected void readBasicCfg()

readAdvancedCfg

protected void readAdvancedCfg()

setCipherSelf

protected void setCipherSelf(com.traxel.crypto.CipherPartner self)

setChildClassName

protected void setChildClassName(java.lang.String name)

setHostName

protected void setHostName(java.lang.String name)

setPort

protected void setPort(int port)

setSocket

protected void setSocket(java.net.Socket socket)

setBasicCfgLocation

protected void setBasicCfgLocation(java.lang.String location)

setAdvancedCfgLocation

protected void setAdvancedCfgLocation(java.lang.String location)

setServerHashesLocation

protected void setServerHashesLocation(java.lang.String location)

setServerHashes

protected void setServerHashes(java.util.Properties serverHashes)

setBaseInputStream

protected void setBaseInputStream(java.io.InputStream baseIn)

setBaseOutputStream

protected void setBaseOutputStream(java.io.OutputStream baseOut)

setUserName

public void setUserName(java.lang.String userName)

setPassword

public void setPassword(java.lang.String password)

getChildClassName

public java.lang.String getChildClassName()
Returns the childClassName that this client is configured for.


getHostName

public java.lang.String getHostName()
Returns the hostname that this client is configured for.


getPort

public int getPort()
Returns the port that this client is configured for.


getBaseOutputStream

public java.io.OutputStream getBaseOutputStream()
Returns the InputStream that connects to your child's OutputStream


getBaseInputStream

public java.io.InputStream getBaseInputStream()
Returns the OutputStream the connects to your child's InputStream


getBasicCfgLocation

public java.lang.String getBasicCfgLocation()

getAdvancedCfgLocation

public java.lang.String getAdvancedCfgLocation()

getServerHashesLocation

public java.lang.String getServerHashesLocation()

getServerHashes

public java.util.Properties getServerHashes()

getProviderName

public java.lang.String getProviderName()

getUserName

public java.lang.String getUserName()

getPassword

public java.lang.String getPassword()

getSocket

protected java.net.Socket getSocket()

getCipherSelf

protected com.traxel.crypto.CipherPartner getCipherSelf()

getEncryptCipher

protected javax.crypto.Cipher getEncryptCipher()

getDecryptCipher

protected javax.crypto.Cipher getDecryptCipher()

getPublicEncoded

protected byte[] getPublicEncoded()

getIv

protected byte[] getIv()
                throws java.io.IOException

getServerHash

public java.lang.String getServerHash(java.lang.String serverName)

setServerHash

public void setServerHash(java.lang.String serverName,
                          java.lang.String hashBase16)