net.sf.jradius.packet
Class RadiusFormat

java.lang.Object
  extended by net.sf.jradius.packet.RadiusFormat
Direct Known Subclasses:
DiameterFormat, FreeRadiusFormat

public class RadiusFormat
extends java.lang.Object

Default RadiusPacket/RadiusAttribute format class. This class formats and parses UDP RADIUS Packets. Derived classes implement other formats.

Author:
David Bird

Nested Class Summary
protected  class RadiusFormat.AttributeParseContext
           
 
Field Summary
static int VSA_HEADER_LENGTH
           
 
Constructor Summary
RadiusFormat()
           
 
Method Summary
static RadiusFormat getInstance()
           
 void packAttribute(java.io.OutputStream out, RadiusAttribute a)
          Packs a RadiusAttribute into a DataOutputStream
 byte[] packAttributeList(AttributeList attrs)
          Packs an AttributeList into a byte array
 void packHeader(java.io.OutputStream out, RadiusAttribute a)
          Packs a RadiusAttribute header into a DataOutputStream
 void packHeader(java.io.OutputStream out, RadiusPacket p, byte[] attributeBytes)
          Packs the RadiusPacket into a DataOutputStream
 void packHeader(java.io.OutputStream out, VSAttribute a)
          Packs a VSAttribute header into a DataOutputStream
 byte[] packPacket(RadiusPacket packet)
          Packs a RadiusPacket into a byte array
static int readUnsignedByte(java.io.InputStream in)
           
static long readUnsignedInt(java.io.InputStream in)
           
static int readUnsignedShort(java.io.InputStream in)
           
static void setAttributeBytes(RadiusPacket packet, byte[] bAttributes)
          Parses attributes and places them in a RadiusPacket
protected  int unpackAttributeHeader(java.io.InputStream in, RadiusFormat.AttributeParseContext ctx)
          Unpacks the header of a RadiusAttribute from a DataInputStream
 void unpackAttributes(AttributeList attrs, byte[] bytes, int bLength)
          Unpacks RadiusAttributes from a byte array into an AttributeList
static void writeUnsignedByte(java.io.OutputStream out, int b)
           
static void writeUnsignedInt(java.io.OutputStream out, long i)
           
static void writeUnsignedShort(java.io.OutputStream out, int s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VSA_HEADER_LENGTH

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

RadiusFormat

public RadiusFormat()
Method Detail

getInstance

public static RadiusFormat getInstance()
Returns:
Returns a static instnace of this class

setAttributeBytes

public static void setAttributeBytes(RadiusPacket packet,
                                     byte[] bAttributes)
Parses attributes and places them in a RadiusPacket

Parameters:
packet - The RadiusPacket to parse attributes into
bAttributes - The attribute bytes to parse

packPacket

public byte[] packPacket(RadiusPacket packet)
Packs a RadiusPacket into a byte array

Parameters:
packet - The RadiusPacket to pack
Returns:
Returns the packed RadiusPacket

packAttributeList

public byte[] packAttributeList(AttributeList attrs)
Packs an AttributeList into a byte array

Parameters:
attrs - The AttributeList to pack
Returns:
Returns the packed AttributeList

packAttribute

public void packAttribute(java.io.OutputStream out,
                          RadiusAttribute a)
                   throws java.io.IOException
Packs a RadiusAttribute into a DataOutputStream

Parameters:
out - The DataOutputStream to write attibutes to
a - The RadiusAttribute to pack
Throws:
java.io.IOException

packHeader

public void packHeader(java.io.OutputStream out,
                       RadiusPacket p,
                       byte[] attributeBytes)
                throws java.io.IOException
Packs the RadiusPacket into a DataOutputStream

Parameters:
out - The DataOutputStream to write to
p - The RadiusPacket to pack
attributeBytes - The RadiusPacket attributes
Throws:
java.io.IOException

packHeader

public void packHeader(java.io.OutputStream out,
                       RadiusAttribute a)
                throws java.io.IOException
Packs a RadiusAttribute header into a DataOutputStream

Parameters:
out - The DataOutputStream to write to
a - The RadiusAttribute to pack
Throws:
java.io.IOException

packHeader

public void packHeader(java.io.OutputStream out,
                       VSAttribute a)
                throws java.io.IOException
Packs a VSAttribute header into a DataOutputStream

Parameters:
out - The DataOutputStream to write to
a - The VSAttribute to pack
Throws:
java.io.IOException

unpackAttributes

public void unpackAttributes(AttributeList attrs,
                             byte[] bytes,
                             int bLength)
Unpacks RadiusAttributes from a byte array into an AttributeList

Parameters:
attrs - The AttributeList to put unpacked attributes
bytes - The bytes to be unpacked
bLength - The length of the bytes to be unpacked

unpackAttributeHeader

protected int unpackAttributeHeader(java.io.InputStream in,
                                    RadiusFormat.AttributeParseContext ctx)
                             throws java.io.IOException
Unpacks the header of a RadiusAttribute from a DataInputStream

Parameters:
in - The DataInputStream to read from
ctx - The Attribute Parser Context
Returns:
Returns the additional offset length for this header
Throws:
java.io.IOException

readUnsignedInt

public static long readUnsignedInt(java.io.InputStream in)
                            throws java.io.IOException
Throws:
java.io.IOException

readUnsignedShort

public static int readUnsignedShort(java.io.InputStream in)
                             throws java.io.IOException
Throws:
java.io.IOException

readUnsignedByte

public static int readUnsignedByte(java.io.InputStream in)
                            throws java.io.IOException
Throws:
java.io.IOException

writeUnsignedByte

public static void writeUnsignedByte(java.io.OutputStream out,
                                     int b)
                              throws java.io.IOException
Throws:
java.io.IOException

writeUnsignedShort

public static void writeUnsignedShort(java.io.OutputStream out,
                                      int s)
                               throws java.io.IOException
Throws:
java.io.IOException

writeUnsignedInt

public static void writeUnsignedInt(java.io.OutputStream out,
                                    long i)
                             throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2006 The JRadius Project, All Rights Reserved.