net.sf.jradius.packet
Class RadiusPacket

java.lang.Object
  extended by net.sf.jradius.packet.RadiusPacket
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NullPacket, RadiusRequest, RadiusResponse

public abstract class RadiusPacket
extends java.lang.Object
implements java.io.Serializable

Represents a Radius Packet. All radius packet classes are derived from this abstract class.

Author:
David Bird
See Also:
Serialized Form

Field Summary
protected  AttributeList attributes
           
protected  byte[] authenticator
           
protected  int code
           
protected  int identifier
           
static int MAX_PACKET_LENGTH
           
static int MIN_PACKET_LENGTH
           
static short RADIUS_HEADER_LENGTH
           
 
Constructor Summary
RadiusPacket()
          Default Constructor
RadiusPacket(AttributeList list)
          Constructs a RadiusPacket with an AttributeList
 
Method Summary
 void addAttribute(RadiusAttribute attribute)
          Adds an attribute to a RadiusPacket (without overriding any existing attributes)
 void addAttributes(AttributeList list)
          Adds the contents of an AttributeList to a RadiusPacket
 byte[] createAuthenticator(byte[] attributes)
          Derived RadiusRequest classes must override this
 RadiusAttribute findAttribute(int type)
           
 RadiusAttribute findAttribute(java.lang.String aName)
           
 java.lang.Object[] findAttributes(int type)
           
 AttributeList getAttributes()
          Get the attributes of a RadiusPacket
 java.lang.Object getAttributeValue(int type)
           
 java.lang.Object getAttributeValue(java.lang.String aName)
           
 byte[] getAuthenticator()
           
 byte[] getAuthenticator(byte[] attributes)
          Get (or generate) the RADIUS Authenticator
 int getCode()
           
 int getIdentifier()
          Get the Identifier of the RadiusPacket (creating one if needed)
 void overwriteAttribute(RadiusAttribute attribute)
          Adds an attribute to a RadiusPacket overwriting any existing attribute
 void removeAttribute(int attributeType)
          Removes an attribute
 void removeAttribute(RadiusAttribute attribute)
          Removes an attribute
 void setAuthenticator(byte[] authenticator)
           
 void setCode(int code)
           
 void setIdentifier(int i)
          Set the Identifier byte of a RadiusPacket
 java.lang.String toString()
           
 java.lang.String toString(boolean nonStandardAtts, boolean unknownAttrs)
          Formats the RadiusPacket into a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_PACKET_LENGTH

public static final int MIN_PACKET_LENGTH
See Also:
Constant Field Values

MAX_PACKET_LENGTH

public static final int MAX_PACKET_LENGTH
See Also:
Constant Field Values

RADIUS_HEADER_LENGTH

public static final short RADIUS_HEADER_LENGTH
See Also:
Constant Field Values

code

protected int code

identifier

protected int identifier

authenticator

protected byte[] authenticator

attributes

protected final AttributeList attributes
Constructor Detail

RadiusPacket

public RadiusPacket()
Default Constructor


RadiusPacket

public RadiusPacket(AttributeList list)
Constructs a RadiusPacket with an AttributeList

Parameters:
list - Initial AttributeList
Method Detail

setCode

public void setCode(int code)
Parameters:
code - The code to set

getCode

public int getCode()
Returns:
Returns the code of the RadiusPacket

addAttribute

public void addAttribute(RadiusAttribute attribute)
Adds an attribute to a RadiusPacket (without overriding any existing attributes)

Parameters:
attribute - The attribute to add

overwriteAttribute

public void overwriteAttribute(RadiusAttribute attribute)
Adds an attribute to a RadiusPacket overwriting any existing attribute

Parameters:
attribute - The attribute to add

addAttributes

public void addAttributes(AttributeList list)
Adds the contents of an AttributeList to a RadiusPacket

Parameters:
list - The attributes to add

removeAttribute

public void removeAttribute(RadiusAttribute attribute)
Removes an attribute

Parameters:
attribute - The RadiusAttribute to be removed

removeAttribute

public void removeAttribute(int attributeType)
Removes an attribute

Parameters:
attributeType - The attribute type to be removed

getIdentifier

public int getIdentifier()
Get the Identifier of the RadiusPacket (creating one if needed)

Returns:
Returns the RadiusPacket Identifier

setIdentifier

public void setIdentifier(int i)
Set the Identifier byte of a RadiusPacket

Parameters:
i - The new Identifier

getAttributes

public AttributeList getAttributes()
Get the attributes of a RadiusPacket

Returns:
Returns the AttributeList of the packet

createAuthenticator

public byte[] createAuthenticator(byte[] attributes)
Derived RadiusRequest classes must override this

Parameters:
attributes -
Returns:
Returns 16 bytes

setAuthenticator

public void setAuthenticator(byte[] authenticator)
Parameters:
authenticator - The authenticator to set.

getAuthenticator

public byte[] getAuthenticator()
Returns:
Returns the packet authenticator

getAuthenticator

public byte[] getAuthenticator(byte[] attributes)
Get (or generate) the RADIUS Authenticator

Parameters:
attributes -
Returns:
Returns the packet authenticator

findAttribute

public RadiusAttribute findAttribute(int type)
Parameters:
type - The attribute type
Returns:
Returns the attribute, if found

findAttributes

public java.lang.Object[] findAttributes(int type)
Parameters:
type - The integer type of the attribute to find
Returns:
Returns an array of RadiusAttributes

findAttribute

public RadiusAttribute findAttribute(java.lang.String aName)
                              throws UnknownAttributeException
Parameters:
aName - The name of the attribute to find
Returns:
Returns the RadiusAttribute, null if not found
Throws:
UnknownAttributeException

getAttributeValue

public java.lang.Object getAttributeValue(int type)
Parameters:
type - The integer type of the attribute to find
Returns:
Returns the Object value of the found attribute, otherwise null

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String aName)
                                   throws UnknownAttributeException
Parameters:
aName - The name of the attribute to find
Returns:
Returns the Object value of the found attribute, otherwise null
Throws:
UnknownAttributeException

toString

public java.lang.String toString(boolean nonStandardAtts,
                                 boolean unknownAttrs)
Formats the RadiusPacket into a String


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2006 The JRadius Project, All Rights Reserved.