Radius with Java

Peter Lambrechtsen plambrechtsen at gmail.com
Tue Jan 3 09:01:57 CET 2012

On Thu, Dec 22, 2011 at 3:08 PM, <jeissonfabian.pr at gmail.com> wrote:

> Yeah,
> I found a lot of problems with JRadius, and tried TinyRadius, it's easy!
> And It didn't present any problem.
> Thanks!

I use this BeanShell script (www.beanshell.org) which allows for Java code
to be executed from the command line without needing to be complied:  Easy
for remote server testing multi-platform without needing radclient and just
java installed on the remote end.

java -cp bsh-2.0b4.jar:TinyRadius-1.0.jar:commons-logging-1.1.1.jar
bsh.Interpreter radius.bsh

import org.tinyradius.util.*;
import org.tinyradius.packet.*;

String radiusHost         = "";
String radiusSharedSecret = "sharedsecret";
String radiusUser         = "user";
String radiusPassword     = "password";

RadiusClient rc = new RadiusClient(radiusHost, radiusSharedSecret);
AccessRequest ar = new AccessRequest(radiusUser, radiusPassword);

try {
   RadiusPacket response = rc.authenticate(ar);
   if (response.getPacketType() == RadiusPacket.ACCESS_ACCEPT) {
      msg = "Success: Expected radius response";
   else {
      msg = "Warning: RADIUS authentication did not return expected
response " + response.getPacketType();
catch(Exception e) {
   msg = "Error: RADIUS authentication failed " + e ;

print (msg);
---end beanshell script---


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20120103/d65e3110/attachment.html>

More information about the Freeradius-Users mailing list