org.openmdx.uses.net.sourceforge.jradiusclient
Class RadiusPacket

java.lang.Object
  extended by org.openmdx.uses.net.sourceforge.jradiusclient.RadiusPacket
Direct Known Subclasses:
AccountingRequest, ChapAccessRequest, PapAccessRequest

public class RadiusPacket
extends Object

Released under the LGPL

Version:
$Revision: 1.5 $
Author:
Robert J. Loihl

Field Summary
static int ACCESS_ACCEPT
           
static int ACCESS_CHALLENGE
           
static int ACCESS_REJECT
           
static int ACCESS_REQUEST
           
static int ACCOUNTING_MESSAGE
           
static int ACCOUNTING_REQUEST
           
static int ACCOUNTING_RESPONSE
           
static int ACCOUNTING_STATUS
           
static String EMPTYSTRING
           
static int MAX_PACKET_LENGTH
           
static int MIN_PACKET_LENGTH
           
static int PASSWORD_ACCEPT
           
static int PASSWORD_REJECT
           
static int PASSWORD_REQUEST
           
static short RADIUS_HEADER_LENGTH
          RADIUS_HEADER_LENGTH is 20 bytes (corresponding to 1 byte for code + 1 byte for Identifier + 2 bytes for Length + 16 bytes for Request Authenticator) It is not a coincidence that it is the same as the MIN_PACKET_LENGTH
static int RESERVED
           
static int STATUS_CLIENT
           
static int STATUS_SERVER
           
 
Constructor Summary
RadiusPacket(int type)
          builds a type RadiusPacket with no Attributes set
RadiusPacket(int type, byte identifier)
           
RadiusPacket(int type, byte identifier, int socketIndex)
          Constructor
RadiusPacket(int type, byte identifier, List attributeList)
          Builds a RadiusPacket with a predefined set of attributes
RadiusPacket(int type, List attributeList)
          Builds a RadiusPacket with a predefined set of attributes
 
Method Summary
 RadiusAttribute getAttribute(int attributeType)
          retrieve a RadiusAttribute from this RadiusPacket
protected  byte[] getAttributeBytes()
          get the byte array
protected  byte[] getAttributeBytes(int[] order)
          get the byte array
 Collection getAttributes()
          get all of the RadiusAttributes in this RadiusPacket
 byte getPacketIdentifier()
          Return the packetIdentifier for this RadiusPacket.
 byte getPacketType()
          get the packet type for this RadiusPacket
 int getSocketIndex()
          Get the provider's index
 void setAttribute(RadiusAttribute radiusAttribute)
          Adds a RadiusAttribute to this RadiusPacket
 void setAttributes(List attributeList)
          Add a set of RadiusAttributes to this RadiusPacket
protected  void setSocketIndex(int socketIndex)
          Set the provider's index
protected  void validateAttribute(RadiusAttribute attribute)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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
RADIUS_HEADER_LENGTH is 20 bytes (corresponding to 1 byte for code + 1 byte for Identifier + 2 bytes for Length + 16 bytes for Request Authenticator) It is not a coincidence that it is the same as the MIN_PACKET_LENGTH

See Also:
Constant Field Values

EMPTYSTRING

public static final String EMPTYSTRING
See Also:
Constant Field Values

ACCESS_REQUEST

public static final int ACCESS_REQUEST
See Also:
Constant Field Values

ACCESS_ACCEPT

public static final int ACCESS_ACCEPT
See Also:
Constant Field Values

ACCESS_REJECT

public static final int ACCESS_REJECT
See Also:
Constant Field Values

ACCOUNTING_REQUEST

public static final int ACCOUNTING_REQUEST
See Also:
Constant Field Values

ACCOUNTING_RESPONSE

public static final int ACCOUNTING_RESPONSE
See Also:
Constant Field Values

ACCOUNTING_STATUS

public static final int ACCOUNTING_STATUS
See Also:
Constant Field Values

PASSWORD_REQUEST

public static final int PASSWORD_REQUEST
See Also:
Constant Field Values

PASSWORD_ACCEPT

public static final int PASSWORD_ACCEPT
See Also:
Constant Field Values

PASSWORD_REJECT

public static final int PASSWORD_REJECT
See Also:
Constant Field Values

ACCOUNTING_MESSAGE

public static final int ACCOUNTING_MESSAGE
See Also:
Constant Field Values

ACCESS_CHALLENGE

