Package org.tinyradius.client.handler
Class SimpleClientHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<io.netty.channel.socket.DatagramPacket>
-
- org.tinyradius.client.handler.ClientHandler
-
- org.tinyradius.client.handler.SimpleClientHandler
-
public class SimpleClientHandler extends ClientHandler
ClientHandler that uses packetIdentifier and remote address to uniquely identify request/responses.Note that packetIdentifier is limited to 1 byte, i.e. only 256 unique IDs. A large number of requests in short period of time may cause requests/responses to be mismatched.
When response is received, it also verifies against the authenticator of the original request to decode.
-
-
Constructor Summary
Constructors Constructor Description SimpleClientHandler(PacketEncoder packetEncoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
handleResponse(io.netty.channel.socket.DatagramPacket packet)
Processes DatagramPacket.io.netty.channel.socket.DatagramPacket
prepareDatagram(RadiusPacket original, RadiusEndpoint endpoint, java.net.InetSocketAddress sender, io.netty.util.concurrent.Promise<RadiusPacket> promise)
Preprocess RadiusPackets before they are sent.-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class org.tinyradius.client.handler.ClientHandler
channelRead0
-
-
-
-
Constructor Detail
-
SimpleClientHandler
public SimpleClientHandler(PacketEncoder packetEncoder)
- Parameters:
packetEncoder
- to convert between datagram and packet
-
-
Method Detail
-
prepareDatagram
public io.netty.channel.socket.DatagramPacket prepareDatagram(RadiusPacket original, RadiusEndpoint endpoint, java.net.InetSocketAddress sender, io.netty.util.concurrent.Promise<RadiusPacket> promise) throws RadiusException
Description copied from class:ClientHandler
Preprocess RadiusPackets before they are sent. May mutate outbound packets.Save state info about outgoing requests so handler has context when handling replies
Ensure that you also return the encoded packet, typically with the shared secret available in RadiusEndpoint.
- Specified by:
prepareDatagram
in classClientHandler
- Parameters:
original
- request to sendendpoint
- packet endpointsender
- source socket for datagrampromise
- promise placeholder that represents overarching request (including retries)- Returns:
- promise of response which completes when server responds. Uses Promise instead Future, to allow requests to be timed out or cancelled by the caller
- Throws:
RadiusException
- if packet could not be encoded/serialized to datagram
-
handleResponse
protected void handleResponse(io.netty.channel.socket.DatagramPacket packet) throws RadiusException
Description copied from class:ClientHandler
Processes DatagramPacket. This does not swallow exceptions.- Specified by:
handleResponse
in classClientHandler
- Parameters:
packet
- datagram received- Throws:
RadiusException
- malformed packet
-
-