@Override
public void channelBound(final ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
// create the imap session and store it in the IoSession for later usage
ImapSessionImpl imapsession = new ImapSessionImpl() {
@Override
public boolean startTLS() {
if (supportStartTLS() == false) return false;
// enable buffering of the stream
((StartTLSOutputStream)getAttachment(ctx).get(BUFFERED_OUT)).bufferTillCRLF();
SslHandler filter = new SslHandler(engine, true);
filter.getEngine().setUseClientMode(false);
ctx.getPipeline().addFirst("sslHandler", filter);
return true;
}
@Override
public boolean supportStartTLS() {
return engine != null;
}
};
imapsession.setLog(logger);
getAttachment(ctx).put(IMAP_SESSION, imapsession);
super.channelBound(ctx, e);
}