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 Object
implements RadiusPacket<T>
Base Radius Packet implementation without support for authenticators or encoding
-
Field Summary
Fields inherited from interface org.tinyradius.core.attribute.AttributeHolder
attrHolderLogger
Fields inherited from interface org.tinyradius.core.packet.RadiusPacket
MAX_PACKET_LENGTH
-
Constructor Summary
ModifierConstructorDescriptionprotected
BaseRadiusPacket
(Dictionary dictionary, io.netty.buffer.ByteBuf header, List<RadiusAttribute> attributes) -
Method Summary
Modifier and TypeMethodDescriptionboolean
byte[]
Returns the authenticator for this Radius packet.int
io.netty.buffer.ByteBuf
byte
getId()
byte
getType()
int
hashCode()
toString()
protected void
verifyPacketAuth
(String sharedSecret, byte[] requestAuth) protected abstract T
with
(io.netty.buffer.ByteBuf header, List<RadiusAttribute> attributes) Naive with(), does not recalculate packet lengths in header.withAttributes
(List<RadiusAttribute> attributes) withAuthAttributes
(byte[] auth, List<RadiusAttribute> attributes) 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, getAttribute, getAttribute, getAttributeByteBuf, getAttributes, getAttributes, getAttributes, removeAttributes, removeLastAttribute
Methods inherited from interface org.tinyradius.core.attribute.NestedAttributeHolder
addAttribute, getAttribute, getAttributes, getAttributes, getFlattenedAttributes, getVendorAttributes, removeAttribute, removeAttributes
Methods inherited from interface org.tinyradius.core.packet.RadiusPacket
genHashedAuth, getLength, toByteBuf, toByteBuffer, toBytes
-
Constructor Details
-
BaseRadiusPacket
protected BaseRadiusPacket(Dictionary dictionary, io.netty.buffer.ByteBuf header, List<RadiusAttribute> attributes) throws RadiusPacketException - Throws:
RadiusPacketException
-
-
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
-
getHeader
public io.netty.buffer.ByteBuf getHeader()- Specified by:
getHeader
in interfaceRadiusPacket<T extends RadiusPacket<T>>
-
getId
public byte getId()- Specified by:
getId
in interfaceRadiusPacket<T extends RadiusPacket<T>>
- Returns:
- Radius packet id
-
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>>
- Returns:
- list of RadiusAttributes
-
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>>
-
withAttributes
- Specified by:
withAttributes
in interfaceAttributeHolder<T extends RadiusPacket<T>>
- Throws:
RadiusPacketException
-
withAuthAttributes
public T withAuthAttributes(byte[] auth, List<RadiusAttribute> attributes) throws RadiusPacketException - Throws:
RadiusPacketException
-
with
protected abstract T with(io.netty.buffer.ByteBuf header, List<RadiusAttribute> attributes) throws RadiusPacketException Naive with(), does not recalculate packet lengths in header.- Parameters:
header
- Radius packet headerattributes
- Radius packet attributes- Returns:
- RadiusPacket with the specified headers and attributes
- Throws:
RadiusPacketException
- packet validation exceptions
-
verifyPacketAuth
protected void verifyPacketAuth(String sharedSecret, byte[] requestAuth) throws RadiusPacketException - Parameters:
sharedSecret
- shared secretrequestAuth
- request authenticator if verifying response, otherwise set to 16 zero octets- Throws:
RadiusPacketException
- if authenticator check fails
-
toString
-
equals
-
hashCode
public int hashCode()
-