Interface AttributeHolder<T extends AttributeHolder<T>>

All Known Subinterfaces:
MessageAuthSupport<T>, NestedAttributeHolder<T>, RadiusPacket<T>, RadiusRequest, RadiusResponse
All Known Implementing Classes:
AccessRequest, AccessRequestArap, AccessRequestChap, AccessRequestEap, AccessRequestNoAuth, AccessRequestPap, AccessResponse, AccessResponse.Accept, AccessResponse.Challenge, AccessResponse.Reject, AccountingRequest, BaseRadiusPacket, GenericRequest, GenericResponse, VendorSpecificAttribute

public interface AttributeHolder<T extends AttributeHolder<T>>
Basic attribute holder, for VendorSpecificAttribute (to hold sub-attributes) or RadiusPackets

Should only hold single layer of attributes

  • Field Details

    • attrHolderLogger

      static final org.apache.logging.log4j.Logger attrHolderLogger
  • Method Details

    • attributesToBytes

      static io.netty.buffer.ByteBuf attributesToBytes(List<RadiusAttribute> attributes)
    • readAttributes

      static List<RadiusAttribute> readAttributes(Dictionary dictionary, int vendorId, io.netty.buffer.ByteBuf data)
      Reads attributes and increments readerIndex.
      Parameters:
      dictionary - dictionary to parse attribute
      vendorId - vendor Id to set attributes
      data - byte array to parse
      Returns:
      list of RadiusAttributes
    • readAttribute

      static RadiusAttribute readAttribute(Dictionary dictionary, int vendorId, io.netty.buffer.ByteBuf data)
      Parses attribute and increases readerIndex by size of attribute.
      Parameters:
      dictionary - dictionary to parse attribute
      vendorId - vendor Id to set attributes
      data - byte array to parse
      Returns:
      list of RadiusAttributes
    • getChildVendorId

      int getChildVendorId()
      Returns:
      VendorId to restrict (sub)attributes, or -1 for top level
    • getDictionary

      Dictionary getDictionary()
    • getAttributes

      List<RadiusAttribute> getAttributes()
      Returns:
      list of RadiusAttributes
    • getAttribute

      default Optional<RadiusAttribute> getAttribute(String type)
      Convenience method to get single attribute.
      Parameters:
      type - attribute type name
      Returns:
      RadiusAttribute object or null if there is no such attribute
    • getAttribute

      default Optional<RadiusAttribute> getAttribute(int type)
      Convenience method to get single attribute.
      Parameters:
      type - attribute type
      Returns:
      RadiusAttribute object or null if there is no such attribute
    • getAttributes

      default List<RadiusAttribute> getAttributes(int type)
      Returns all attributes of the given type, regardless of vendorId
      Parameters:
      type - type of attributes to get
      Returns:
      list of RadiusAttribute objects, or empty list
    • getAttributes

      default List<RadiusAttribute> getAttributes(String name)
      Returns attributes of the given type name. Also searches sub-attributes if appropriate.
      Parameters:
      name - attribute type name
      Returns:
      list of RadiusAttribute objects, or empty list
    • getAttributes

      default List<RadiusAttribute> getAttributes(Predicate<RadiusAttribute> filter)
      Returns attributes of the given type, filtered by given predicate
      Parameters:
      filter - RadiusAttribute filter predicate
      Returns:
      list of RadiusAttribute objects, or empty list
    • getAttributes

      default List<RadiusAttribute> getAttributes(AttributeTemplate type)
      Returns attributes of the given attribute type. Also searches sub-attributes if appropriate.
      Parameters:
      type - attribute type name
      Returns:
      list of RadiusAttribute objects, or empty list
    • getAttributeByteBuf

      default io.netty.buffer.ByteBuf getAttributeByteBuf()
      Encodes the attributes of this Radius packet to a byte array.
      Returns:
      byte array with encoded attributes
    • withAttributes

      T withAttributes(List<RadiusAttribute> attributes) throws RadiusPacketException
      Throws:
      RadiusPacketException
    • addAttribute

      default T addAttribute(RadiusAttribute attribute) throws RadiusPacketException
      Adds a attribute to this attribute container.
      Parameters:
      attribute - attribute to add
      Returns:
      object of same type with appended attribute
      Throws:
      IllegalArgumentException - if the attribute's vendorId does not match AttributeHolder's childVendorId
      RadiusPacketException - packet validation exceptions
    • addAttribute

      default T addAttribute(String name, String value) throws RadiusPacketException
      Throws:
      RadiusPacketException
    • addAttribute

      default T addAttribute(int type, String value) throws RadiusPacketException
      Adds a Radius attribute.
      Parameters:
      type - attribute type code
      value - string value to set
      Returns:
      object of same type with appended attribute
      Throws:
      RadiusPacketException - packet validation exceptions
    • removeAttribute

      default T removeAttribute(RadiusAttribute attribute) throws RadiusPacketException
      Removes all instances of the specified attribute from this attribute container.
      Parameters:
      attribute - attributes to remove
      Returns:
      object of same type with removed attribute
      Throws:
      RadiusPacketException - packet validation exceptions
    • removeAttributes

      default T removeAttributes(int type) throws RadiusPacketException
      Removes all attributes from this packet which have got the specified type.
      Parameters:
      type - attribute type to remove
      Returns:
      object of same type with removed attributes
      Throws:
      RadiusPacketException - packet validation exceptions
    • removeLastAttribute

      default T removeLastAttribute(int type) throws RadiusPacketException
      Removes the last occurrence of the attribute of the given type from the packet.
      Parameters:
      type - attribute type code
      Returns:
      object of same type with removed attribute
      Throws:
      RadiusPacketException - packet validation exceptions
    • encodeAttributes

      default List<RadiusAttribute> encodeAttributes(byte[] requestAuth, String sharedSecret) throws RadiusPacketException
      Parameters:
      requestAuth - request authenticator to encode attributes
      sharedSecret - shared secret with server/client to encode attributes
      Returns:
      encoded version of attributes
      Throws:
      RadiusPacketException - errors encoding attributes
    • decodeAttributes

      default List<RadiusAttribute> decodeAttributes(byte[] requestAuth, String sharedSecret) throws RadiusPacketException
      Parameters:
      requestAuth - request authenticator to decode attributes
      sharedSecret - shared secret with server/client to decode attributes
      Returns:
      decoded/original version of attributes
      Throws:
      RadiusPacketException - errors decoding attributes