net.sf.jradius.client
Class RadiusClient

java.lang.Object
  extended by net.sf.jradius.client.RadiusClient

public class RadiusClient
extends java.lang.Object

A Radius Client Context

Author:
David Bird

Field Summary
protected  int acctPort
           
protected static java.util.LinkedHashMap authenticators
           
protected  int authPort
           
protected  java.net.InetAddress remoteInetAddress
           
protected  JRadiusSession session
           
protected  java.lang.String sharedSecret
           
protected  java.net.DatagramSocket socket
           
protected  int socketTimeout
           
 
Constructor Summary
RadiusClient()
          Default constructor
RadiusClient(java.net.InetAddress address, java.lang.String secret)
          RadiusClient constructor
RadiusClient(java.net.InetAddress address, java.lang.String secret, int authPort, int acctPort, int timeout)
          RadiusClient constructor
 
Method Summary
 AccountingResponse accounting(AccountingRequest p, int retries)
          Send an accounting request
 RadiusResponse authenticate(AccessRequest p, RadiusAuthenticator auth, int retries)
          Authenicates using the specified method.
 int getAcctPort()
           
 int getAuthPort()
           
static RadiusAuthenticator getAuthProtocol(java.lang.String protocolName)
          Get a supported RadiusAuthenticator based on the protocol name.
 java.net.InetAddress getLocalInetAddress()
           
 java.security.MessageDigest getMD()
           
 java.net.InetAddress getRemoteInetAddress()
           
 java.lang.String getSharedSecret()
           
 int getSocketTimeout()
           
protected  RadiusResponse receive()
           
static void registerAuthenticator(java.lang.String name, java.lang.Class c)
          Registration of supported RadiusAuthenticator protocols
static void registerAuthenticator(java.lang.String name, java.lang.String className)
           
