Package org.tinyradius.dictionary

Examples of org.tinyradius.dictionary.AttributeType


    if (typeName == null || typeName.length() == 0)
      throw new IllegalArgumentException("type name is empty");
    if (value == null || value.length() == 0)
      throw new IllegalArgumentException("value is empty");
   
    AttributeType type = dictionary.getAttributeTypeByName(typeName);
    if (type == null)
      throw new IllegalArgumentException("unknown attribute type '" + typeName + "'");

    RadiusAttribute attribute = RadiusAttribute.createRadiusAttribute(getDictionary(), type.getVendorId(), type.getTypeCode());
    attribute.setAttributeValue(value);
    addAttribute(attribute);
  }
View Full Code Here


   */
  public RadiusAttribute getAttribute(String type) {
    if (type == null || type.length() == 0)
      throw new IllegalArgumentException("type name is empty");
   
    AttributeType t = dictionary.getAttributeTypeByName(type);
    if (t == null)
      throw new IllegalArgumentException("unknown attribute type name '" + type + "'");
   
    return getAttribute(t.getVendorId(), t.getTypeCode());
  }
View Full Code Here

   * Tries to resolve enumerations.
   * @see org.tinyradius.attribute.RadiusAttribute#getAttributeValue()
   */
  public String getAttributeValue() {
    int value = getAttributeValueInt();
    AttributeType at = getAttributeTypeObject();
    if (at != null) {
      String name = at.getEnumeration(value);
      if (name != null)
        return name;
    }

    return Integer.toString(value);
View Full Code Here

   * Sets the value of this attribute.
   * @exception NumberFormatException if value is not a number and constant cannot be resolved
   * @see org.tinyradius.attribute.RadiusAttribute#setAttributeValue(java.lang.String)
   */
  public void setAttributeValue(String value) {
    AttributeType at = getAttributeTypeObject();
    if (at != null) {
      Integer val = at.getEnumeration(value);
      if (val != null) {
        setAttributeValue(val.intValue());
        return;
      }
    }
View Full Code Here

   */
  public String toString() {
    String name;
   
    // determine attribute name
    AttributeType at = getAttributeTypeObject();
    if (at != null)
      name = at.getName();
    else if (getVendorId() != -1)
      name = "Unknown-Sub-Attribute-" + getAttributeType();
    else
      name = "Unknown-Attribute-" + getAttributeType();
   
View Full Code Here

   * @return RadiusAttribute object
   */
  public static RadiusAttribute createRadiusAttribute(Dictionary dictionary, int vendorId, int attributeType) {
    RadiusAttribute attribute = new RadiusAttribute();
   
    AttributeType at = dictionary.getAttributeTypeByCode(vendorId, attributeType);
    if (at != null && at.getAttributeClass() != null) {
      try {
        attribute = (RadiusAttribute)at.getAttributeClass().newInstance();
      } catch (Exception e) {
        // error instantiating class - should not occur
      }
    }
   
View Full Code Here

    if (name == null || name.length() == 0)
      throw new IllegalArgumentException("type name is empty");
    if (value == null || value.length() == 0)
      throw new IllegalArgumentException("value is empty");

    AttributeType type = getDictionary().getAttributeTypeByName(name);
    if (type == null)
      throw new IllegalArgumentException("unknown attribute type '"
          + name + "'");
    if (type.getVendorId() == -1)
      throw new IllegalArgumentException("attribute type '" + name
          + "' is not a Vendor-Specific sub-attribute");
    if (type.getVendorId() != getChildVendorId())
      throw new IllegalArgumentException("attribute type '" + name
          + "' does not belong to vendor ID " + getChildVendorId());

    RadiusAttribute attribute = createRadiusAttribute(getDictionary(),
        getChildVendorId(), type.getTypeCode());
    attribute.setAttributeValue(value);
    addSubAttribute(attribute);
  }
View Full Code Here

   */
  public RadiusAttribute getSubAttribute(String type) throws RadiusException {
    if (type == null || type.length() == 0)
      throw new IllegalArgumentException("type name is empty");

    AttributeType t = getDictionary().getAttributeTypeByName(type);
    if (t == null)
      throw new IllegalArgumentException("unknown attribute type name '"
          + type + "'");
    if (t.getVendorId() != getChildVendorId())
      throw new IllegalArgumentException("vendor ID mismatch");

    return getSubAttribute(t.getTypeCode());
  }
View Full Code Here

TOP

Related Classes of org.tinyradius.dictionary.AttributeType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.