Package org.tinyradius.attribute
Class VendorSpecificAttribute
- java.lang.Object
-
- org.tinyradius.attribute.RadiusAttribute
-
- org.tinyradius.attribute.VendorSpecificAttribute
-
public class VendorSpecificAttribute extends RadiusAttribute
This class represents a "Vendor-Specific" attribute.
-
-
Field Summary
Fields Modifier and Type Field Description static int
VENDOR_SPECIFIC
-
Constructor Summary
Constructors Constructor Description VendorSpecificAttribute(Dictionary dictionary, int vendorId)
Constructs a new Vendor-Specific attribute to be sent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubAttribute(java.lang.String name, java.lang.String value)
Adds a sub-attribute with the specified name to this attribute.void
addSubAttribute(RadiusAttribute attribute)
Adds a sub-attribute to this attribute.RadiusAttribute
getSubAttribute(int type)
Returns a sub-attribute of the given type which may only occur once in this attribute.RadiusAttribute
getSubAttribute(java.lang.String type)
Returns a single sub-attribute of the given type name.java.util.List<RadiusAttribute>
getSubAttributes()
Returns the list of sub-attributes.java.util.List<RadiusAttribute>
getSubAttributes(int attributeType)
Returns all sub-attributes of this attribute which have the given type.void
removeSubAttribute(RadiusAttribute attribute)
Removes the specified sub-attribute from this attribute.java.util.Map<java.lang.String,java.lang.String>
toAttributeMap()
Returns set of entry of Attribute name and Value as string.byte[]
toByteArray()
Renders this attribute as a byte array.java.lang.String
toString()
Returns a string representation for debugging.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from class org.tinyradius.attribute.RadiusAttribute
equals, getAttributeKey, getAttributeType, getDictionary, getType, getValue, getValueString, getVendorId, hashCode
-
-
-
-
Field Detail
-
VENDOR_SPECIFIC
public static final int VENDOR_SPECIFIC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VendorSpecificAttribute
public VendorSpecificAttribute(Dictionary dictionary, int vendorId)
Constructs a new Vendor-Specific attribute to be sent.- Parameters:
dictionary
- dictionary to use for (sub)attributesvendorId
- vendor ID of the sub-attributes
-
-
Method Detail
-
addSubAttribute
public void addSubAttribute(RadiusAttribute attribute)
Adds a sub-attribute to this attribute.- Parameters:
attribute
- sub-attribute to add
-
addSubAttribute
public void addSubAttribute(java.lang.String name, java.lang.String value)
Adds a sub-attribute with the specified name to this attribute.- Parameters:
name
- name of the sub-attributevalue
- value of the sub-attribute- Throws:
java.lang.IllegalArgumentException
- invalid sub-attribute name or value
-
removeSubAttribute
public void removeSubAttribute(RadiusAttribute attribute)
Removes the specified sub-attribute from this attribute.- Parameters:
attribute
- RadiusAttribute to remove
-
getSubAttributes
public java.util.List<RadiusAttribute> getSubAttributes()
Returns the list of sub-attributes.- Returns:
- List of RadiusAttribute objects
-
getSubAttributes
public java.util.List<RadiusAttribute> getSubAttributes(int attributeType)
Returns all sub-attributes of this attribute which have the given type.- Parameters:
attributeType
- type of sub-attributes to get- Returns:
- list of RadiusAttribute objects, does not return null
-
getSubAttribute
public RadiusAttribute getSubAttribute(int type)
Returns a sub-attribute of the given type which may only occur once in this attribute.- Parameters:
type
- sub-attribute type- Returns:
- RadiusAttribute object or null if there is no such sub-attribute
- Throws:
java.lang.RuntimeException
- if there are multiple occurrences of the requested sub-attribute type
-
getSubAttribute
public RadiusAttribute getSubAttribute(java.lang.String type)
Returns a single sub-attribute of the given type name.- Parameters:
type
- attribute type name- Returns:
- RadiusAttribute object or null if there is no such attribute
- Throws:
java.lang.RuntimeException
- if the attribute occurs multiple times
-
toByteArray
public byte[] toByteArray()
Renders this attribute as a byte array.- Overrides:
toByteArray
in classRadiusAttribute
- Returns:
- entire attribute (including headers) as byte array
-
toString
public java.lang.String toString()
Returns a string representation for debugging.- Overrides:
toString
in classRadiusAttribute
-
toAttributeMap
public java.util.Map<java.lang.String,java.lang.String> toAttributeMap()
Description copied from class:RadiusAttribute
Returns set of entry of Attribute name and Value as string. Size is generally 1, except in case of VendorSpecificAttribute where it is aggregate of sub-attributes.- Overrides:
toAttributeMap
in classRadiusAttribute
- Returns:
- Set of String/String Entry
-
-