protected boolean doHandshake ( ByteBuffer receiveBuffer ) throws IOException { if ( ! session . isOpen ( ) ) { close ( ) ; return ( initialHSComplete = false ) ; } if ( initialHSComplete ) { return true ; } switch ( initialHSStatus ) { case NOT_HANDSHAKING : case FINISHED : { handshakeFinish ( ) ; return initialHSComplete ; } case NEED_UNWRAP : doHandshakeReceive ( receiveBuffer ) ; if ( initialHSStatus != SSLEngineResult . HandshakeStatus . NEED_WRAP ) break ; case NEED_WRAP : doHandshakeResponse ( ) ; break ; default : // NEED_TASK throw new SecureNetException ( "Invalid Handshaking State" + initialHSStatus ) ; } return initialHSComplete ; }
The initial handshake is a procedure by which the two peers exchange communication parameters until an SecureSession is established . Application data can not be sent during this phase .