Package org.onlab.packet
Class RADIUS
- java.lang.Object
-
- org.onlab.packet.BasePacket
-
- org.onlab.packet.RADIUS
-
- All Implemented Interfaces:
IPacket
public class RADIUS extends BasePacket
RADIUS packet.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<RADIUSAttribute>
attributes
protected byte[]
authenticator
protected byte
code
protected byte
identifier
protected short
length
static short
MAX_ATTR_VALUE_LENGTH
static byte
RADIUS_CODE_ACCESS_ACCEPT
static byte
RADIUS_CODE_ACCESS_CHALLENGE
static byte
RADIUS_CODE_ACCESS_REJECT
static byte
RADIUS_CODE_ACCESS_REQUEST
static byte
RADIUS_CODE_ACCOUNTING_REQUEST
static byte
RADIUS_CODE_ACCOUNTING_RESPONSE
static short
RADIUS_MAX_LENGTH
static short
RADIUS_MIN_LENGTH
-
Fields inherited from class org.onlab.packet.BasePacket
parent, payload
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RADIUSAttribute
addMessageAuthenticator(java.lang.String key)
Adds a message authenticator to the packet based on the given key.boolean
checkMessageAuthenticator(java.lang.String key)
Checks the message authenticator in the packet with one generated from the given key.EAP
decapsulateMessage()
Decapsulates an EAP packet from the RADIUS packet.static Deserializer<RADIUS>
deserializer()
Deserializer for RADIUS packets.void
encapsulateMessage(EAP message)
Encapsulates an EAP packet in this RADIUS packet.byte[]
generateAuthCode()
Generates an authenticator code.RADIUSAttribute
getAttribute(byte attrType)
Gets an attribute from the RADIUS packet.java.util.ArrayList<RADIUSAttribute>
getAttributeList(byte attrType)
Gets a list of attributes from the RADIUS packet.byte[]
getAuthenticator()
Gets the authenticator.byte
getCode()
Gets the code.byte
getIdentifier()
Gets the identifier.int
getReadableIdentifier()
Get the identifier in a readable format.boolean
isValidCode()
Checks if the packet's code field is valid.byte[]
serialize()
Sets all payloads parent packet if applicable, then serializes this packet and all payloads.RADIUSAttribute
setAttribute(byte attrType, byte[] value)
Sets an attribute in the RADIUS packet.void
setAuthenticator(byte[] authenticator)
Sets the authenticator.void
setCode(byte code)
Sets the code.void
setIdentifier(byte identifier)
Sets the identifier.java.lang.String
toString()
RADIUSAttribute
updateAttribute(byte attrType, byte[] value)
Updates an attribute in the RADIUS packet.-
Methods inherited from class org.onlab.packet.BasePacket
clone, equals, getParent, getPayload, hashCode, resetChecksum, setParent, setPayload
-
-
-
-
Field Detail
-
code
protected byte code
-
identifier
protected byte identifier
-
length
protected short length
-
authenticator
protected byte[] authenticator
-
attributes
protected java.util.List<RADIUSAttribute> attributes
-
RADIUS_MIN_LENGTH
public static final short RADIUS_MIN_LENGTH
- See Also:
- Constant Field Values
-
MAX_ATTR_VALUE_LENGTH
public static final short MAX_ATTR_VALUE_LENGTH
- See Also:
- Constant Field Values
-
RADIUS_MAX_LENGTH
public static final short RADIUS_MAX_LENGTH
- See Also:
- Constant Field Values
-
RADIUS_CODE_ACCESS_REQUEST
public static final byte RADIUS_CODE_ACCESS_REQUEST
- See Also:
- Constant Field Values
-
RADIUS_CODE_ACCESS_ACCEPT
public static final byte RADIUS_CODE_ACCESS_ACCEPT
- See Also:
- Constant Field Values
-
RADIUS_CODE_ACCESS_REJECT
public static final byte RADIUS_CODE_ACCESS_REJECT
- See Also:
- Constant Field Values
-
RADIUS_CODE_ACCOUNTING_REQUEST
public static final byte RADIUS_CODE_ACCOUNTING_REQUEST
- See Also:
- Constant Field Values
-
RADIUS_CODE_ACCOUNTING_RESPONSE
public static final byte RADIUS_CODE_ACCOUNTING_RESPONSE
- See Also:
- Constant Field Values
-
RADIUS_CODE_ACCESS_CHALLENGE
public static final byte RADIUS_CODE_ACCESS_CHALLENGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCode
public byte getCode()
Gets the code.- Returns:
- code
-
setCode
public void setCode(byte code)
Sets the code.- Parameters:
code
- code
-
getIdentifier
public byte getIdentifier()
Gets the identifier.- Returns:
- identifier
-
getReadableIdentifier
public int getReadableIdentifier()
Get the identifier in a readable format.- Returns:
- identifier
-
setIdentifier
public void setIdentifier(byte identifier)
Sets the identifier.- Parameters:
identifier
- identifier
-
getAuthenticator
public byte[] getAuthenticator()
Gets the authenticator.- Returns:
- authenticator
-
setAuthenticator
public void setAuthenticator(byte[] authenticator)
Sets the authenticator.- Parameters:
authenticator
- authenticator
-
generateAuthCode
public byte[] generateAuthCode()
Generates an authenticator code.- Returns:
- the authenticator
-
isValidCode
public boolean isValidCode()
Checks if the packet's code field is valid.- Returns:
- whether the code is valid
-
addMessageAuthenticator
public RADIUSAttribute addMessageAuthenticator(java.lang.String key)
Adds a message authenticator to the packet based on the given key.- Parameters:
key
- key to generate message authenticator- Returns:
- the messgae authenticator RADIUS attribute
-
checkMessageAuthenticator
public boolean checkMessageAuthenticator(java.lang.String key)
Checks the message authenticator in the packet with one generated from the given key.- Parameters:
key
- key to generate message authenticator- Returns:
- whether the message authenticators match or not
-
encapsulateMessage
public void encapsulateMessage(EAP message)
Encapsulates an EAP packet in this RADIUS packet.- Parameters:
message
- EAP message object to be embedded in the RADIUS EAP-Message attributed
-
decapsulateMessage
public EAP decapsulateMessage() throws DeserializationException
Decapsulates an EAP packet from the RADIUS packet.- Returns:
- An EAP object containing the reassembled EAP message
- Throws:
DeserializationException
- if packet deserialization fails
-
getAttributeList
public java.util.ArrayList<RADIUSAttribute> getAttributeList(byte attrType)
Gets a list of attributes from the RADIUS packet.- Parameters:
attrType
- the type field of the required attributes- Returns:
- List of the attributes that matches the type or an empty list if there is none
-
getAttribute
public RADIUSAttribute getAttribute(byte attrType)
Gets an attribute from the RADIUS packet.- Parameters:
attrType
- the type field of the required attribute- Returns:
- the first attribute that matches the type or null if does not exist
-
setAttribute
public RADIUSAttribute setAttribute(byte attrType, byte[] value)
Sets an attribute in the RADIUS packet.- Parameters:
attrType
- the type field of the attribute to setvalue
- value to be set- Returns:
- reference to the attribute object
-
updateAttribute
public RADIUSAttribute updateAttribute(byte attrType, byte[] value)
Updates an attribute in the RADIUS packet.- Parameters:
attrType
- the type field of the attribute to updatevalue
- the value to update to- Returns:
- reference to the attribute object
-
deserializer
public static Deserializer<RADIUS> deserializer()
Deserializer for RADIUS packets.- Returns:
- deserializer
-
serialize
public byte[] serialize()
Description copied from interface:IPacket
Sets all payloads parent packet if applicable, then serializes this packet and all payloads.- Returns:
- a byte[] containing this packet and payloads
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-