protected  void send(RadiusPacket p, java.net.InetAddress a, int port, int attempt)
           
 RadiusResponse sendReceive(RadiusRequest p, java.net.InetAddress a, int port, int retries)
          Send and receive RadiusPackets
 void setAcctPort(int acctPort)
           
 void setAuthPort(int authPort)
           
 void setLocalInetAddress(java.net.InetAddress localInetAddress)
           
 void setRemoteInetAddress(java.net.InetAddress remoteInetAddress)
           
 void setSharedSecret(java.lang.String sharedSecret)
           
 void setSocketTimeout(int socketTimeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

remoteInetAddress

protected java.net.InetAddress remoteInetAddress

sharedSecret

protected java.lang.String sharedSecret

authPort

protected int authPort

acctPort

protected int acctPort

socketTimeout

protected int socketTimeout

socket

protected java.net.DatagramSocket socket

session

protected JRadiusSession session

authenticators

protected static final java.util.LinkedHashMap authenticators
Constructor Detail

RadiusClient

public RadiusClient()
Default constructor


RadiusClient

public RadiusClient(java.net.InetAddress address,
                    java.lang.String secret)
RadiusClient constructor

Parameters:
address - The Internet address to send to
secret - Our shared secret
Throws:
RadiusException

RadiusClient

public RadiusClient(java.net.InetAddress address,
                    java.lang.String secret,
                    int authPort,
                    int acctPort,
                    int timeout)
RadiusClient constructor

Parameters:
address - The Internet address to send to
secret - Our shared secret
authPort - The authentication port
acctPort - The accounting port
timeout - Timeout (time to wait for a reply)
Throws:
RadiusException
Method Detail

registerAuthenticator

public static void registerAuthenticator(java.lang.String name,
                                         java.lang.Class c)
Registration of supported RadiusAuthenticator protocols

Parameters:
name - The authentication protocol name
c - The RadiusAuthenticator class that implements the protocol

registerAuthenticator

public static void registerAuthenticator(java.lang.String name,
                                         java.lang.String className)
                                  throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

getAuthProtocol

public static RadiusAuthenticator getAuthProtocol(java.lang.String protocolName)
Get a supported RadiusAuthenticator based on the protocol name. If no protocol with that name is supported, null is returned. If the authenticator class for the named protocol has writable bean properties, these can be set by appending a colon separated list of property=value pairs to the protocolName. For instance, the EAP-TLS (and EAP-TTLS since it derives from EAP-TLS) authenticator class has numerous configurable properties (including keyFile, keyFileType, keyPassword, etc).

Examples:

Keep in mind that Java 1.5 is required for EAP-TLS/TTLS and only PAP is usable as the inner protocol because of limitations of Java 1.5.

Parameters:
protocolName - The requested authentication protocol
Returns:
Returns an instance of RadiusAuthenticator or null

authenticate

public RadiusResponse authenticate(AccessRequest p,
                                   RadiusAuthenticator auth,
                                   int retries)
                            throws RadiusException,
                                   UnknownAttributeException
Authenicates using the specified method. For all methods, it is assumed that the user's password can be found in the User-Password attribute. All authentiation requests automatically contain the Message-Authenticator attribute.

Parameters:
p - RadiusPacket to be send (should be AccessRequest)
auth - The RadiusAuthenticator instance (if null, PAPAuthenticator is used)
retries - Number of times to retry (without response)
Returns:
Returns the reply RadiusPacket
Throws:
RadiusException
UnknownAttributeException

accounting

public AccountingResponse accounting(AccountingRequest p,
                                     int retries)
                              throws RadiusException
Send an accounting request

Parameters:
p - The RadiusPacket to be sent (should be AccountingRequest)
retries - Number of times to retry (without a response)
Returns:
Returns the reply RadiusPacket
Throws:
RadiusException
UnknownAttributeException

sendReceive

public RadiusResponse sendReceive(RadiusRequest p,
                                  java.net.InetAddress a,
                                  int port,
                                  int retries)
                           throws RadiusException
Send and receive RadiusPackets

Parameters:
p - The RadiusPacket being sent
a - The Internet Address sending to
port - The port sending to
retries - Number of times to retry (without response)
Returns:
Returns the returned RadiusPacket
Throws:
RadiusException

send

protected void send(RadiusPacket p,
                    java.net.InetAddress a,
                    int port,
                    int attempt)
             throws java.io.IOException
Throws:
java.io.IOException

receive

protected RadiusResponse receive()
                          throws java.io.IOException,
                                 RadiusException
Throws:
java.io.IOException
RadiusException

getMD

public java.security.MessageDigest getMD()
Returns:
Returns the MD5 MessageDigest being used

getAcctPort

public int getAcctPort()
Returns:
Returns the RADIUS accounting port

setAcctPort

public void setAcctPort(int acctPort)
Parameters:
acctPort - The RADIUS accounting port

getAuthPort

public int getAuthPort()
Returns:
Returns the RADIUS authentication port

setAuthPort

public void setAuthPort(int authPort)
Parameters:
authPort - The RADIUS authentication port

getSocketTimeout

public int getSocketTimeout()
Returns:
Returns the socket timeout (in seconds)

setSocketTimeout

public void setSocketTimeout(int socketTimeout)
Parameters:
socketTimeout - The socket timeout (in seconds)

getRemoteInetAddress

public java.net.InetAddress getRemoteInetAddress()
Returns:
Returns the remote server IP Address

setRemoteInetAddress

public void setRemoteInetAddress(java.net.InetAddress remoteInetAddress)
Parameters:
remoteInetAddress - The remote server IP Address

getLocalInetAddress

public java.net.InetAddress getLocalInetAddress()
Returns:
Returns the local IP Address (bind address)

setLocalInetAddress

public void setLocalInetAddress(java.net.InetAddress localInetAddress)
Parameters:
localInetAddress - The local IP Address to bind to

getSharedSecret

public java.lang.String getSharedSecret()
Returns:
Returns the shared secret

setSharedSecret

public void setSharedSecret(java.lang.String sharedSecret)
Parameters:
sharedSecret - The shared secret to set


Copyright © 2006 The JRadius Project, All Rights Reserved.