hudson.cli
Class Connection

java.lang.Object
  extended by hudson.cli.Connection

public class Connection
extends Object


Field Summary
 DataInputStream din
           
 DataOutputStream dout
           
 InputStream in
           
 OutputStream out
           
 
Constructor Summary
Connection(InputStream in, OutputStream out)
           
Connection(Socket socket)
           
 
Method Summary
 void close()
           
 KeyAgreement diffieHellman(boolean side)
          Performs a Diffie-Hellman key exchange and produce a common secret between two ends of the connection.
 KeyAgreement diffieHellman(boolean side, int keySize)
           
 Connection encryptConnection(SecretKey sessionKey, String algorithm)
          Upgrades a connection with transport encryption by the specified symmetric cipher.
static byte[] fold(byte[] bytes, int size)
          Given a byte array that contains arbitrary number of bytes, digests or expands those bits into the specified number of bytes without loss of entropy.
 void proveIdentity(byte[] sharedSecret, KeyPair key)
          Used in conjunction with verifyIdentity(byte[]) to prove that we actually own the private key of the given key pair.
 boolean readBoolean()
           
 byte[] readByteArray()
           
 X509EncodedKeySpec readKey()
           
<T> T
readObject()
          Receives an object sent by writeObject(Object)
 String readUTF()
           
 PublicKey verifyIdentity(byte[] sharedSecret)
          Verifies that we are talking to a peer that actually owns the private key corresponding to the public key we get.
 void writeBoolean(boolean b)
           
 void writeByteArray(byte[] data)
           
 void writeKey(Key key)
           
 void writeObject(Object o)
          Sends a serializable object.
 void writeUTF(String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

public final InputStream in

out

public final OutputStream out

din

public final DataInputStream din

dout

public final DataOutputStream dout
Constructor Detail

Connection

public Connection(Socket socket)
           throws IOException
Throws:
IOException

Connection

public Connection(InputStream in,
                  OutputStream out)
Method Detail

writeUTF

public void writeUTF(String msg)
              throws IOException
Throws:
IOException

readUTF

public String readUTF()
               throws IOException
Throws:
IOException

writeBoolean

public void writeBoolean(boolean b)
                  throws IOException
Throws:
IOException

readBoolean

public boolean readBoolean()
                    throws IOException
Throws:
IOException

writeObject

public void writeObject(Object o)
                 throws IOException
Sends a serializable object.

Throws:
IOException

readObject

public <T> T readObject()
             throws IOException,
                    ClassNotFoundException
Receives an object sent by writeObject(Object)

Throws:
IOException
ClassNotFoundException

writeKey

public void writeKey(Key key)
              throws IOException
Throws:
IOException

readKey

public X509EncodedKeySpec readKey()
                           throws IOException
Throws:
IOException

writeByteArray

public void writeByteArray(byte[] data)
                    throws IOException
Throws:
IOException

readByteArray

public byte[] readByteArray()
                     throws IOException
Throws:
IOException

diffieHellman

public KeyAgreement diffieHellman(boolean side)
                           throws IOException,
                                  GeneralSecurityException
Performs a Diffie-Hellman key exchange and produce a common secret between two ends of the connection.

DH is also useful as a coin-toss algorithm. Two parties get the same random number without trusting each other.

Throws:
IOException
GeneralSecurityException

diffieHellman

public KeyAgreement diffieHellman(boolean side,
                                  int keySize)
                           throws IOException,
                                  GeneralSecurityException
Throws:
IOException
GeneralSecurityException

encryptConnection

public Connection encryptConnection(SecretKey sessionKey,
                                    String algorithm)
                             throws IOException,
                                    GeneralSecurityException
Upgrades a connection with transport encryption by the specified symmetric cipher.

Returns:
A new Connection object that includes the transport encryption.
Throws:
IOException
GeneralSecurityException

fold

public static byte[] fold(byte[] bytes,
                          int size)
Given a byte array that contains arbitrary number of bytes, digests or expands those bits into the specified number of bytes without loss of entropy. Cryptographic utility code.


proveIdentity

public void proveIdentity(byte[] sharedSecret,
                          KeyPair key)
                   throws IOException,
                          GeneralSecurityException
Used in conjunction with verifyIdentity(byte[]) to prove that we actually own the private key of the given key pair.

Throws:
IOException
GeneralSecurityException

verifyIdentity

public PublicKey verifyIdentity(byte[] sharedSecret)
                         throws IOException,
                                GeneralSecurityException
Verifies that we are talking to a peer that actually owns the private key corresponding to the public key we get.

Throws:
IOException
GeneralSecurityException

close

public void close()
           throws IOException
Throws:
IOException


Copyright © 2004-2013. All Rights Reserved.