net.jradius.freeradius
Class FreeRadiusFormat
java.lang.Object
net.jradius.packet.Format
net.jradius.packet.RadiusFormat
net.jradius.freeradius.FreeRadiusFormat
public class FreeRadiusFormat
- extends RadiusFormat
Packs and Unpacks Radius Packets and Attributes for the FreeRADIUS Server.
- Author:
- David Bird
Method Summary |
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,
RadiusPacket p,
int attributesLength,
String sharedSecret)
|
void |
packPacket(RadiusPacket packet,
String sharedSecret,
ByteBuffer buffer,
boolean onWire)
Packs a RadiusPacket into a byte array |
static void |
setAttributeBytes(RadiusPacket p,
ByteBuffer buffer,
int length)
|
void |
unpackAttributeHeader(ByteBuffer buffer,
Format.AttributeParseContext ctx)
|
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 |
FreeRadiusFormat
public FreeRadiusFormat()
setAttributeBytes
public static void setAttributeBytes(RadiusPacket p,
ByteBuffer buffer,
int length)
- See Also:
public static void setAttributeBytes(RadiusPacket p, byte[] bAttributes)
{
int attributesLength = bAttributes.length;
if (attributesLength > 0)
{
staticFormat.unpackAttributes(p.getAttributes(), bAttributes, 0, attributesLength);
}
}
packAttribute
public void packAttribute(ByteBuffer buffer,
RadiusAttribute a)
- Description copied from class:
RadiusFormat
- Packs a RadiusAttribute into a DataOutputStream
- Overrides:
packAttribute
in class RadiusFormat
a
- The RadiusAttribute to pack
packHeader
public void packHeader(ByteBuffer buffer,
RadiusPacket p,
int attributesLength,
String sharedSecret)
- See Also:
public void packHeader(OutputStream out, RadiusPacket p, byte[] attributeBytes, String sharedSecret) throws IOException
{
writeUnsignedInt(out, p.getCode());
writeUnsignedInt(out, p.getIdentifier());
writeUnsignedInt(out, attributeBytes == null ? 0 : attributeBytes.length);
}
packPacket
public void packPacket(RadiusPacket packet,
String sharedSecret,
ByteBuffer buffer,
boolean onWire)
throws IOException
- Description copied from class:
RadiusFormat
- Packs a RadiusPacket into a byte array
- Overrides:
packPacket
in class RadiusFormat
- Parameters:
packet
- The RadiusPacket to pack
- Throws:
IOException
packHeader
public void packHeader(ByteBuffer buffer,
RadiusAttribute a)
- Description copied from class:
RadiusFormat
- Packs a RadiusAttribute header into a DataOutputStream
- Overrides:
packHeader
in class RadiusFormat
a
- The RadiusAttribute to pack- See Also:
public void packHeader(OutputStream out, RadiusAttribute a) throws IOException
{
AttributeValue attributeValue = a.getValue();
writeUnsignedInt(out, a.getFormattedType());
writeUnsignedInt(out, attributeValue.getLength());
writeUnsignedInt(out, a.getAttributeOp());
}
unpackAttributeHeader
public void unpackAttributeHeader(ByteBuffer buffer,
Format.AttributeParseContext ctx)
throws IOException
- Overrides:
unpackAttributeHeader
in class RadiusFormat
- Throws:
IOException
- See Also:
public int unpackAttributeHeader(InputStream in, AttributeParseContext ctx) throws IOException
{
ctx.attributeType = readUnsignedInt(in);
ctx.attributeLength = readUnsignedInt(in);
ctx.attributeOp = readUnsignedInt(in);
if (ctx.attributeType > (1 << 16))
{
// FreeRADIUS encodes the vendor number in the type
// with: if (vendor) attr->attr |= (vendor << 16);
ctx.vendorNumber = (int)((ctx.attributeType >> 16) & 0xffff);
ctx.attributeType &= 0xffff;
}
return 12;
}
Copyright © 2011 Coova Technologies, LLC, All Rights Reserved.