亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? vendorspecificattribute.java

?? TinyRadius is a simple, small and fast Java Radius library capable of sending and receiving Radius
?? JAVA
字號:
/**
 * $Id: VendorSpecificAttribute.java,v 1.7 2005/11/22 10:18:38 wuttke Exp $
 * Created on 10.04.2005
 * @author Matthias Wuttke
 * @version $Revision: 1.7 $
 */
package org.tinyradius.attribute;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.tinyradius.dictionary.AttributeType;
import org.tinyradius.dictionary.Dictionary;
import org.tinyradius.util.RadiusException;

/**
 * This class represents a "Vendor-Specific" attribute.
 */
public class VendorSpecificAttribute extends RadiusAttribute {

	/**
	 * Radius attribute type code for Vendor-Specific
	 */
	public static final int VENDOR_SPECIFIC = 26;

	/**
	 * Constructs an empty Vendor-Specific attribute that can be read from a
	 * Radius packet.
	 */
	public VendorSpecificAttribute() {
		super();
	}

	/**
	 * Constructs a new Vendor-Specific attribute to be sent.
	 * @param vendorId vendor ID of the sub-attributes
	 */
	public VendorSpecificAttribute(int vendorId) {
		setAttributeType(VENDOR_SPECIFIC);
		setChildVendorId(vendorId);
	}

	/**
	 * Sets the vendor ID of the child attributes.
	 * @param childVendorId
	 */
	public void setChildVendorId(int childVendorId) {
		this.childVendorId = childVendorId;
	}

	/**
	 * Returns the vendor ID of the sub-attributes.
	 * @return vendor ID of sub attributes
	 */
	public int getChildVendorId() {
		return childVendorId;
	}

	/**
	 * Also copies the new dictionary to sub-attributes.
	 * @param dictionary dictionary to set
	 * @see org.tinyradius.attribute.RadiusAttribute#setDictionary(org.tinyradius.dictionary.Dictionary)
	 */
	public void setDictionary(Dictionary dictionary) {
		super.setDictionary(dictionary);
		for (Iterator i = subAttributes.iterator(); i.hasNext();) {
			RadiusAttribute attr = (RadiusAttribute) i.next();
			attr.setDictionary(dictionary);
		}
	}

	/**
	 * Adds a sub-attribute to this attribute.
	 * @param attribute sub-attribute to add
	 */
	public void addSubAttribute(RadiusAttribute attribute) {
		if (attribute.getVendorId() != getChildVendorId())
			throw new IllegalArgumentException(
					"sub attribut has incorrect vendor ID");

		subAttributes.add(attribute);
	}

