RADIUS Client API (V3)

com.theorem.radius3
Class AttributeName

Object
  extended byAttributeName
All Implemented Interfaces:
Serializable

public final class AttributeName
extends Object
implements Serializable

Class to find attribute names from field names in classes. This is used to display attribute names in dumping attribute names and values, in particular within Attribute.toString() and VendorSpecific.toString(), and implicitly in AttributeList.toString().

See Also:
Serialized Form

Field Summary
static int UNKNOWN_VENDOR
          Return value from AttributeName#getVendor() if no vendor name can be found - -1.
 
Constructor Summary
AttributeName()
          Default constructor.
 
Method Summary
static void add(String className, int vendorId)
          Add a class name to the class search list as a Vendor-Specific Attributes (VSA's).
static void addDictionary(RADIUSDictionary dict)
          Add a dictionary.
static String getVendor(int vendorId)
          Get the vendor name from the Vendor ID.
static int getVendor(String name)
          Extract the vendor Id given the name.
static String lookup(int type)
          Lookup the field name from an attribute type.
static String lookup(int vendorId, int type)
          Lookup the field name from a Vendor-Specific attribute type.
static int lookup(int vendorId, String attributeName)
          Lookup the tag number from an attribute name.
static int lookup(String attributeName)
          Lookup the tag number from an attribute name.
static void main(String[] args)
          Small test looking up attributes.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_VENDOR

public static final int UNKNOWN_VENDOR
Return value from AttributeName#getVendor() if no vendor name can be found - -1.

See Also:
Constant Field Values
Constructor Detail

AttributeName

public AttributeName()
Default constructor.

Method Detail

main

public static void main(String[] args)
Small test looking up attributes. This takes no arguments.


add

public static void add(String className,
                       int vendorId)
Add a class name to the class search list as a Vendor-Specific Attributes (VSA's). The format to use is the same as in the Cisco.java and Microsoft.java files. The vendorId field must exist in the class..

Parameters:
className - Fully qualified class name.
vendorId - Vendor ID for VSA's, 0 for Attributes types.

This should be executed before using the .toString() methods in AttributeList, Attribute, or VendorSpecific.

 new AttributeName().add("com.myco.MyVendor", com.myco.MyVendor.vendorId);

addDictionary

public static void addDictionary(RADIUSDictionary dict)
Add a dictionary. Adding a dictionary to AttributeName also adds it to the AV class.

Parameters:
dict - Dictionary.

getVendor

public static String getVendor(int vendorId)
Get the vendor name from the Vendor ID.

Parameters:
vendorId - Vendor ID.
Returns:
Name of vendor or null if unknown.

getVendor

public static int getVendor(String name)
Extract the vendor Id given the name.

Parameters:
name - Vendor name.
Returns:
the VendorId of the vendor or UNKNOWN_VENDOR if a vendor cannot be found.

lookup

public static String lookup(int type)
Lookup the field name from an attribute type.

Parameters:
type - Attribute type.
Returns:
Attribute name, or 'Unknown-[type]' if not found, e.g. 'Unknown-0'.

lookup

public static String lookup(int vendorId,
                            int type)
Lookup the field name from a Vendor-Specific attribute type.

A vendorId value of 0 performs a look up on the basic RADIUS attributes. E.g. lookup(0, 2) yields "User-Password" and lookup(Microsoft.VENDORID, 2) returns "MS-CHAP-Error".

Parameters:
vendorId - Vendor ID.
type - Attribute type, like Attribute.User-Name.
Returns:
Attribute name, or 'Unknown-[type]' if not found, e.g. 'Unknown-0'.

lookup

public static int lookup(int vendorId,
                         String attributeName)
Lookup the tag number from an attribute name.

A vendorId value of 0 performs a look up on the basic RADIUS attributes. E.g. lookup(0, "User-Password") yields 2 and lookup(Microsoft.VENDORID, "MS-CHAP-Error") returns 2.

Parameters:
vendorId - Vendor number.
attributeName - Attribute name.
Returns:
Attribute tag value or 0 if not found.

lookup

public static int lookup(String attributeName)
Lookup the tag number from an attribute name.

Parameters:
attributeName - Attribute name.
Returns:
Attribute tag value or 0 if not found.

RADIUS Client API (V3)

Submit a bug report or feature request

Copyright 1998-2008 AXL Software. PO Box 97, Viola, Delaware 19979, U.S.A. All Rights Reserved.