|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jradius.packet.Format
net.jradius.packet.RadiusFormat
public class RadiusFormat
Default RadiusPacket/RadiusAttribute format class. This class formats and parses UDP RADIUS Packets. Derived classes implement other formats.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.jradius.packet.Format |
---|
Format.AttributeParseContext |
Field Summary | |
---|---|
static int |
VSA_HEADER_LENGTH
|
Constructor Summary | |
---|---|
RadiusFormat()
|
Method Summary | |
---|---|
static RadiusFormat |
getInstance()
|
int |
headerLength(RadiusAttribute a)
|
int |
headerLength(VSAttribute a)
Packs a VSAttribute header into a DataOutputStream |
void |
packAttribute(ByteBuffer buffer,
RadiusAttribute a)
Packs a RadiusAttribute into a DataOutputStream |
void |
packHeader(ByteBuffer buffer,
RadiusAttribute a)
Packs a RadiusAttribute header into a DataOutputStream |
void |
packHeader(ByteBuffer buffer,
RadiusAttribute a,
int valueLength)
|
void |
packHeader(ByteBuffer buffer,
RadiusPacket p,
byte[] attributeBytes,
int offset,
int attributesLength,
String sharedSecret)
Packs the RadiusPacket into a DataOutputStream |
void |
packHeader(ByteBuffer buffer,
VSAttribute a)
|
void |
packHeader(ByteBuffer buffer,
VSAttribute a,
int len)
|
void |
packPacket(RadiusPacket packet,
String sharedSecret,
ByteBuffer buffer,
boolean onWire)
Packs a RadiusPacket into a byte array |
static void |
setAttributeBytes(RadiusPacket packet,
ByteBuffer buffer,
int length)
Parses attributes and places them in a RadiusPacket |
void |
unpackAttributeHeader(ByteBuffer buffer,
Format.AttributeParseContext ctx)
|
void |
unpackAttributeHeader(InputStream in,
Format.AttributeParseContext ctx)
Unpacks the header of a RadiusAttribute from a DataInputStream |
Methods inherited from class net.jradius.packet.Format |
---|
getUnsignedByte, getUnsignedByte, getUnsignedInt, getUnsignedInt, getUnsignedShort, getUnsignedShort, packAttributeList, packAttributes, putUnsignedByte, putUnsignedByte, putUnsignedInt, putUnsignedInt, putUnsignedShort, putUnsignedShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, unpackAttributes, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int VSA_HEADER_LENGTH
Constructor Detail |
---|
public RadiusFormat()
Method Detail |
---|
public static RadiusFormat getInstance()
public static void setAttributeBytes(RadiusPacket packet, ByteBuffer buffer, int length)
packet
- The RadiusPacket to parse attributes intobAttributes
- The attribute bytes to parsepublic void packPacket(RadiusPacket packet, String sharedSecret, ByteBuffer buffer, boolean onWire) throws IOException
packet
- The RadiusPacket to pack
IOException
public void packHeader(ByteBuffer buffer, RadiusPacket p, byte[] attributeBytes, int offset, int attributesLength, String sharedSecret) throws IOException
out
- The DataOutputStream to write top
- The RadiusPacket to packattributeBytes
- The RadiusPacket attributes
IOException
- public void packHeader(OutputStream out, RadiusPacket p, byte[] attributeBytes, String sharedSecret) throws IOException
{
int length = attributeBytes.length + RadiusPacket.RADIUS_HEADER_LENGTH;
writeUnsignedByte(out, p.getCode());
writeUnsignedByte(out, p.getIdentifier());
writeUnsignedShort(out, length);
out.write(p.getAuthenticator(attributeBytes, sharedSecret));
}public void packAttribute(ByteBuffer buffer, RadiusAttribute a)
packAttribute
in class Format
out
- The DataOutputStream to write attributes toa
- The RadiusAttribute to pack
IOException
- public void packAttribute(OutputStream out, RadiusAttribute a) throws IOException
{
AttributeValue attributeValue = a.getValue();
packHeader(out, a);
attributeValue.getBytes(out);
}public void packHeader(ByteBuffer buffer, RadiusAttribute a)
out
- The DataOutputStream to write toa
- The RadiusAttribute to pack
IOException
- public void packHeader(OutputStream out, RadiusAttribute a) throws IOException
{
if (a instanceof VSAttribute)
{
packHeader(out, (VSAttribute)a);
return;
}
AttributeValue attributeValue = a.getValue();
writeUnsignedByte(out, (int) a.getType());
writeUnsignedByte(out, attributeValue.getLength() + HEADER_LENGTH);
}public void packHeader(ByteBuffer buffer, RadiusAttribute a, int valueLength)
public int headerLength(VSAttribute a)
out
- The DataOutputStream to write toa
- The VSAttribute to pack
IOException
- public void packHeader(OutputStream out, VSAttribute a) throws IOException
{
AttributeValue attributeValue = a.getValue();
int len = attributeValue.getLength();
int vsaHeader = VSA_HEADER_LENGTH;
if (a.hasContinuationByte()) vsaHeader ++;
writeUnsignedByte(out, (int)a.getType());
writeUnsignedByte(out, len + vsaHeader);
writeUnsignedInt(out, a.getVendorId());
writeUnsignedByte(out, (int)a.getVsaAttributeType());
len += 2;
if (a.hasContinuationByte()) len ++;
switch(a.getLengthLength())
{
case 1:
writeUnsignedByte(out, len);
break;
case 2:
writeUnsignedShort(out, len);
break;
case 4:
writeUnsignedInt(out, len);
break;
}
if (a.hasContinuationByte())
{
writeUnsignedByte(out, a.getContinuation());
}
}public int headerLength(RadiusAttribute a)
public void packHeader(ByteBuffer buffer, VSAttribute a)
public void packHeader(ByteBuffer buffer, VSAttribute a, int len)
public void unpackAttributeHeader(InputStream in, Format.AttributeParseContext ctx) throws IOException
in
- The DataInputStream to read fromctx
- The Attribute Parser Context
IOException
public void unpackAttributeHeader(ByteBuffer buffer, Format.AttributeParseContext ctx) throws IOException
unpackAttributeHeader
in class Format
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |