net.jradius.client
Class RadiusClient

java.lang.Object
  extended by net.jradius.client.RadiusClient
Direct Known Subclasses:
RadiusMultiClient

public class RadiusClient
extends Object

A Radius Client Context

Author:
David Bird

Field Summary
protected static LinkedHashMap<String,Class<?>> authenticators
           
protected  JRadiusSession session
           
protected  RadiusClientTransport transport
           
 
Constructor Summary
RadiusClient()
          Default constructor
RadiusClient(DatagramSocket socket)
           
RadiusClient(DatagramSocket socket, InetAddress address, String secret)
           
RadiusClient(DatagramSocket socket, InetAddress address, String secret, int authPort, int acctPort, int timeout)
           
RadiusClient(InetAddress address, String secret)
          RadiusClient constructor
RadiusClient(InetAddress address, String secret, int authPort, int acctPort, int timeout)
          RadiusClient constructor
RadiusClient(RadiusClientTransport transport)
           
 
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.
 CoAResponse changeOfAuth(CoARequest p, int retries)
           
 void close()
           
 DisconnectResponse disconnect(DisconnectRequest p, int retries)
           
 int getAcctPort()
           
 int getAuthPort()
           
static RadiusAuthenticator getAuthProtocol(String protocolName)
          Get a supported RadiusAuthenticator based on the protocol name.
 InetAddress getLocalInetAddress()
           
 InetAddress getRemoteInetAddress()
           
 String getSharedSecret()
           
 int getSocketTimeout()
           
static void registerAuthenticator(String name, Class<?> c)
          Registration of supported RadiusAuthenticator protocols
static void registerAuthenticator(String name, String className)
           
 void send(RadiusRequest p)
           
 RadiusResponse sendReceive(RadiusRequest p, int retries)
           
 void setAcctPort(int acctPort)
           
 void setAuthPort(int authPort)
           
 void setLocalInetAddress(InetAddress localInetAddress)
           
 void setRemoteInetAddress(InetAddress remoteInetAddress)
           
 void setSharedSecret(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

transport

protected RadiusClientTransport transport

authenticators

protected static final LinkedHashMap<String,Class<?>> authenticators

session

protected JRadiusSession session
Constructor Detail

RadiusClient

public RadiusClient()
             throws IOException
Default constructor

Throws:
IOException

RadiusClient

public RadiusClient(DatagramSocket socket)

RadiusClient

public RadiusClient(RadiusClientTransport transport)

RadiusClient

public RadiusClient(InetAddress address,
                    String secret)
             throws IOException
RadiusClient constructor

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

RadiusClient

public RadiusClient(DatagramSocket socket,
                    InetAddress address,
                    String secret)

RadiusClient

public RadiusClient(InetAddress address,
                    String secret,
                    int authPort,
                    int acctPort,
                    int timeout)
             throws IOException
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:
IOException
RadiusException

RadiusClient

public RadiusClient(DatagramSocket socket,
                    InetAddress address,
                    String secret,
                    int authPort,
                    int acctPort,
                    int timeout)
             throws SocketException
Throws:
SocketException
Method Detail

close

public void close()

registerAuthenticator

public static void registerAuthenticator(String name,
                                         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(String name,
                                         String className)
                                  throws ClassNotFoundException
Throws:
ClassNotFoundException

getAuthProtocol

public static RadiusAuthenticator getAuthProtocol(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

sendReceive

public RadiusResponse sendReceive(RadiusRequest p,
                                  int retries)
                           throws RadiusException
Throws:
RadiusException

send

public void send(RadiusRequest p)
          throws Exception
Throws:
Exception

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

disconnect

public DisconnectResponse disconnect(DisconnectRequest p,
                                     int retries)
                              throws RadiusException
Throws:
RadiusException

changeOfAuth

public CoAResponse changeOfAuth(CoARequest p,
                                int retries)
                         throws RadiusException
Throws:
RadiusException

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 InetAddress getRemoteInetAddress()
Returns:
Returns the remote server IP Address

setRemoteInetAddress

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

getLocalInetAddress

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

setLocalInetAddress

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

getSharedSecret

public String getSharedSecret()
Returns:
Returns the shared secret

setSharedSecret

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


Copyright © 2011 Coova Technologies, LLC, All Rights Reserved.