/** * Radius command line client. * <br/>Usage: TestClient <i>hostName sharedSecret userName password</i> * @param args arguments * @throws Exception */ public static void main(String[] args) { if (args.Length != 4) { System.Console.WriteLine("Usage: TestClient hostName sharedSecret userName password"); return; } String host = args[0]; String shared = args[1]; String user = args[2]; String pass = args[3]; var rc = new RadiusClient(IPAddress.Parse(host), shared); // 1. Send Access-Request var ar = new AccessRequest(user, pass); ar.AuthProtocol = AuthenticationType.pap; // or AUTH_CHAP ar.AddAttribute("NAS-Identifier", "this.is.my.nas-identifier.de"); ar.AddAttribute("NAS-IP-Address", "192.168.0.100"); ar.AddAttribute("Service-Type", "Login-User"); ar.AddAttribute("WISPr-Redirection-URL", "http://www.sourceforge.net/"); ar.AddAttribute("WISPr-Location-ID", "net.sourceforge.ap1"); System.Console.WriteLine("Packet before it is sent\n" + ar + "\n"); RadiusPacket response = rc.Authenticate(ar); System.Console.WriteLine("Packet after it was sent\n" + ar + "\n"); System.Console.WriteLine("Response\n" + response + "\n"); // 2. Send Accounting-Request var acc = new AccountingRequest("mw", AccountingRequest.ACCT_STATUS_TYPE_START); acc.AddAttribute("Acct-Session-Id", "1234567890"); acc.AddAttribute("NAS-Identifier", "this.is.my.nas-identifier.de"); acc.AddAttribute("NAS-Port", "0"); System.Console.WriteLine(acc + "\n"); response = rc.Account(acc); System.Console.WriteLine("Response: " + response); rc.Close(); }
/** * Sends the specified packet to the specified Radius server endpoint. * @param remoteServer Radius endpoint consisting of server address, * port number and shared secret * @param request Radius packet to be sent * @return received response packet * @throws RadiusException malformed packet * @throws IOException error while communication */ public static RadiusPacket Communicate(RadiusEndpoint remoteServer, RadiusPacket request) { var rc = new RadiusClient(remoteServer.EndpointAddress.Address, remoteServer.SharedSecret); return rc.Communicate(request, remoteServer.EndpointAddress.Port); }
/** * Sends the specified packet to the specified Radius server endpoint. * @param remoteServer Radius endpoint consisting of server address, * port number and shared secret * @param request Radius packet to be sent * @return received response packet * @throws RadiusException malformed packet * @throws IOException error while communication */ public static RadiusPacket Communicate(RadiusEndpoint remoteServer, RadiusPacket request) { var rc = new RadiusClient(remoteServer.EndpointAddress.Address, remoteServer.SharedSecret); return(rc.Communicate(request, remoteServer.EndpointAddress.Port)); }