RADIUS Client API (V3)

com.theorem.radius3.radutil
Class FailOverRADIUSClient

Object
  extended byFailOverRADIUSClient

public class FailOverRADIUSClient
extends Object

Class to perform fail-over RADIUS client requests.

A list of remote servers, their secrets, and any special attributes supply the class with fail-over servers.


Nested Class Summary
 class FailOverRADIUSClient.ServerData
          Inner class to hold server list.
 
Field Summary
static String AUTH_CHAP
          CHAP authentication.
static String AUTH_EAPMD5
          EAPMD5 authentication.
static String AUTH_MSCHAP
          MSCHAP authentication.
static String AUTH_MSCHAP2
          MSCHAP V2 authentication.
static String AUTH_PAP
          PAP authentication.
 
Constructor Summary
FailOverRADIUSClient()
          Default constructor.
 
Method Summary
 int accounting()
          Perform accounting.
 void addServer(InetAddress server, int authPort, int acctPort, String secret, AttributeList serverAttributeList)
          Add a server to the list of fail over servers.
 void addServer(InetAddress server, String secret, AttributeList serverAttributeList)
          Add a server to the list of fail over servers.
 void allowEmptyAttributes(boolean enable)
          Permit or refuse empty attributes.
 int authenticate()
          Perform the authentication.
 AttributeList getAttributes()
          Retrieve any attributes returned by the response.
 String getErrorMessage()
          Get the error message associated with the success()
 InetAddress getRespondingServer()
          Get the last responding server.
 FailOverRADIUSClient.ServerData getRespondingServerData()
          Get the responding server information.
static void main(String[] arg)
          Main test of the class.
 Iterator serverIterator()
          Get all server inforamtion.
 void setAttributes(AttributeList alist)
          Set the attributes necessary for this authentication or accounting.
 void setAuthenticationType(String type)
          Set the authentication type, one of PAP, CHAP, MSCHAP, MSCHAPV2, and EAPMD5.
 void setDebug(boolean enable)
          Enable or disable debugging.
 void setName(String name)
          Set the name of the entity being authenticated or accounted.
 void setPassword(byte[] password)
          Set the password to be used with authentication.
 void setPassword(String password)
          Set the password to be used with authentication.
 void setTimeout(int timeout)
          Set the RADIUS client timeout.
 boolean success()
          Determine if the authentication or accounting succeeded.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTH_PAP

public static final String AUTH_PAP
PAP authentication.

See Also:
Constant Field Values

AUTH_CHAP

public static final String AUTH_CHAP
CHAP authentication.

See Also:
Constant Field Values

AUTH_MSCHAP

public static final String AUTH_MSCHAP
MSCHAP authentication.

See Also:
Constant Field Values

AUTH_MSCHAP2

public static final String AUTH_MSCHAP2
MSCHAP V2 authentication.

See Also:
Constant Field Values

AUTH_EAPMD5

public static final String AUTH_EAPMD5
EAPMD5 authentication.

See Also:
Constant Field Values
Constructor Detail

FailOverRADIUSClient

public FailOverRADIUSClient()
Default constructor.

Method Detail

addServer

public void addServer(InetAddress server,
                      String secret,
                      AttributeList serverAttributeList)
               throws Exception
Add a server to the list of fail over servers.

The default ports are the standard 1812 for authentication and 1813 for accounting. If your server uses obsolete ports they will probably be 1645 and 1646 respectively.

Parameters:
server - Server address.
secret - Server secret.
serverAttributeList - List of server specific attributes. This may be empty or null.
Throws:
Exception - if either the server or secret are null.

addServer

public void addServer(InetAddress server,
                      int authPort,
                      int acctPort,
                      String secret,
                      AttributeList serverAttributeList)
               throws Exception
Add a server to the list of fail over servers.

The default ports are the standard 1812 for authentication and 1813 for accounting. If your server uses obsolete ports they will probably be 1645 and 1646 respectively.

Parameters:
server - Server address.
authPort - The UDP port number for authentication. A value of 0 uses the standard port number 1812.
acctPort - The UDP port number for accounting. A value of 0 uses the standard port number 1813.
secret - Server secret.
serverAttributeList - List of server specific attributes. This may be empty or null.
Throws:
Exception - if either the server or secret are null.

setTimeout

public void setTimeout(int timeout)
Set the RADIUS client timeout. If the server doesn't get a response in the given time the next server is tried.

Parameters:
timeout - Timeout in milliseconds.

setDebug

public void setDebug(boolean enable)
Enable or disable debugging.

Parameters:
enable - True to enable debugging, false to disable debugging.

allowEmptyAttributes

public void allowEmptyAttributes(boolean enable)
Permit or refuse empty attributes.

An empty attribute is one with a tag and a length of 0. The RADIUS rfc does not permit empty attributes to be sent or received. Some implementations break this rule. If you find that empty attributes are acceptable enable them.

Parameters:
enable - True to support empty attributes. The default to to disable them.

setAttributes

public void setAttributes(AttributeList alist)
Set the attributes necessary for this authentication or accounting. This list is used in conjunction with attributes set specifically for each server (if any).

Parameters:
alist - Attribute list.

getAttributes

public AttributeList getAttributes()
Retrieve any attributes returned by the response.

Returns:
Response attributes. This may be empty.

setName

public void setName(String name)
Set the name of the entity being authenticated or accounted.

Parameters:
name - Entity name.

setPassword

public void setPassword(byte[] password)
Set the password to be used with authentication.

Parameters:
password - Password.

setPassword

public void setPassword(String password)
Set the password to be used with authentication.

Parameters:
password - Password.

setAuthenticationType

public void setAuthenticationType(String type)
                           throws Exception
Set the authentication type, one of PAP, CHAP, MSCHAP, MSCHAPV2, and EAPMD5.

Parameters:
type - Authentication type as a string. Not setting any authentication type or choosing an authentication method that implies CHAP or PAP voids the effect of this method.
Throws:
Exception - if the authentication type is unknown.

authenticate

public int authenticate()
Perform the authentication.

Returns:
the packet type. E.g. Access-Accept, Access-Reject, &c. The result may also be -1 (nothing done) if there are no servers configured.

accounting

public int accounting()
Perform accounting.

Returns:
the packet type. E.g. Accounting_Response.

success

public boolean success()
Determine if the authentication or accounting succeeded. This will be a true or false result indicating that either one server responded or no servers responded.

Returns:
True if a server responded, false if no servers responded and there were errors. See getRespondingServer() to determine which server responded.

getErrorMessage

public String getErrorMessage()
Get the error message associated with the success()

Returns:
error string.

getRespondingServer

public InetAddress getRespondingServer()
Get the last responding server. This may be the server that performed an authentication or the last server in the list that failed it's authentication or accounting.

Returns:
responding server address.

getRespondingServerData

public FailOverRADIUSClient.ServerData getRespondingServerData()
Get the responding server information.

Returns:
responding server information or null if there is no responding server.

serverIterator

public Iterator serverIterator()
Get all server inforamtion.

The servers will be returned as the class FailOverRADIUSClient.ServerData.

Returns:
an Iteration of servers in the order they sent requests.

main

public static void main(String[] arg)
Main test of the class.


RADIUS Client API (V3)

Submit a bug report or feature request

Copyright 1998-2008 AXL Software. PO Box 97, Viola, Delaware 19979, U.S.A. All Rights Reserved.