Class SignatureHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<I>
-
- org.drasyl.peer.connection.handler.SimpleChannelDuplexHandler<Message,Message>
-
- org.drasyl.peer.connection.handler.SignatureHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
public class SignatureHandler extends SimpleChannelDuplexHandler<Message,Message>
Acts as a guard for in- and outbound messages.
Signs automatically outbound messages.
Validates automatically inbound messages and drops them, iff a signature is invalid or if a validation is impossible, e.g. the public key of the sender is unknown. In this case, drop information is written to the log.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SIGNATURE_HANDLER
-
Constructor Summary
Constructors Constructor Description SignatureHandler(int networkId, Identity identity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
channelRead0(io.netty.channel.ChannelHandlerContext ctx, Message msg)
Is called for each message of typeSimpleChannelDuplexHandler
on inbound channel.protected void
channelWrite0(io.netty.channel.ChannelHandlerContext ctx, Message msg, io.netty.channel.ChannelPromise promise)
Is called for each message of typeSimpleChannelDuplexHandler
on the outbound channel.-
Methods inherited from class org.drasyl.peer.connection.handler.SimpleChannelDuplexHandler
acceptOutboundMessage, bind, close, connect, deregister, disconnect, flush, read, write
-
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Field Detail
-
SIGNATURE_HANDLER
public static final String SIGNATURE_HANDLER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SignatureHandler
public SignatureHandler(int networkId, Identity identity)
-
-
Method Detail
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, Message msg)
Description copied from class:SimpleChannelDuplexHandler
Is called for each message of typeSimpleChannelDuplexHandler
on inbound channel.- Specified by:
channelRead0
in classSimpleChannelDuplexHandler<Message,Message>
- Parameters:
ctx
- theChannelHandlerContext
which thisSimpleChannelDuplexHandler
belongs tomsg
- the message to handle
-
channelWrite0
protected void channelWrite0(io.netty.channel.ChannelHandlerContext ctx, Message msg, io.netty.channel.ChannelPromise promise)
Description copied from class:SimpleChannelDuplexHandler
Is called for each message of typeSimpleChannelDuplexHandler
on the outbound channel.- Specified by:
channelWrite0
in classSimpleChannelDuplexHandler<Message,Message>
- Parameters:
ctx
- theChannelHandlerContext
which thisSimpleChannelDuplexHandler
belongs tomsg
- the message to handlepromise
- the corresponding promise
-
-