Package org.tinyradius.core.packet
Interface RadiusPacket<T extends RadiusPacket<T>>
- All Superinterfaces:
AttributeHolder<T>
,NestedAttributeHolder<T>
- All Known Subinterfaces:
MessageAuthSupport<T>
,RadiusRequest
,RadiusResponse
- All Known Implementing Classes:
AccessRequest
,AccessRequestArap
,AccessRequestChap
,AccessRequestEap
,AccessRequestNoAuth
,AccessRequestPap
,AccessResponse
,AccessResponse.Accept
,AccessResponse.Challenge
,AccessResponse.Reject
,AccountingRequest
,BaseRadiusPacket
,GenericRequest
,GenericResponse
public interface RadiusPacket<T extends RadiusPacket<T>> extends NestedAttributeHolder<T>
-
Field Summary
Fields Modifier and Type Field Description static int
HEADER_LENGTH
static int
MAX_PACKET_LENGTH
static org.apache.logging.log4j.Logger
packetLogger
-
Method Summary
Modifier and Type Method Description static RadiusRequest
fromByteBuf(Dictionary dictionary, io.netty.buffer.ByteBuf byteBuf)
Reads a Radius packet from the given input stream and creates an appropriate RadiusPacket descendant object.default byte[]
genHashedAuth(java.lang.String sharedSecret, byte[] requestAuth)
Generates an authenticator for a Radius packet.java.util.List<RadiusAttribute>
getAttributes()
byte[]
getAuthenticator()
Returns the authenticator for this Radius packet.Dictionary
getDictionary()
byte
getId()
static java.security.MessageDigest
getMd5Digest()
byte
getType()
static io.netty.buffer.ByteBuf
toByteBuf(RadiusPacket<?> packet)
default io.netty.channel.socket.DatagramPacket
toDatagram(java.net.InetSocketAddress recipient)
default io.netty.channel.socket.DatagramPacket
toDatagram(java.net.InetSocketAddress recipient, java.net.InetSocketAddress sender)
default void
verifyPacketAuth(java.lang.String sharedSecret, byte[] requestAuth)
Methods inherited from interface org.tinyradius.core.attribute.AttributeHolder
addAttribute, addAttribute, decodeAttributes, encodeAttributes, filterAttributes, filterAttributes, filterAttributes, getAttribute, getAttribute, getAttributeBytes, getChildVendorId, removeAttributes, removeLastAttribute, withAttributes
Methods inherited from interface org.tinyradius.core.attribute.NestedAttributeHolder
addAttribute, filterAttributes, filterAttributes, getAttribute, getFlattenedAttributes, getVendorAttributes, removeAttribute, removeAttributes
-
Field Details
-
packetLogger
static final org.apache.logging.log4j.Logger packetLogger -
HEADER_LENGTH
static final int HEADER_LENGTH- See Also:
- Constant Field Values
-
MAX_PACKET_LENGTH
static final int MAX_PACKET_LENGTH- See Also:
- Constant Field Values
-
-
Method Details
-
getMd5Digest
static java.security.MessageDigest getMd5Digest() -
toByteBuf
- Throws:
RadiusPacketException
-
fromByteBuf
static RadiusRequest fromByteBuf(Dictionary dictionary, io.netty.buffer.ByteBuf byteBuf) throws RadiusPacketExceptionReads a Radius packet from the given input stream and creates an appropriate RadiusPacket descendant object.Decodes the encrypted fields and attributes of the packet, and checks authenticator if appropriate.
- Parameters:
dictionary
- dictionary to use for attributesbyteBuf
- DatagramPacket to read packet from- Returns:
- new RadiusPacket object
- Throws:
RadiusPacketException
- malformed packet
-
toDatagram
default io.netty.channel.socket.DatagramPacket toDatagram(java.net.InetSocketAddress recipient, java.net.InetSocketAddress sender) throws RadiusPacketException- Parameters:
recipient
- destination socketsender
- source socket, nullable- Returns:
- converted DatagramPacket
- Throws:
RadiusPacketException
- if packet could not be encoded/serialized to datagram
-
toDatagram
default io.netty.channel.socket.DatagramPacket toDatagram(java.net.InetSocketAddress recipient) throws RadiusPacketException- Parameters:
recipient
- destination socket- Returns:
- converted DatagramPacket
- Throws:
RadiusPacketException
- if packet could not be encoded/serialized to datagram
-
getType
byte getType()- Returns:
- Radius packet type
-
getId
byte getId()- Returns:
- Radius packet identifier
-
getAuthenticator
byte[] getAuthenticator()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.
- Returns:
- authenticator, 16 bytes
-
getAttributes
java.util.List<RadiusAttribute> getAttributes()- Specified by:
getAttributes
in interfaceAttributeHolder<T extends RadiusPacket<T>>
- Returns:
- list of RadiusAttributes in packet
-
getDictionary
Dictionary getDictionary()- Specified by:
getDictionary
in interfaceAttributeHolder<T extends RadiusPacket<T>>
- Returns:
- the dictionary this Radius packet uses.
-
verifyPacketAuth
default void verifyPacketAuth(java.lang.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
-
genHashedAuth
default byte[] genHashedAuth(java.lang.String sharedSecret, byte[] requestAuth)Generates an authenticator for a Radius packet.Note: 'this' packet authenticator is ignored, only requestAuth param is used.
- Parameters:
sharedSecret
- shared secretrequestAuth
- request authenticator if hashing for response, otherwise set to 16 zero octets- Returns:
- new 16 byte response authenticator
-