Package org.tinyradius.core.attribute
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault T
addAttribute
(int type, String value) Adds a Radius attribute.default T
addAttribute
(String name, String value) default T
addAttribute
(RadiusAttribute attribute) Adds a attribute to this attribute container.static io.netty.buffer.ByteBuf
attributesToBytes
(List<RadiusAttribute> attributes) default List<RadiusAttribute>
decodeAttributes
(byte[] requestAuth, String sharedSecret) default List<RadiusAttribute>
encodeAttributes
(byte[] requestAuth, String sharedSecret) default Optional<RadiusAttribute>
getAttribute
(int type) Convenience method to get single attribute.default Optional<RadiusAttribute>
getAttribute
(String type) Convenience method to get single attribute.default io.netty.buffer.ByteBuf
Encodes the attributes of this Radius packet to a byte array.default List<RadiusAttribute>
getAttributes
(int type) Returns all attributes of the given type, regardless of vendorIddefault List<RadiusAttribute>
getAttributes
(String name) Returns attributes of the given type name.default List<RadiusAttribute>
getAttributes
(Predicate<RadiusAttribute> filter) Returns attributes of the given type, filtered by given predicatedefault List<RadiusAttribute>
Returns attributes of the given attribute type.int
static RadiusAttribute
readAttribute
(Dictionary dictionary, int vendorId, io.netty.buffer.ByteBuf data) Parses attribute and increases readerIndex by size of attribute.static List<RadiusAttribute>
readAttributes
(Dictionary dictionary, int vendorId, io.netty.buffer.ByteBuf data) Reads attributes and increments readerIndex.default T
removeAttribute
(RadiusAttribute attribute) Removes all instances of the specified attribute from this attribute container.default T
removeAttributes
(int type) Removes all attributes from this packet which have got the specified type.default T
removeLastAttribute
(int type) Removes the last occurrence of the attribute of the given type from the packet.withAttributes
(List<RadiusAttribute> attributes)
-
Field Details
-
attrHolderLogger
static final org.apache.logging.log4j.Logger attrHolderLogger
-
-
Method Details
-
attributesToBytes
-
readAttributes
static List<RadiusAttribute> readAttributes(Dictionary dictionary, int vendorId, io.netty.buffer.ByteBuf data) Reads attributes and increments readerIndex.- Parameters:
dictionary
- dictionary to parse attributevendorId
- vendor Id to set attributesdata
- 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 attributevendorId
- vendor Id to set attributesdata
- 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
Convenience method to get single attribute.- Parameters:
type
- attribute type name- Returns:
- RadiusAttribute object or null if there is no such attribute
-
getAttribute
Convenience method to get single attribute.- Parameters:
type
- attribute type- Returns:
- RadiusAttribute object or null if there is no such attribute
-
getAttributes
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
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
Returns attributes of the given type, filtered by given predicate- Parameters:
filter
- RadiusAttribute filter predicate- Returns:
- list of RadiusAttribute objects, or empty list
-
getAttributes
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
- Throws:
RadiusPacketException
-
addAttribute
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 childVendorIdRadiusPacketException
- packet validation exceptions
-
addAttribute
- Throws:
RadiusPacketException
-
addAttribute
Adds a Radius attribute.- Parameters:
type
- attribute type codevalue
- string value to set- Returns:
- object of same type with appended attribute
- Throws:
RadiusPacketException
- packet validation exceptions
-
removeAttribute
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
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
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 attributessharedSecret
- 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 attributessharedSecret
- shared secret with server/client to decode attributes- Returns:
- decoded/original version of attributes
- Throws:
RadiusPacketException
- errors decoding attributes
-