com.kodemuse.security.ssl
Class AbstractSSLSocketDecorator

java.lang.Object
  |
  +--com.kodemuse.security.ssl.LogCapability
        |
        +--com.kodemuse.security.ssl.AbstractSSLSocketDecorator
All Implemented Interfaces:
ConnectionDecorator, SSLConstants
Direct Known Subclasses:
SSLClientSocketDecorator, SSLServerSocketDecorator

abstract class AbstractSSLSocketDecorator
extends LogCapability
implements SSLConstants, ConnectionDecorator

Base class for decorating socket and converting to Secure Socket

Author:
Harmeet Bedi

Field Summary
protected  OutputBuffer buf
           
protected  SSLContext ctxt
           
protected  CipherSpec currCS
           
protected  java.io.DataInputStream din
           
protected  HandshakeDigest handshakeDigest
           
protected  MasterSecret masterSecret
           
protected  java.io.OutputStream out
           
protected  java.security.cert.X509Certificate[] peerCert
           
protected  long read_sequence_num
           
protected  CipherSpec selectedSpec
           
protected  SessionID serverSessionID
           
protected  TrustStore trustStore
           
protected  long write_sequence_num
           
 
Fields inherited from interface com.kodemuse.security.ssl.SSLConstants
ALERT_CONTENT, APPLICATION_DATA_CONTENT, BAD_CERTIFICATE_ALERTDESC, BAD_RECORD_MAC_ALERTDESC, CERTIFICATE_EXPIRED_ALERTDESC, CERTIFICATE_HANDSHAKE, CERTIFICATE_REQUEST_HANDSHAKE, CERTIFICATE_REVOKED_ALERTDESC, CERTIFICATE_UNKNOWN_ALERTDESC, CERTIFICATE_VERIFY_HANDSHAKE, CHANGE_CIPHER_SPEC_CONTENT, CLIENT, CLIENT_HELLO_HANDSHAKE, CLIENT_KEY_EXCHANGE_HANDSHAKE, CLOSE_ALERT, CLOSE_NOTIFY_ALERTDESC, DECOMPRESSION_FAILURE_ALERTDESC, FATAL_ALERTLEVEL, FINISHED_CLIENT_SENDER, FINISHED_HANDSHAKE, FINISHED_SERVER_SENDER, HANDSHAKE_CONTENT, HANDSHAKE_FAILURE_ALERTDESC, HELLO_REQUEST_HANDSHAKE, ILLEGAL_PARAMETER_ALERTDESC, MAX_RECORD_SIZE, MD5_PAD_1, MD5_PAD_2, MD5LEN, NO_CERTIFICATE_ALERTDESC, NULL_COMPRESSION, RNG, SERVER, SERVER_HELLO_DONE_HANDSHAKE, SERVER_HELLO_HANDSHAKE, SERVER_KEY_EXCHANGE_HANDSHAKE, SHA_PAD_1, SHA_PAD_2, SHA1LEN, SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA, SSL_DH_anon_EXPORT_WITH_RC4_40_MD5, SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_DES_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5, SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA, SSL_DH_DSS_WITH_DES_CBC_SHA, SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DH_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA, SSL_FORTEZZA_KEA_WITH_NULL_SHA, SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, SSL_NULL_WITH_NULL_NULL, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_RSA_WITH_IDEA_CBC_SHA, SSL_RSA_WITH_NULL_MD5, SSL_RSA_WITH_NULL_SHA, SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, SSLV3_VERSION, TLSV1_VERSION, UNEXPECTED_MESSAGE_ALERTDESC, UNEXPECTEDMSG_ALERT, UNSUPPORTED_CERTIFICATE_ALERTDESC, WARNING_ALERTLEVEL
 
Constructor Summary
(package private) AbstractSSLSocketDecorator(SSLContext ctxt, TrustStore trustStore)
           
 
Method Summary
 java.net.Socket decorate(java.net.Socket connection)
           
protected  java.io.DataInputStream getHandshakeInput(HandshakeType expectedType)
           
protected  void readCertificateHandshake(boolean serverCerts)
           
protected  void readChangeCipherSpec()
           
protected  void readClientCertificateVerify()
           
protected  void readClientHelloHandshake()
           
protected  void readClientKeyExchangeHandshake()
           
protected  void readFinished(boolean server)
           
protected  Handshake readHandshake()
           
protected  boolean readServerCertificateRequestOrHelloDone()
           
protected  void readServerHelloDoneHandshake()
           
protected  void readServerHelloHandshake()
           
protected abstract  boolean wrapSocket(java.net.Socket plainSock)
           
protected  void writeChangeCipherSpec()
           
