Hi.
Is there anyway to generate a message authenticator for an
accounting request packet. At the moment I am using JRadius, I need to send an
accounting request message to another radius server. However after I add the
message authenticator and send to to another server, the other server complains
about “Invalid message authenticator” (Shared secret is
incorrect).
Here is some code :
//Proxy request to the wap gateway
DatagramSocket
socket = new DatagramSocket();
socket.setSoTimeout(5000);
//Generate
authenticator
MessageDigest
md5 = MessageDigest.getInstance("MD5");
md5.reset();
md5.update((byte)req.getCode());
md5.update((byte)req.getIdentifier());
int length =
req.getBytes().length;
byte []
authenticator = req.getAuthenticator();
byte []
attributeBytes = req.getAttributeBytes(req.getAttributes(),0);
for (int z=0; z
<authenticator.length ; z++ )
RadiusLog.debug("Autenticator["+z+"]
Before = " + authenticator[z]);
RadiusLog.debug("Autenticator Length: " + authenticator.length);
RadiusLog.debug("Attributes Length: " + attributeBytes.length);
RadiusLog.debug("Paket Length: " + length);
String
sharedSecret = "testing123";
md5.update((byte)(length >> 8));
md5.update((byte)(length & 0xff));
md5.update(authenticator, 0, authenticator.length);
md5.update(attributeBytes,
0, attributeBytes.length);
md5.update(sharedSecret.getBytes());
req.overwriteAttribute(AttributeFactory.newAttribute(AttributeDictionary.MESSAGE_AUTHENTICATOR,
authenticator));
System.arraycopy(md5.digest(), 0, authenticator, 0, 16);