code: public static byte[] readSslMessage(InputStream in)
          throws IOException {
          byte [] header = new byte[5];
          readFully(in, header, 0, header.length);
  	int length;
          if (isSSLv3Packet(header))
          	length = toShort(header[3], header[4]);
  	else if (isSSLv2HelloPacket(header))
          	length = (((header[0] & 0x7f) << 8) | (header[1] & 0xff)) - 3;
  	else {
              throw new IOException("Invalid SSL header");
          }
          byte [] inToken = new byte[header.length + length];
          System.arraycopy(header, 0, inToken, 0, header.length);
          readFully(in, inToken, header.length, length);
          return inToken;
      }
docs: Reads an entire SSL message from the specified
  input stream.
  
  @param in the input stream to read the SSL message
  from.
  @return the byte array containing the SSL message
  @exception IOException if I/O error occurs.