Class AbstractArmHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<ArmHeader,io.netty.buffer.ByteBuf>
org.drasyl.node.handler.crypto.AbstractArmHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler
Direct Known Subclasses:
LongTimeArmHandler, PFSArmHandler

@UnstableApi public abstract class AbstractArmHandler extends io.netty.handler.codec.MessageToMessageCodec<ArmHeader,io.netty.buffer.ByteBuf>
Skeleton handler that arms (encrypt) outbound and disarms (decrypt) inbound messages. Messages that could not be (dis-)armed are dropped.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Crypto
     
    protected final IdentityPublicKey
     
    protected final Session
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractArmHandler(Crypto crypto, Duration expireAfter, int maxAgreements, Identity identity, IdentityPublicKey peerIdentity)
     
    protected
    AbstractArmHandler(Crypto crypto, IdentityPublicKey peerIdentity, Session session)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected ArmHeader
    arm(io.netty.channel.ChannelHandlerContext ctx, Agreement agreement, io.netty.buffer.ByteBuf msg)
     
    protected void
    decode(io.netty.channel.ChannelHandlerContext ctx, ArmHeader msg, List<Object> out)
     
    protected void
    encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, List<Object> out)
     
    protected abstract Agreement
     
    protected abstract void
    inboundArmMessage(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     
    protected abstract void
    onNonAgreement(io.netty.channel.ChannelHandlerContext ctx)
     
    protected abstract void
    removeStaleAgreement(io.netty.channel.ChannelHandlerContext ctx, Agreement agreement)
     
    protected Object
    unarm(io.netty.channel.ChannelHandlerContext ctx, Agreement agreement, Nonce nonce, io.netty.buffer.ByteBuf byteBuf)
     

    Methods inherited from class io.netty.handler.codec.MessageToMessageCodec

    acceptInboundMessage, acceptOutboundMessage, channelRead, write

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Field Details

  • Constructor Details

  • Method Details

    • encode

      protected void encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, List<Object> out) throws Exception
      Specified by:
      encode in class io.netty.handler.codec.MessageToMessageCodec<ArmHeader,io.netty.buffer.ByteBuf>
      Throws:
      Exception
    • decode

      protected void decode(io.netty.channel.ChannelHandlerContext ctx, ArmHeader msg, List<Object> out) throws Exception
      Specified by:
      decode in class io.netty.handler.codec.MessageToMessageCodec<ArmHeader,io.netty.buffer.ByteBuf>
      Throws:
      Exception
    • inboundArmMessage

      protected abstract void inboundArmMessage(io.netty.channel.ChannelHandlerContext ctx, Object msg)
    • onNonAgreement

      protected abstract void onNonAgreement(io.netty.channel.ChannelHandlerContext ctx)
    • unarm

      protected Object unarm(io.netty.channel.ChannelHandlerContext ctx, Agreement agreement, Nonce nonce, io.netty.buffer.ByteBuf byteBuf) throws CryptoException
      Throws:
      CryptoException
    • arm

      protected ArmHeader arm(io.netty.channel.ChannelHandlerContext ctx, Agreement agreement, io.netty.buffer.ByteBuf msg) throws CryptoException
      Throws:
      CryptoException
    • removeStaleAgreement

      protected abstract void removeStaleAgreement(io.netty.channel.ChannelHandlerContext ctx, Agreement agreement)
    • getAgreement

      protected abstract Agreement getAgreement(AgreementId agreementId)