protected  void writeClientCertificateVerify()
           
protected  void writeClientHelloHandshake(SessionID sessid)
           
protected  void writeClientKeyExchangeHandshake()
           
protected  void writeFinished(boolean server)
           
protected  void writeFinished(Finished fin, boolean server)
           
protected  void writeHandshake(Handshake handshake)
           
protected  void writeHandshake(HandshakeType type, DataSource ds)
           
protected  void writeHandshakeCertificates()
           
protected  void writeServerCertificateRequest()
           
protected  void writeServerHelloDoneHandshake()
           
protected  void writeServerHelloHandshake()
           
 
Methods inherited from class com.kodemuse.security.ssl.LogCapability
log, protocolLog
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currCS

protected CipherSpec currCS

handshakeDigest

protected final HandshakeDigest handshakeDigest

buf

protected final OutputBuffer buf

out

protected java.io.OutputStream out

din

protected java.io.DataInputStream din

serverSessionID

protected SessionID serverSessionID

trustStore

protected final TrustStore trustStore

peerCert

protected java.security.cert.X509Certificate[] peerCert

ctxt

protected final SSLContext ctxt

masterSecret

protected final MasterSecret masterSecret

selectedSpec

protected CipherSpec selectedSpec

write_sequence_num

protected long write_sequence_num

read_sequence_num

protected long read_sequence_num
Constructor Detail

AbstractSSLSocketDecorator

AbstractSSLSocketDecorator(SSLContext ctxt,
                           TrustStore trustStore)
Method Detail

decorate

public final java.net.Socket decorate(java.net.Socket connection)
                               throws java.io.IOException
Specified by:
decorate in interface ConnectionDecorator

readClientHelloHandshake

protected void readClientHelloHandshake()
                                 throws java.io.IOException

writeClientHelloHandshake

protected void writeClientHelloHandshake(SessionID sessid)
                                  throws java.io.IOException

readServerHelloHandshake

protected void readServerHelloHandshake()
                                 throws java.io.IOException

writeServerHelloHandshake

protected void writeServerHelloHandshake()
                                  throws java.io.IOException

writeChangeCipherSpec

protected void writeChangeCipherSpec()
                              throws java.io.IOException

readChangeCipherSpec

protected void readChangeCipherSpec()
                             throws java.io.IOException,
                                    org.bouncycastle.crypto.InvalidCipherTextException,
                                    java.security.DigestException

writeFinished

protected void writeFinished(boolean server)
                      throws java.io.IOException

readFinished

protected void readFinished(boolean server)
                     throws java.io.IOException,
                            org.bouncycastle.crypto.InvalidCipherTextException,
                            java.security.NoSuchAlgorithmException

writeHandshakeCertificates

protected void writeHandshakeCertificates()
                                   throws java.lang.Exception

readServerCertificateRequestOrHelloDone

protected boolean readServerCertificateRequestOrHelloDone()
                                                   throws java.io.IOException

writeServerCertificateRequest

protected void writeServerCertificateRequest()
                                      throws java.io.IOException

writeServerHelloDoneHandshake

protected void writeServerHelloDoneHandshake()
                                      throws java.io.IOException

readServerHelloDoneHandshake

protected void readServerHelloDoneHandshake()
                                     throws java.io.IOException

readCertificateHandshake

protected void readCertificateHandshake(boolean serverCerts)
                                 throws java.lang.Exception

readClientKeyExchangeHandshake

protected void readClientKeyExchangeHandshake()
                                       throws java.io.IOException,
                                              org.bouncycastle.crypto.InvalidCipherTextException,
                                              java.security.DigestException

writeClientKeyExchangeHandshake

protected void writeClientKeyExchangeHandshake()
                                        throws java.io.IOException,
                                               org.bouncycastle.crypto.InvalidCipherTextException,
                                               java.security.DigestException

writeClientCertificateVerify

protected void writeClientCertificateVerify()
                                     throws java.lang.Exception

readClientCertificateVerify

protected void readClientCertificateVerify()
                                    throws java.lang.Exception

writeFinished

protected void writeFinished(Finished fin,
                             boolean server)

writeHandshake

protected void writeHandshake(HandshakeType type,
                              DataSource ds)
                       throws java.io.IOException

writeHandshake

protected void writeHandshake(Handshake handshake)
                       throws java.io.IOException

getHandshakeInput

protected java.io.DataInputStream getHandshakeInput(HandshakeType expectedType)
                                             throws java.io.IOException

readHandshake

protected Handshake readHandshake()
                           throws java.io.IOException

wrapSocket

protected abstract boolean wrapSocket(java.net.Socket plainSock)
                               throws java.lang.Exception