	/**
	 * Adds a sub-attribute with the specified name to this attribute.
	 * @param name name of the sub-attribute
	 * @param value value of the sub-attribute
	 * @exception IllegalArgumentException invalid sub-attribute name or value
	 */
	public void addSubAttribute(String name, String value) {
		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);
	}

	/**
	 * Removes the specified sub-attribute from this attribute.
	 * @param attribute RadiusAttribute to remove
	 */
	public void removeSubAttribute(RadiusAttribute attribute) {
		if (!subAttributes.remove(attribute))
			throw new IllegalArgumentException("no such attribute");
	}

	/**
	 * Returns the list of sub-attributes.
	 * @return List of RadiusAttribute objects
	 */
	public List getSubAttributes() {
		return subAttributes;
	}

	/**
	 * Returns all sub-attributes of this attribut which have the given type.
	 * @param attributeType type of sub-attributes to get
	 * @return list of RadiusAttribute objects, does not return null
	 */
	public List getSubAttributes(int attributeType) {
		if (attributeType < 1 || attributeType > 255)
			throw new IllegalArgumentException(
					"sub-attribute type out of bounds");

		LinkedList result = new LinkedList();
		for (Iterator i = subAttributes.iterator(); i.hasNext();) {
			RadiusAttribute a = (RadiusAttribute) i.next();
			if (attributeType == a.getAttributeType())
				result.add(a);
		}
		return result;
	}

	/**
	 * Returns a sub-attribute of the given type which may only occur once in
	 * this attribute.
	 * @param type sub-attribute type
	 * @return RadiusAttribute object or null if there is no such sub-attribute
	 * @throws RuntimeException if there are multiple occurences of the
	 * requested sub-attribute type
	 */
	public RadiusAttribute getSubAttribute(int type) {
		List attrs = getSubAttributes(type);
		if (attrs.size() > 1)
			throw new RuntimeException(
					"multiple sub-attributes of requested type " + type);
		else if (attrs.size() == 0)
			return null;
		else
			return (RadiusAttribute) attrs.get(0);
	}

	/**
	 * Returns a single sub-attribute of the given type name.
	 * @param type attribute type name
	 * @return RadiusAttribute object or null if there is no such attribute
	 * @throws RuntimeException if the attribute occurs multiple times
	 */
	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());
	}

	/**
	 * Returns the value of the Radius attribute of the given type or null if
	 * there is no such attribute.
	 * @param type attribute type name
	 * @return value of the attribute as a string or null if there is no such
	 * attribute
	 * @throws IllegalArgumentException if the type name is unknown
	 * @throws RuntimeException attribute occurs multiple times
	 */
	public String getSubAttributeValue(String type) throws RadiusException {
		RadiusAttribute attr = getSubAttribute(type);
		if (attr == null)
			return null;
		else
			return attr.getAttributeValue();
	}

	/**
	 * Renders this attribute as a byte array.
	 * @see org.tinyradius.attribute.RadiusAttribute#writeAttribute()
	 */
	public byte[] writeAttribute() {
		// write vendor ID
		ByteArrayOutputStream bos = new ByteArrayOutputStream(255);
		bos.write(getChildVendorId() >> 24 & 0x0ff);
		bos.write(getChildVendorId() >> 16 & 0x0ff);
		bos.write(getChildVendorId() >> 8 & 0x0ff);
		bos.write(getChildVendorId() & 0x0ff);

		// write sub-attributes
		try {
			for (Iterator i = subAttributes.iterator(); i.hasNext();) {
				RadiusAttribute a = (RadiusAttribute) i.next();
				bos.write(a.writeAttribute());
			}
		} catch (IOException ioe) {
			// occurs never
			throw new RuntimeException("error writing data", ioe);
		}

		// check data length
		byte[] attrData = bos.toByteArray();
		int len = attrData.length;
		if (len > 253)
			throw new RuntimeException("Vendor-Specific attribute too long: "
					+ bos.size());

		// compose attribute
		byte[] attr = new byte[len + 2];
		attr[0] = VENDOR_SPECIFIC; // code
		attr[1] = (byte) (len + 2); // length
		System.arraycopy(attrData, 0, attr, 2, len);
		return attr;
	}

	/**
	 * Reads a Vendor-Specific attribute and decodes the internal sub-attribute
	 * structure.
	 * @see org.tinyradius.attribute.RadiusAttribute#readAttribute(byte[], int,
	 * int)
	 */
	public void readAttribute(byte[] data, int offset, int length)
			throws RadiusException {
		// check length
		if (length < 6)
			throw new RadiusException("Vendor-Specific attribute too short: "
					+ length);

		int vsaCode = data[offset];
		int vsaLen = ((int) data[offset + 1] & 0x000000ff) - 6;

		if (vsaCode != VENDOR_SPECIFIC)
			throw new RadiusException("not a Vendor-Specific attribute");

		// read vendor ID and vendor data
		/*
		 * int vendorId = (data[offset + 2] << 24 | data[offset + 3] << 16 |
		 * data[offset + 4] << 8 | ((int)data[offset + 5] & 0x000000ff));
		 */
		int vendorId = (unsignedByteToInt(data[offset + 2]) << 24
				| unsignedByteToInt(data[offset + 3]) << 16
				| unsignedByteToInt(data[offset + 4]) << 8 | unsignedByteToInt(data[offset + 5]));
		setChildVendorId(vendorId);

		// validate sub-attribute structure
		int pos = 0;
		int count = 0;
		while (pos < vsaLen) {
			if (pos + 1 >= vsaLen)
				throw new RadiusException("Vendor-Specific attribute malformed");
			// int vsaSubType = data[(offset + 6) + pos] & 0x0ff;
			int vsaSubLen = data[(offset + 6) + pos + 1] & 0x0ff;
			pos += vsaSubLen;
			count++;
		}
		if (pos != vsaLen)
			throw new RadiusException("Vendor-Specific attribute malformed");

		subAttributes = new ArrayList(count);
		pos = 0;
		while (pos < vsaLen) {
			int subtype = data[(offset + 6) + pos] & 0x0ff;
			int sublength = data[(offset + 6) + pos + 1] & 0x0ff;
			RadiusAttribute a = createRadiusAttribute(getDictionary(),
					vendorId, subtype);
			a.readAttribute(data, (offset + 6) + pos, sublength);
			subAttributes.add(a);
			pos += sublength;
		}
	}

	private static int unsignedByteToInt(byte b) {
		return (int) b & 0xFF;
	}

	/**
	 * Returns a string representation for debugging.
	 * @see org.tinyradius.attribute.RadiusAttribute#toString()
	 */
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("Vendor-Specific: ");
		int vendorId = getChildVendorId();
		String vendorName = getDictionary().getVendorName(vendorId);
		if (vendorName != null) {
			sb.append(vendorName);
			sb.append(" (");
			sb.append(vendorId);
			sb.append(")");
		} else {
			sb.append("vendor ID ");
			sb.append(vendorId);
		}
		for (Iterator i = getSubAttributes().iterator(); i.hasNext();) {
			RadiusAttribute attr = (RadiusAttribute) i.next();
			sb.append("\n");
			sb.append(attr.toString());
		}
		return sb.toString();
	}

	/**
	 * Sub attributes. Only set if isRawData == false.
	 */
	private List subAttributes = new ArrayList();

	/**
	 * Vendor ID of sub-attributes.
	 */
	private int childVendorId;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲日本免费电影| 久久久九九九九| 天天做天天摸天天爽国产一区| 色激情天天射综合网| 亚洲高清免费视频| 欧美一区二区日韩一区二区| 精品中文字幕一区二区| 精品久久久久久久久久久久包黑料| 精品一二三四区| 国产喷白浆一区二区三区| 97精品国产97久久久久久久久久久久| 日韩理论在线观看| 欧美日韩久久久久久| 久久精品国产精品亚洲红杏| 国产亚洲精品资源在线26u| 91同城在线观看| 五月婷婷激情综合网| 欧美精品一区二区三区蜜臀| www.欧美.com| 三级精品在线观看| 欧美激情一区在线观看| 欧洲中文字幕精品| 国产一区欧美日韩| 亚洲精品日韩一| 欧美xxxxxxxx| 91丨九色丨尤物| 免费的国产精品| 亚洲欧美偷拍卡通变态| 日韩女优毛片在线| 色婷婷av一区二区三区大白胸| 亚洲va在线va天堂| 中文字幕电影一区| 7777精品伊人久久久大香线蕉的| 懂色一区二区三区免费观看| 亚洲va天堂va国产va久| 欧美国产精品中文字幕| 日韩一区二区免费视频| 色www精品视频在线观看| 狠狠网亚洲精品| 亚洲一二三四区不卡| 国产欧美综合在线观看第十页| 欧美色网一区二区| 成人国产视频在线观看| 看电影不卡的网站| 亚洲成人免费观看| 国产精品短视频| 国产日韩欧美综合在线| 日韩免费视频线观看| 91久久人澡人人添人人爽欧美| 国产成人综合亚洲91猫咪| 天堂久久一区二区三区| 亚洲色欲色欲www| 久久久国产综合精品女国产盗摄| 欧美精品自拍偷拍动漫精品| 91麻豆精品在线观看| 国产成人午夜精品影院观看视频| 日本中文在线一区| 亚洲一区在线看| 亚洲欧洲成人精品av97| 国产亚洲人成网站| 精品日韩欧美在线| 精品欧美一区二区在线观看| 欧美精品777| 欧美午夜电影网| 色狠狠综合天天综合综合| 99久久精品免费看国产| 懂色av一区二区三区免费看| 国产在线观看一区二区| 久久国产精品色| 久久er99热精品一区二区| 免费高清在线一区| 精品一区二区三区在线播放| 日本不卡一区二区| 日本va欧美va欧美va精品| 日韩国产在线一| 视频一区国产视频| 日本sm残虐另类| 久久精品国产澳门| 国产精品综合一区二区三区| 韩国v欧美v日本v亚洲v| 国产精品一区二区在线播放 | 国产一区二区三区不卡在线观看 | 久久成人久久爱| 美女任你摸久久| 精品一区二区久久| 国产麻豆精品在线观看| 国产成人免费网站| 成人黄色大片在线观看| 91视频.com| 欧美日韩精品一区二区三区四区 | 99精品热视频| 91国偷自产一区二区使用方法| 欧美性生交片4| 91麻豆精品国产91久久久久久久久| 精品视频一区二区不卡| 日韩一二在线观看| 久久伊人蜜桃av一区二区| 国产精品久久久久久久久久久免费看| 亚洲视频网在线直播| 亚洲国产视频直播| 精品夜夜嗨av一区二区三区| 成人美女在线观看| 欧美色视频在线| 久久网这里都是精品| 亚洲欧美综合色| 肉色丝袜一区二区| 国产成人av一区二区三区在线| 91在线免费看| 91精品啪在线观看国产60岁| 国产欧美日本一区视频| 亚洲美女少妇撒尿| 激情都市一区二区| 91久久人澡人人添人人爽欧美| 日韩免费一区二区| 亚洲精品亚洲人成人网| 老司机精品视频在线| 国产91丝袜在线播放九色| 欧美视频一区二区在线观看| 久久久久久麻豆| 亚洲在线视频免费观看| 国内精品视频666| 日本高清不卡视频| 国产人久久人人人人爽| 婷婷久久综合九色综合绿巨人| 国产麻豆午夜三级精品| 欧美日韩国产高清一区二区三区| 国产亚洲一二三区| 日韩激情av在线| 99精品欧美一区二区三区小说 | 国产午夜亚洲精品羞羞网站| 亚洲在线视频免费观看| 懂色av一区二区夜夜嗨| 欧美一区二区三区免费大片 | 成人综合日日夜夜| 制服丝袜成人动漫| 亚洲精品国产品国语在线app| 国产麻豆成人传媒免费观看| 欧美人牲a欧美精品| 国产精品美女一区二区| 久热成人在线视频| 欧美性大战久久久久久久| 一区精品在线播放| 九九**精品视频免费播放| 欧美日韩国产色站一区二区三区| 中文字幕中文字幕一区二区| 精品一区二区三区蜜桃| 欧美一区二区三区免费在线看| 亚洲精品写真福利| jlzzjlzz亚洲日本少妇| 欧美国产日韩精品免费观看| 国产综合色视频| 欧美精品一区二区三区视频| 蜜桃视频免费观看一区| 欧美日产在线观看| 亚洲成人你懂的| 欧美日韩国产免费| 亚洲国产成人va在线观看天堂| 波多野结衣中文一区| 国产视频一区在线播放| 国产成人在线视频网址| 久久亚洲一区二区三区四区| 蜜臀av一区二区| 精品日韩成人av| 狠狠狠色丁香婷婷综合激情| 精品国产污污免费网站入口| 久久精品国产精品亚洲精品| 日韩三区在线观看| 蜜桃精品在线观看| 精品免费视频.| 国产高清不卡一区二区| 亚洲国产精品99久久久久久久久| 国产成人亚洲综合a∨婷婷| 国产日韩精品久久久| 成人免费视频视频在线观看免费| 国产情人综合久久777777| 不卡视频在线观看| 一区二区三区在线播| 欧美日韩国产一级二级| 日本不卡视频在线观看| 精品88久久久久88久久久| 国产高清不卡二三区| 国产精品成人午夜| 欧美性猛交xxxx黑人交| 日韩av午夜在线观看| 精品国产91洋老外米糕| 成人一区二区三区视频| 亚洲女人****多毛耸耸8| 欧美三级蜜桃2在线观看| 蜜臀av在线播放一区二区三区| 欧美精品一区二区三区视频| 成人久久视频在线观看| 亚洲一区二区在线播放相泽| 日韩小视频在线观看专区| 国产精品一级在线| 伊人性伊人情综合网| 欧美一区二区三区在线观看| 国产伦精品一区二区三区免费| 成人免费在线观看入口| 欧美精品v国产精品v日韩精品| 国产伦精一区二区三区|