资源简介
tinyRadius封装,官方源码和的test测试代码
代码片段和文件信息
/**
* $Id: IntegerAttribute.javav 1.4 2005/09/04 22:11:03 wuttke Exp $
* Created on 08.04.2005
* @author Matthias Wuttke
* @version $Revision: 1.4 $
*/
package org.tinyradius.attribute;
import org.tinyradius.dictionary.AttributeType;
import org.tinyradius.util.RadiusException;
/**
* This class represents a Radius attribute which only
* contains a 32 bit integer.
*/
public class IntegerAttribute extends RadiusAttribute {
/**
* Constructs an empty integer attribute.
*/
public IntegerAttribute() {
super();
}
/**
* Constructs an integer attribute with the given value.
* @param type attribute type
* @param value attribute value
*/
public IntegerAttribute(int type int value) {
setAttributeType(type);
setAttributeValue(value);
}
/**
* Returns the string value of this attribute.
* @return a string
*/
public int getAttributeValueInt() {
byte[] data = getAttributeData();
return (((data[0] & 0x0ff) << 24) | ((data[1] & 0x0ff) << 16) |
((data[2] & 0x0ff) << 8) | (data[3] & 0x0ff));
}
/**
* Returns the value of this attribute as a string.
* 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);
}
/**
* Sets the value of this attribute.
* @param value integer value
*/
public void setAttributeValue(int value) {
byte[] data = new byte[4];
data[0] = (byte)(value >> 24 & 0x0ff);
data[1] = (byte)(value >> 16 & 0x0ff);
data[2] = (byte)(value >> 8 & 0x0ff);
data[3] = (byte)(value & 0x0ff);
setAttributeData(data);
}
/**
* 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;
}
}
setAttributeValue(Integer.parseInt(value));
}
/**
* Check attribute length.
* @see org.tinyradius.attribute.RadiusAttribute#readAttribute(byte[] int int)
*/
public void readAttribute(byte[] data int offset int length)
throws RadiusException {
if (length != 6)
throw new RadiusException(“integer attribute: expected 4 bytes data“);
super.readAttribute(data offset length);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-03 17:40 dist\
文件 61441 2010-02-03 23:51 dist\TinyRadius-1.0.jar
目录 0 2018-12-03 17:40 doc\
目录 0 2018-12-03 17:40 doc\apidoc\
文件 4038 2010-02-03 23:51 doc\apidoc\allclasses-fr
文件 3558 2010-02-03 23:51 doc\apidoc\allclasses-nofr
文件 20018 2010-02-03 23:51 doc\apidoc\constant-values.html
文件 5940 2010-02-03 23:51 doc\apidoc\deprecated-list.html
文件 10031 2010-02-03 23:51 doc\apidoc\help-doc.html
目录 0 2018-12-03 17:40 doc\apidoc\index-files\
文件 19219 2010-02-03 23:51 doc\apidoc\index-files\index-1.html
文件 7503 2010-02-03 23:51 doc\apidoc\index-files\index-10.html
文件 8124 2010-02-03 23:51 doc\apidoc\index-files\index-11.html
文件 16179 2010-02-03 23:51 doc\apidoc\index-files\index-12.html
文件 21556 2010-02-03 23:51 doc\apidoc\index-files\index-13.html
文件 9763 2010-02-03 23:51 doc\apidoc\index-files\index-14.html
文件 7624 2010-02-03 23:51 doc\apidoc\index-files\index-15.html
文件 8310 2010-02-03 23:51 doc\apidoc\index-files\index-16.html
文件 7340 2010-02-03 23:51 doc\apidoc\index-files\index-17.html
文件 12607 2010-02-03 23:51 doc\apidoc\index-files\index-2.html
文件 11917 2010-02-03 23:51 doc\apidoc\index-files\index-3.html
文件 8511 2010-02-03 23:51 doc\apidoc\index-files\index-4.html
文件 33187 2010-02-03 23:51 doc\apidoc\index-files\index-5.html
文件 6918 2010-02-03 23:51 doc\apidoc\index-files\index-6.html
文件 9080 2010-02-03 23:51 doc\apidoc\index-files\index-7.html
文件 7370 2010-02-03 23:51 doc\apidoc\index-files\index-8.html
文件 10112 2010-02-03 23:51 doc\apidoc\index-files\index-9.html
文件 1528 2010-02-03 23:51 doc\apidoc\index.html
目录 0 2018-12-03 17:40 doc\apidoc\org\
目录 0 2018-12-03 17:40 doc\apidoc\org\tinyradius\
目录 0 2018-12-03 17:40 doc\apidoc\org\tinyradius\attribute\
............此处省略137个文件信息
- 上一篇:MM1排队系统仿真
- 下一篇:基于紫红外线检测原理的火焰传感器的设计
评论
共有 条评论