SSLSession toSession(byte[] data,String host,int port){
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  DataInputStream dais=new DataInputStream(bais);
  try {
    int type=dais.readInt();
    if (type != OPEN_SSL) {
      log(new AssertionError("Unexpected type ID: " + type));
      return null;
    }
    int length=dais.readInt();
    byte[] sessionData=new byte[length];
    dais.readFully(sessionData);
    int count=dais.readInt();
    X509Certificate[] certs=new X509Certificate[count];
    for (int i=0; i < count; i++) {
      length=dais.readInt();
      byte[] certData=new byte[length];
      dais.readFully(certData);
      certs[i]=OpenSSLX509Certificate.fromX509Der(certData);
    }
    return new OpenSSLSessionImpl(sessionData,host,port,certs,this);
  }
 catch (  IOException e) {
    log(e);
    return null;
  }
}

SSLSession toSession ( byte [ ] data , String host , int port ) { ByteArrayInputStream bais = new ByteArrayInputStream ( data ) ; DataInputStream dais = new DataInputStream ( bais ) ; try { int type = dais . readInt ( ) ; if ( type != OPEN_SSL ) { log ( new AssertionError ( "Unexpected type ID: " + type ) ) ; return null ; } int length = dais . readInt ( ) ; byte [ ] sessionData = new byte [ length ] ; dais . readFully ( sessionData ) ; int count = dais . readInt ( ) ; X509Certificate [ ] certs = new X509Certificate [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { length = dais . readInt ( ) ; byte [ ] certData = new byte [ length ] ; dais . readFully ( certData ) ; certs [ i ] = OpenSSLX509Certificate . fromX509Der ( certData ) ; } return new OpenSSLSessionImpl ( sessionData , host , port , certs , this ) ; } catch ( IOException e ) { log ( e ) ; return null ; } }
creates a session from the given bytes .
