final int bytesRead = receiveEncryptedData();
if (bytesRead == -1) {
this.endOfStream = true;
}
doHandshake();
final HandshakeStatus status = this.sslEngine.getHandshakeStatus();
if (status == HandshakeStatus.NOT_HANDSHAKING || status == HandshakeStatus.FINISHED) {
decryptData();
}
} while (this.sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_TASK);
// Some decrypted data is available or at the end of stream