// data already encrypted; simply return buffer
handler.scheduleFilterWrite(nextFilter, writeRequest);
} else if (handler.isHandshakeComplete()) {
// SSL encrypt
int pos = buf.position();
handler.encrypt(buf.buf());
buf.position(pos);
IoBuffer encryptedBuffer = handler.fetchOutNetBuffer();
handler.scheduleFilterWrite(nextFilter, new EncryptedWriteRequest(writeRequest, encryptedBuffer));
} else {
if (session.isConnected()) {