org.tinyradius.attribute
Class VendorSpecificAttribute

java.lang.Object
  extended by org.tinyradius.attribute.RadiusAttribute
      extended by org.tinyradius.attribute.VendorSpecificAttribute

public class VendorSpecificAttribute
extends RadiusAttribute

This class represents a "Vendor-Specific" attribute.


Field Summary
static int VENDOR_SPECIFIC
          Radius attribute type code for Vendor-Specific
 
Constructor Summary
VendorSpecificAttribute()
          Constructs an empty Vendor-Specific attribute that can be read from a Radius packet.
VendorSpecificAttribute(int vendorId)
          Constructs a new Vendor-Specific attribute to be sent.
 
Method Summary
 void addSubAttribute(RadiusAttribute attribute)
          Adds a sub-attribute to this attribute.
 void addSubAttribute(java.lang.String name, java.lang.String value)
          Adds a sub-attribute with the specified name to this attribute.
 int getChildVendorId()
          Returns the vendor ID of the sub-attributes.
 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 getSubAttributes()
          Returns the list of sub-attributes.
 java.util.List getSubAttributes(int attributeType)
          Returns all sub-attributes of this attribut which have the given type.
 java.lang.String getSubAttributeValue(java.lang.String type)
          Returns the value of the Radius attribute of the given type or null if there is no such attribute.
 void readAttribute(byte[] data, int offset, int length)
          Reads a Vendor-Specific attribute and decodes the internal sub-attribute structure.
 void removeSubAttribute(RadiusAttribute attribute)
          Removes the specified sub-attribute from this attribute.
 void setChildVendorId(int childVendorId)
          Sets the vendor ID of the child attributes.
 void setDictionary(Dictionary dictionary)
          Also copies the new dictionary to sub-attributes.
 java.lang.String toString()
          Returns a string representation for debugging.
 byte[] writeAttribute()
          Renders this attribute as a byte array.
 
Methods inherited from class org.tinyradius.attribute.RadiusAttribute
createRadiusAttribute, createRadiusAttribute, createRadiusAttribute, getAttributeData, getAttributeType, getAttributeTypeObject, getAttributeValue, getDictionary, getVendorId, setAttributeData, setAttributeType, setAttributeValue, setVendorId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VENDOR_SPECIFIC

public static final int VENDOR_SPECIFIC
Radius attribute type code for Vendor-Specific

See Also:
Constant Field Values
Constructor Detail

VendorSpecificAttribute

public VendorSpecificAttribute()
Constructs an empty Vendor-Specific attribute that can be read from a Radius packet.


VendorSpecificAttribute

public VendorSpecificAttribute(int vendorId)
Constructs a new Vendor-Specific attribute to be sent.

Parameters:
vendorId - vendor ID of the sub-attributes
Method Detail

setChildVendorId

public void setChildVendorId(int childVendorId)
Sets the vendor ID of the child attributes.

Parameters:
childVendorId -

getChildVendorId

public int getChildVendorId()
Returns the vendor ID of the sub-attributes.

Returns:
vendor ID of sub attributes

setDictionary

public void setDictionary(Dictionary dictionary)
Also copies the new dictionary to sub-attributes.

Overrides:
setDictionary in class RadiusAttribute
Parameters:
dictionary - dictionary to set
See Also:
RadiusAttribute.setDictionary(org.tinyradius.dictionary.Dictionary)

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-attribute
value - 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 getSubAttributes()
Returns the list of sub-attributes.

Returns:
List of RadiusAttribute objects

getSubAttributes

public java.util.List getSubAttributes(int attributeType)
Returns all sub-attributes of this attribut 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 occurences of the requested sub-attribute type

getSubAttribute

public RadiusAttribute getSubAttribute(java.lang.String type)
                                throws RadiusException
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
RadiusException

getSubAttributeValue

public java.lang.String getSubAttributeValue(java.lang.String type)
                                      throws RadiusException
Returns the value of the Radius attribute of the given type or null if there is no such attribute.

Parameters:
type - attribute type name
Returns:
value of the attribute as a string or null if there is no such attribute
Throws:
java.lang.IllegalArgumentException - if the type name is unknown
java.lang.RuntimeException - attribute occurs multiple times
RadiusException

writeAttribute

public byte[] writeAttribute()
Renders this attribute as a byte array.

Overrides:
writeAttribute in class RadiusAttribute
Returns:
attribute
See Also:
RadiusAttribute.writeAttribute()

readAttribute

public void readAttribute(byte[] data,
                          int offset,
                          int length)
                   throws RadiusException
Reads a Vendor-Specific attribute and decodes the internal sub-attribute structure.

Overrides:
readAttribute in class RadiusAttribute
Throws:
RadiusException
See Also:
RadiusAttribute.readAttribute(byte[], int, int)

toString

public java.lang.String toString()
Returns a string representation for debugging.

Overrides:
toString in class RadiusAttribute
See Also:
RadiusAttribute.toString()