public static final int ACCESS_CHALLENGE
See Also:
Constant Field Values

STATUS_SERVER

public static final int STATUS_SERVER
See Also:
Constant Field Values

STATUS_CLIENT

public static final int STATUS_CLIENT
See Also:
Constant Field Values

RESERVED

public static final int RESERVED
See Also:
Constant Field Values
Constructor Detail

RadiusPacket

public RadiusPacket(int type)
             throws InvalidParameterException
builds a type RadiusPacket with no Attributes set

Parameters:
type - int a PacketType to send.
Throws:
InvalidParameterException - if the attributeList is null or contains non-RadiusAttribute type entries

RadiusPacket

public RadiusPacket(int type,
                    byte identifier)
             throws InvalidParameterException
Parameters:
type -
identifier -
Throws:
InvalidParameterException

RadiusPacket

public RadiusPacket(int type,
                    byte identifier,
                    int socketIndex)
             throws InvalidParameterException
Constructor

Parameters:
type -
identifier -
socketIndex -
Throws:
InvalidParameterException

RadiusPacket

public RadiusPacket(int type,
                    List attributeList)
             throws InvalidParameterException
Builds a RadiusPacket with a predefined set of attributes

Parameters:
type - int a PacketType to send.
attributeList - a list of RadiusAttribute objects to initialize this RadiusPacket with
Throws:
InvalidParameterException - if the attributeList is null or contains non-RadiusAttribute type entries

RadiusPacket

public RadiusPacket(int type,
                    byte identifier,
                    List attributeList)
             throws InvalidParameterException
Builds a RadiusPacket with a predefined set of attributes

Parameters:
type -
identifier -
attributeList -
Throws:
InvalidParameterException
Method Detail

setAttribute

public void setAttribute(RadiusAttribute radiusAttribute)
                  throws InvalidParameterException
Adds a RadiusAttribute to this RadiusPacket

Parameters:
radiusAttribute - A RadiusAttribute to set on this RadiusPacket
Throws:
InvalidParameterException - if the parameter radiusAttribute was null

setAttributes

public void setAttributes(List attributeList)
                   throws InvalidParameterException
Add a set of RadiusAttributes to this RadiusPacket

Parameters:
attributeList - a list of RadiusAttribute objects to add to this RadiusPacket
Throws:
InvalidParameterException - if the attributeList is null or contains non-RadiusAttribute type entries

validateAttribute

protected void validateAttribute(RadiusAttribute attribute)
                          throws InvalidParameterException
Throws:
InvalidParameterException

getAttribute

public RadiusAttribute getAttribute(int attributeType)
                             throws InvalidParameterException,
                                    RadiusException
retrieve a RadiusAttribute from this RadiusPacket

Parameters:
attributeType - an integer between 0 and 256 (i.e. a byte) from the list of Radius constants in net.sourceforge.jradiusclient.RadiusValues
Returns:
a single RadiusAttribute from the RadiusPacket
Throws:
RadiusException - if no attribute of type attributeType is stored in this RadiusPacket
InvalidParameterException - if the attributeType is not between 0 and 256 (i.e. a byte)

getAttributes

public Collection getAttributes()
get all of the RadiusAttributes in this RadiusPacket

Returns:
a java.util.Collection of RadiusAttributes

getPacketType

public byte getPacketType()
get the packet type for this RadiusPacket

Returns:
packet type for this RadiusPacket

getPacketIdentifier

public byte getPacketIdentifier()
Return the packetIdentifier for this RadiusPacket. This can be used to match request packets to response packets

Returns:
the packet identifier for this object.

getAttributeBytes

protected final byte[] getAttributeBytes()
                                  throws RadiusException
get the byte array

Returns:
a byte array of the raw bytes for all of the RadiusAttributes assigned to this RadiusPacket
Throws:
RadiusException - If there is any error assembling the bytes into a byte array

getAttributeBytes

protected final byte[] getAttributeBytes(int[] order)
                                  throws RadiusException
get the byte array

Returns:
a byte array of the raw bytes for all of the RadiusAttributes assigned to this RadiusPacket
Throws:
RadiusException - If there is any error assembling the bytes into a byte array

setSocketIndex

protected void setSocketIndex(int socketIndex)
Set the provider's index

Parameters:
socketIndex -

getSocketIndex

public int getSocketIndex()
Get the provider's index

Returns:
the provider's index; or -1 if none has been set


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.