/** * Drains the byte buffer. By default, it decrypts the SSL data and copies as many byte as * possible to the target buffer, with no modification. */ @Override public int onDrain(Buffer buffer, int maxDrained, Object... args) throws IOException { ByteBuffer applicationBuffer = (ByteBuffer) args[0]; int initialSize = buffer.remaining(); SSLEngineResult sslResult = getConnection().getSslEngine().unwrap(buffer.getBytes(), applicationBuffer); getConnection().setSslResult(sslResult); return initialSize - buffer.remaining(); }