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

  • Method Details

    • attributesToBytes

      static byte[] attributesToBytes​(java.util.List<RadiusAttribute> attributes)
    • extractAttributes

      static java.util.List<RadiusAttribute> extractAttributes​(Dictionary dictionary, int vendorId, byte[] data, int pos)
      Parameters:
      dictionary - dictionary to parse attribute
      vendorId - vendor Id to set attributes
      data - byte array to parse
      pos - position in byte array at which to parse
      Returns:
      list of RadiusAttributes
    • getChildVendorId

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

      Dictionary getDictionary()
    • getAttributes

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

      default java.util.Optional<RadiusAttribute> getAttribute​(java.lang.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 java.util.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
    • filterAttributes

      default java.util.List<RadiusAttribute> filterAttributes​(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
    • filterAttributes

      default java.util.List<RadiusAttribute> filterAttributes​(java.lang.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
    • filterAttributes

      default java.util.List<RadiusAttribute> filterAttributes​(java.util.function.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
    • filterAttributes

      default java.util.List<RadiusAttribute> filterAttributes​(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
    • getAttributeBytes

      default byte[] getAttributeBytes()
      Encodes the attributes of this Radius packet to a byte array.
      Returns:
      byte array with encoded attributes
    • withAttributes

      T withAttributes​(java.util.List<RadiusAttribute> attributes)
    • addAttribute

      default T addAttribute​(RadiusAttribute attribute)
      Adds a attribute to this attribute container.
      Parameters:
      attribute - attribute to add
      Returns:
      object of same type with appended attribute
    • addAttribute

      default T addAttribute​(java.lang.String name, java.lang.String value)
    • addAttribute

      default T addAttribute​(int type, java.lang.String value)
      Adds a Radius attribute.
      Parameters:
      type - attribute type code
      value - string value to set
      Returns:
      object of same type with appended attribute
    • removeAttribute

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

      default T removeAttributes​(int type)
      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
    • removeLastAttribute

      default T removeLastAttribute​(int type)
      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
    • encodeAttributes

      default java.util.List<RadiusAttribute> encodeAttributes​(byte[] requestAuth, java.lang.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 java.util.List<RadiusAttribute> decodeAttributes​(byte[] requestAuth, java.lang.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