net.jradius.packet.attribute
Class AttributeFactory

java.lang.Object
  extended by net.jradius.packet.attribute.AttributeFactory

public final class AttributeFactory
extends Object

The Attribute Factor. This factor builds the RADIUS attributes based on configured dictionaries.

Author:
David Bird

Nested Class Summary
static class AttributeFactory.VendorValue
           
 
Constructor Summary
AttributeFactory()
           
 
Method Summary
static int addToAttributeList(AttributeList list, long type, byte[] value)
           
static byte[] assembleAttributeList(AttributeList list, long type)
           
static RadiusAttribute attributeFromString(String src)
          Parses a string to create a RadiusAttribute.
static RadiusAttribute borrow(Long key)
           
static RadiusAttribute copyAttribute(RadiusAttribute a)
           
static LinkedHashMap<Long,Class<?>> getAttributeMap()
           
static LinkedHashMap<String,Class<?>> getAttributeNameMap()
           
static String getPoolStatus()
           
static long getTypeByName(String aName)
          The the integer type of a RadiusAttribute by name
static LinkedHashMap<Long,Class<?>> getVendorMap()
           
static LinkedHashMap<Long,AttributeFactory.VendorValue> getVendorValueMap()
           
static boolean loadAttributeDictionary(AttributeDictionary dict)
           
static boolean loadAttributeDictionary(String className)
          Load an attribute dictionary
static void loadAttributesFromString(AttributeList list, String src, String delim, boolean beStrinct)
           
static RadiusAttribute newAttribute(AttributeDescription desc)
          Create a new RadiusAttribute based on a AttributeDescription
static RadiusAttribute newAttribute(Long key)
           
static RadiusAttribute newAttribute(long type, byte[] value)
          Creates a new RadiusAttribute
static RadiusAttribute newAttribute(long vendor, long type, byte[] value, int op)
          Creates a new RadiusAttribute
static RadiusAttribute newAttribute(long vendor, long type, long len, int op, ByteBuffer buffer)
           
static RadiusAttribute newAttribute(Long key, Serializable value)
           
static RadiusAttribute newAttribute(String aName)
          Create a RadiusAttribute by name
static RadiusAttribute newAttribute(String aName, String aValue, String aOp)
          Creates a new RadiusAttribute
static AttributeList newAttributeList(long type, byte[] value)
           
static void poolStatus()
           
static void recycle(AttributeList list)
           
static void recycle(RadiusAttribute a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeFactory

public AttributeFactory()
Method Detail

newAttribute

public static RadiusAttribute newAttribute(Long key)
                                    throws Exception
Throws:
Exception

newAttribute

public static RadiusAttribute newAttribute(Long key,
                                           Serializable value)

copyAttribute

public static RadiusAttribute copyAttribute(RadiusAttribute a)

borrow

public static RadiusAttribute borrow(Long key)
                              throws NoSuchElementException,
                                     IllegalStateException,
                                     Exception
Throws:
NoSuchElementException
IllegalStateException
Exception

loadAttributeDictionary

public static boolean loadAttributeDictionary(String className)
Load an attribute dictionary

Parameters:
className - Name of the Java Class derived from AttributeDictionary
Returns:
Returns true if loading of dictionary was successful

loadAttributeDictionary

public static boolean loadAttributeDictionary(AttributeDictionary dict)

attributeFromString

public static RadiusAttribute attributeFromString(String src)
                                           throws RadiusException,
                                                  UnknownAttributeException
Parses a string to create a RadiusAttribute. Will either return the attribute, or throw an Exception.

Parameters:
src - The source String
Returns:
Returns the RadiusAttribute parsed from String
Throws:
RadiusException
UnknownAttributeException

loadAttributesFromString

public static void loadAttributesFromString(AttributeList list,
                                            String src,
                                            String delim,
                                            boolean beStrinct)
                                     throws RadiusException
Throws:
RadiusException

newAttribute

public static RadiusAttribute newAttribute(long vendor,
                                           long type,
                                           byte[] value,
                                           int op)
Creates a new RadiusAttribute

Parameters:
vendor - The VendorID of the attribute (if one)
type - The Attribute Type
value - The Attribute Value
op - The Attribute Operator
Returns:
Returns the newly created RadiusAttribute

newAttribute

public static RadiusAttribute newAttribute(long vendor,
                                           long type,
                                           long len,
                                           int op,
                                           ByteBuffer buffer)

newAttribute

public static RadiusAttribute newAttribute(long type,
                                           byte[] value)
Creates a new RadiusAttribute

Parameters:
type - The type of the attribute
value - The value of the attribute
Returns:
Returns the newly created RadiusAttribute

newAttributeList

public static AttributeList newAttributeList(long type,
                                             byte[] value)
Parameters:
type - The type of the attribute
value - The value of the attribute
Returns:
Returns the newly created AttributeList

addToAttributeList

public static int addToAttributeList(AttributeList list,
                                     long type,
                                     byte[] value)
Parameters:
list - The AttributeList to add to
type - The type of the attribute
value - The value of the attribute
Returns:
Returns how many attributes created

assembleAttributeList

public static byte[] assembleAttributeList(AttributeList list,
                                           long type)

newAttribute

public static RadiusAttribute newAttribute(String aName)
                                    throws UnknownAttributeException
Create a RadiusAttribute by name

Parameters:
aName - The name of the attribute to create
Returns:
Returns the newly created RadiusAttribute
Throws:
UnknownAttributeException

newAttribute

public static RadiusAttribute newAttribute(AttributeDescription desc)
                                    throws UnknownAttributeException
Create a new RadiusAttribute based on a AttributeDescription

Parameters:
desc - The RadiusDescription
Returns:
Returns the newly created RadiusAttribute
Throws:
UnknownAttributeException

newAttribute

public static RadiusAttribute newAttribute(String aName,
                                           String aValue,
                                           String aOp)
                                    throws UnknownAttributeException
Creates a new RadiusAttribute

Parameters:
aName - The name of the attribute to create
aValue - The value of the attribute
aOp - The "operator" of the attribute
Returns:
Returns the newly created RadiusAttribute
Throws:
UnknownAttributeException

getTypeByName

public static long getTypeByName(String aName)
                          throws UnknownAttributeException
The the integer type of a RadiusAttribute by name

Parameters:
aName - The name of the attribute
Returns:
Returns the integer type of the attribute
Throws:
UnknownAttributeException

getAttributeMap

public static LinkedHashMap<Long,Class<?>> getAttributeMap()
Returns:
Returns the attributeMap.

getAttributeNameMap

public static LinkedHashMap<String,Class<?>> getAttributeNameMap()
Returns:
Returns the attributeNameMap.

getVendorMap

public static LinkedHashMap<Long,Class<?>> getVendorMap()
Returns:
Returns the vendorMap.

getVendorValueMap

public static LinkedHashMap<Long,AttributeFactory.VendorValue> getVendorValueMap()
Returns:
Returns the vendorValueMap.

poolStatus

public static void poolStatus()

getPoolStatus

public static String getPoolStatus()

recycle

public static void recycle(RadiusAttribute a)

recycle

public static void recycle(AttributeList list)


Copyright © 2011 Coova Technologies, LLC, All Rights Reserved.