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>attributesprotected byte[]authenticatorprotected bytecodeprotected byteidentifierprotected shortlengthstatic shortMAX_ATTR_VALUE_LENGTHstatic byteRADIUS_CODE_ACCESS_ACCEPTstatic byteRADIUS_CODE_ACCESS_CHALLENGEstatic byteRADIUS_CODE_ACCESS_REJECTstatic byteRADIUS_CODE_ACCESS_REQUESTstatic byteRADIUS_CODE_ACCOUNTING_REQUESTstatic byteRADIUS_CODE_ACCOUNTING_RESPONSEstatic shortRADIUS_MAX_LENGTHstatic shortRADIUS_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 RADIUSAttributeaddMessageAuthenticator(java.lang.String key)Adds a message authenticator to the packet based on the given key.booleancheckMessageAuthenticator(java.lang.String key)Checks the message authenticator in the packet with one generated from the given key.EAPdecapsulateMessage()Decapsulates an EAP packet from the RADIUS packet.static Deserializer<RADIUS>deserializer()Deserializer for RADIUS packets.voidencapsulateMessage(EAP message)Encapsulates an EAP packet in this RADIUS packet.byte[]generateAuthCode()Generates an authenticator code.RADIUSAttributegetAttribute(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.bytegetCode()Gets the code.bytegetIdentifier()Gets the identifier.booleanisValidCode()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.RADIUSAttributesetAttribute(byte attrType, byte[] value)Sets an attribute in the RADIUS packet.voidsetAuthenticator(byte[] authenticator)Sets the authenticator.voidsetCode(byte code)Sets the code.voidsetIdentifier(byte identifier)Sets the identifier.java.lang.StringtoString()RADIUSAttributeupdateAttribute(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
-
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:IPacketSets 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:
toStringin classjava.lang.Object
-
-