java.lang.Object
com.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();
}
}
}
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
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.
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)