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
-
Method Summary
Modifier and Type Method Description default T
addAttribute(int type, java.lang.String value)
Adds a Radius attribute.default T
addAttribute(java.lang.String name, java.lang.String value)
default T
addAttribute(RadiusAttribute attribute)
Adds a attribute to this attribute container.static byte[]
attributesToBytes(java.util.List<RadiusAttribute> attributes)
default java.util.List<RadiusAttribute>
decodeAttributes(byte[] requestAuth, java.lang.String sharedSecret)
default java.util.List<RadiusAttribute>
encodeAttributes(byte[] requestAuth, java.lang.String sharedSecret)
static java.util.List<RadiusAttribute>
extractAttributes(Dictionary dictionary, int vendorId, byte[] data, int pos)
default java.util.List<RadiusAttribute>
filterAttributes(int type)
Returns all attributes of the given type, regardless of vendorIddefault java.util.List<RadiusAttribute>
filterAttributes(java.lang.String name)
Returns attributes of the given type name.default java.util.List<RadiusAttribute>
filterAttributes(java.util.function.Predicate<RadiusAttribute> filter)
Returns attributes of the given type, filtered by given predicatedefault java.util.List<RadiusAttribute>
filterAttributes(AttributeTemplate type)
Returns attributes of the given attribute type.default java.util.Optional<RadiusAttribute>
getAttribute(int type)
Convenience method to get single attribute.default java.util.Optional<RadiusAttribute>
getAttribute(java.lang.String type)
Convenience method to get single attribute.default byte[]
getAttributeBytes()
Encodes the attributes of this Radius packet to a byte array.java.util.List<RadiusAttribute>
getAttributes()
int
getChildVendorId()
Dictionary
getDictionary()
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.T
withAttributes(java.util.List<RadiusAttribute> attributes)
-
Method Details
-
attributesToBytes
-
extractAttributes
static java.util.List<RadiusAttribute> extractAttributes(Dictionary dictionary, int vendorId, byte[] data, int pos)- Parameters:
dictionary
- dictionary to parse attributevendorId
- vendor Id to set attributesdata
- byte array to parsepos
- 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
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
-
filterAttributes
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
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
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
-
addAttribute
Adds a attribute to this attribute container.- Parameters:
attribute
- attribute to add- Returns:
- object of same type with appended attribute
-
addAttribute
-
addAttribute
Adds a Radius attribute.- Parameters:
type
- attribute type codevalue
- string value to set- Returns:
- object of same type with appended attribute
-
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
-
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
-
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
-
encodeAttributes
default java.util.List<RadiusAttribute> encodeAttributes(byte[] requestAuth, java.lang.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 java.util.List<RadiusAttribute> decodeAttributes(byte[] requestAuth, java.lang.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
-