Class OctetsAttribute
java.lang.Object
org.tinyradius.core.attribute.type.OctetsAttribute
- All Implemented Interfaces:
RadiusAttribute
- Direct Known Subclasses:
IntegerAttribute
,IpAttribute
,Ipv6PrefixAttribute
,StringAttribute
,VendorSpecificAttribute
public class OctetsAttribute extends java.lang.Object implements RadiusAttribute
The basic generic Radius attribute. All type-specific implementations extend this class
by adding additional type conversion methods and validations.
-
Constructor Summary
Constructors Constructor Description OctetsAttribute(Dictionary dictionary, int vendorId, byte type, byte[] value)
OctetsAttribute(Dictionary dictionary, int vendorId, byte type, java.lang.String value)
-
Method Summary
Modifier and Type Method Description RadiusAttribute
decode(byte[] requestAuth, java.lang.String secret)
Decodes attribute.RadiusAttribute
encode(byte[] requestAuth, java.lang.String secret)
Encodes attribute.boolean
equals(java.lang.Object o)
java.util.List<RadiusAttribute>
flatten()
Returns set of all nested attributes if contains sub-attributes, otherwise singleton set of current attribute.java.lang.String
getAttributeName()
java.util.Optional<AttributeTemplate>
getAttributeTemplate()
Dictionary
getDictionary()
byte
getTag()
byte
getType()
byte[]
getValue()
java.lang.String
getValueString()
int
getVendorId()
int
hashCode()
byte[]
toByteArray()
java.lang.String
toString()
-
Constructor Details
-
OctetsAttribute
- Parameters:
dictionary
- dictionary to usevendorId
- vendor ID or -1type
- attribute type codevalue
- value of attribute as byte array, excluding type and length bytes
-
OctetsAttribute
- Parameters:
dictionary
- dictionary to usevendorId
- vendor ID or -1type
- attribute type codevalue
- value of attribute as hex string
-
-
Method Details
-
getVendorId
public int getVendorId()- Specified by:
getVendorId
in interfaceRadiusAttribute
- Returns:
- vendor Id if Vendor-Specific attribute or sub-attribute, otherwise -1
-
getType
public byte getType()- Specified by:
getType
in interfaceRadiusAttribute
- Returns:
- attribute type code, 0-255
-
getTag
public byte getTag()- Specified by:
getTag
in interfaceRadiusAttribute
- Returns:
- Tag if available and specified for attribute type (RFC2868)
-
getValue
public byte[] getValue()- Specified by:
getValue
in interfaceRadiusAttribute
- Returns:
- attribute data as raw bytes
-
getValueString
public java.lang.String getValueString()- Specified by:
getValueString
in interfaceRadiusAttribute
- Returns:
- value of this attribute as a hex string.
-
getDictionary
- Specified by:
getDictionary
in interfaceRadiusAttribute
- Returns:
- dictionary that attribute uses
-
toByteArray
public byte[] toByteArray()- Specified by:
toByteArray
in interfaceRadiusAttribute
- Returns:
- entire attribute (including headers) as byte array
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getAttributeName
public java.lang.String getAttributeName()- Specified by:
getAttributeName
in interfaceRadiusAttribute
-
flatten
Description copied from interface:RadiusAttribute
Returns set of all nested attributes if contains sub-attributes, otherwise singleton set of current attribute.- Specified by:
flatten
in interfaceRadiusAttribute
- Returns:
- List of RadiusAttributes
-
getAttributeTemplate
- Specified by:
getAttributeTemplate
in interfaceRadiusAttribute
- Returns:
- AttributeTemplate used to define this attribute
-
encode
public RadiusAttribute encode(byte[] requestAuth, java.lang.String secret) throws RadiusPacketExceptionDescription copied from interface:RadiusAttribute
Encodes attribute. Must be idempotent.- Specified by:
encode
in interfaceRadiusAttribute
- Parameters:
requestAuth
- (corresponding) request packet authenticatorsecret
- shared secret to encode with- Returns:
- attribute with encoded data
- Throws:
RadiusPacketException
- errors encoding attribute
-
decode
Description copied from interface:RadiusAttribute
Decodes attribute. Must be idempotent.- Specified by:
decode
in interfaceRadiusAttribute
- Parameters:
requestAuth
- (corresponding) request packet authenticatorsecret
- shared secret to encode with- Returns:
- attribute with encoded data
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-