Package org.tinyradius.core.packet
Class BaseRadiusPacket<T extends RadiusPacket<T>>
java.lang.Object
org.tinyradius.core.packet.BaseRadiusPacket<T>
- All Implemented Interfaces:
AttributeHolder<T>
,NestedAttributeHolder<T>
,RadiusPacket<T>
- Direct Known Subclasses:
GenericRequest
,GenericResponse
public abstract class BaseRadiusPacket<T extends RadiusPacket<T>> extends java.lang.Object implements RadiusPacket<T>
Base Radius Packet implementation without support for authenticators or encoding
-
Field Summary
Fields inherited from interface org.tinyradius.core.packet.RadiusPacket
HEADER_LENGTH, MAX_PACKET_LENGTH, packetLogger
-
Constructor Summary
Constructors Constructor Description BaseRadiusPacket(Dictionary dictionary, byte type, byte id, byte[] authenticator, java.util.List<RadiusAttribute> attributes)
Builds a Radius packet with the given type, identifier and attributes. -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.util.List<RadiusAttribute>
getAttributes()
byte[]
getAuthenticator()
Returns the authenticator for this Radius packet.int
getChildVendorId()
Dictionary
getDictionary()
byte
getId()
byte
getType()
int
hashCode()
java.lang.String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.tinyradius.core.attribute.AttributeHolder
addAttribute, addAttribute, decodeAttributes, encodeAttributes, filterAttributes, filterAttributes, filterAttributes, getAttribute, getAttribute, getAttributeBytes, removeAttributes, removeLastAttribute, withAttributes
Methods inherited from interface org.tinyradius.core.attribute.NestedAttributeHolder
addAttribute, filterAttributes, filterAttributes, getAttribute, getFlattenedAttributes, getVendorAttributes, removeAttribute, removeAttributes
Methods inherited from interface org.tinyradius.core.packet.RadiusPacket
genHashedAuth, toDatagram, toDatagram, verifyPacketAuth
-
Constructor Details
-
BaseRadiusPacket
public BaseRadiusPacket(Dictionary dictionary, byte type, byte id, byte[] authenticator, java.util.List<RadiusAttribute> attributes)Builds a Radius packet with the given type, identifier and attributes.Use
RadiusRequest.create(Dictionary, byte, byte, byte[], List)
orRadiusResponse.create(Dictionary, byte, byte, byte[], List)
where possible as that automatically creates Request/Response variants as required.- Parameters:
dictionary
- custom dictionary to usetype
- packet typeid
- packet identifierauthenticator
- can be null if creating manuallyattributes
- list of RadiusAttributes
-
-
Method Details
-
getChildVendorId
public int getChildVendorId()- Specified by:
getChildVendorId
in interfaceAttributeHolder<T extends RadiusPacket<T>>
- Returns:
- VendorId to restrict (sub)attributes, or -1 for top level
-
getId
public byte getId()- Specified by:
getId
in interfaceRadiusPacket<T extends RadiusPacket<T>>
- Returns:
- Radius packet identifier
-
getType
public byte getType()- Specified by:
getType
in interfaceRadiusPacket<T extends RadiusPacket<T>>
- Returns:
- Radius packet type
-
getAttributes
- Specified by:
getAttributes
in interfaceAttributeHolder<T extends RadiusPacket<T>>
- Specified by:
getAttributes
in interfaceRadiusPacket<T extends RadiusPacket<T>>
- Returns:
- list of RadiusAttributes in packet
-
getAuthenticator
public byte[] getAuthenticator()Description copied from interface:RadiusPacket
Returns the authenticator for this Radius packet.For a Radius packet read from a stream, this will return the authenticator sent by the server.
For a new Radius packet to be sent, this will return the authenticator created, or null if no authenticator has been created yet.
- Specified by:
getAuthenticator
in interfaceRadiusPacket<T extends RadiusPacket<T>>
- Returns:
- authenticator, 16 bytes
-
getDictionary
- Specified by:
getDictionary
in interfaceAttributeHolder<T extends RadiusPacket<T>>
- Specified by:
getDictionary
in interfaceRadiusPacket<T extends RadiusPacket<T>>
- Returns:
- the dictionary this Radius packet uses.
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-