Allow to register ChannelFutureListener's that get notified once the inbound of the SSLEngine is closed. See #137
This commit is contained in:
parent
7d2d742a43
commit
250f1667b9
@ -43,6 +43,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.DefaultChannelFuture;
|
||||
import org.jboss.netty.channel.DownstreamMessageEvent;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
|
||||
@ -205,6 +206,8 @@ public class SslHandler extends FrameDecoder
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final SSLEngineInboundCloseFuture sslEngineCloseFuture = new SSLEngineInboundCloseFuture();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
@ -441,6 +444,20 @@ public class SslHandler extends FrameDecoder
|
||||
return issueHandshake;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link ChannelFuture} that will get notified if the inbound of the {@link SSLEngine} will get closed.
|
||||
*
|
||||
* This method will return the same {@link ChannelFuture} all the time.
|
||||
*
|
||||
* For more informations see the apidocs of {@link SSLEngine}
|
||||
*
|
||||
*/
|
||||
public ChannelFuture getSSLEngineInboundCloseFuture() {
|
||||
return sslEngineCloseFuture;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void handleDownstream(
|
||||
final ChannelHandlerContext context, final ChannelEvent evt) throws Exception {
|
||||
if (evt instanceof ChannelStateEvent) {
|
||||
@ -937,7 +954,13 @@ public class SslHandler extends FrameDecoder
|
||||
synchronized (handshakeLock) {
|
||||
result = engine.unwrap(inNetBuf, outAppBuf);
|
||||
}
|
||||
|
||||
|
||||
// notify about the CLOSED state of the SSLEngine. See #137
|
||||
if (result.getStatus() == Status.CLOSED) {
|
||||
sslEngineCloseFuture.setClosed();
|
||||
}
|
||||
|
||||
|
||||
final HandshakeStatus handshakeStatus = result.getHandshakeStatus();
|
||||
handleRenegotiation(handshakeStatus);
|
||||
switch (handshakeStatus) {
|
||||
@ -966,7 +989,7 @@ public class SslHandler extends FrameDecoder
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (needsWrap) {
|
||||
// wrap() acquires pendingUnencryptedWrites first and then
|
||||
// handshakeLock. If handshakeLock is already hold by the
|
||||
@ -1215,4 +1238,34 @@ public class SslHandler extends FrameDecoder
|
||||
}
|
||||
super.channelConnected(ctx, e);
|
||||
}
|
||||
|
||||
private final class SSLEngineInboundCloseFuture extends DefaultChannelFuture {
|
||||
public SSLEngineInboundCloseFuture() {
|
||||
super(null, true);
|
||||
}
|
||||
|
||||
void setClosed() {
|
||||
super.setSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
if (ctx == null) {
|
||||
// Maybe we should better throw an IllegalStateException() ?
|
||||
return null;
|
||||
} else {
|
||||
return ctx.getChannel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSuccess() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFailure(Throwable cause) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user