Class RadiusPacketEncoder


  • public class RadiusPacketEncoder
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static RadiusPacket createRadiusPacket​(Dictionary dictionary, int type, int identifier, byte[] authenticator, java.util.List<RadiusAttribute> attributes)
      Creates a RadiusPacket object.
      static RadiusPacket fromDatagram​(Dictionary dictionary, io.netty.channel.socket.DatagramPacket packet, java.lang.String sharedSecret)
      Reads a request from the given input stream and creates an appropriate RadiusPacket/subclass.
      static RadiusPacket fromDatagram​(Dictionary dictionary, io.netty.channel.socket.DatagramPacket datagram, java.lang.String sharedSecret, RadiusPacket request)
      Reads a response from the given input stream and creates an appropriate RadiusPacket descendant object.
      static RadiusPacket fromDatagramUnverified​(Dictionary dictionary, io.netty.channel.socket.DatagramPacket packet)
      Reads a Radius packet from the given input stream and creates an appropriate RadiusPacket/subclass.
      static int nextPacketId()
      Increment the next packet identifier.
      static io.netty.channel.socket.DatagramPacket toDatagram​(RadiusPacket packet, java.net.InetSocketAddress address)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RadiusPacketEncoder

        public RadiusPacketEncoder()
    • Method Detail

      • nextPacketId

        public static int nextPacketId()
        Increment the next packet identifier.
        Returns:
        the next packet identifier to use
      • fromDatagramUnverified

        public static RadiusPacket fromDatagramUnverified​(Dictionary dictionary,
                                                          io.netty.channel.socket.DatagramPacket packet)
                                                   throws RadiusException
        Reads a Radius packet from the given input stream and creates an appropriate RadiusPacket/subclass.

        Makes no distinction between reading requests/responses, and does not attempt to decode attributes/verify authenticators. RadiusPacket should be separately verified after this to check authenticators are valid and required attributes present.

        Typically used to decode a response where the corresponding request (specifically the authenticator/identifier) are not available.

        Parameters:
        dictionary - dictionary to use for attributes
        packet - DatagramPacket to read packet from
        Returns:
        new RadiusPacket object
        Throws:
        RadiusException - malformed packet
      • fromDatagram

        public static RadiusPacket fromDatagram​(Dictionary dictionary,
                                                io.netty.channel.socket.DatagramPacket packet,
                                                java.lang.String sharedSecret)
                                         throws RadiusException
        Reads a request from the given input stream and creates an appropriate RadiusPacket/subclass.

        Decodes the encrypted fields and attributes of the packet, and checks authenticator if appropriate.

        Parameters:
        dictionary - dictionary to use for attributes
        packet - DatagramPacket to read packet from
        sharedSecret - shared secret to be used to decode this packet
        Returns:
        new RadiusPacket object
        Throws:
        RadiusException - malformed packet
      • fromDatagram

        public static RadiusPacket fromDatagram​(Dictionary dictionary,
                                                io.netty.channel.socket.DatagramPacket datagram,
                                                java.lang.String sharedSecret,
                                                RadiusPacket request)
                                         throws RadiusException
        Reads a response from the given input stream and creates an appropriate RadiusPacket descendant object.

        Decodes the encrypted fields and attributes of the packet, and checks authenticator if appropriate.

        Parameters:
        dictionary - dictionary to use for attributes
        datagram - DatagramPacket to read packet from
        sharedSecret - shared secret to be used to decode this packet
        request - associated request packet if parsing response, or null if parsing request
        Returns:
        new RadiusPacket object
        Throws:
        RadiusException - malformed packet
      • createRadiusPacket

        public static RadiusPacket createRadiusPacket​(Dictionary dictionary,
                                                      int type,
                                                      int identifier,
                                                      byte[] authenticator,
                                                      java.util.List<RadiusAttribute> attributes)
        Creates a RadiusPacket object. Depending on the passed type, an appropriate packet is created. Also sets the type, and the the packet identifier.
        Parameters:
        type - packet type
        Returns:
        RadiusPacket object