|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openmdx.uses.net.sourceforge.jradiusclient.AbstractRadiusClient
org.openmdx.uses.net.sourceforge.jradiusclient.RadiusClient
public class RadiusClient
Released under the LGPL
This class provides basic functionality required to implement a NAS as
defined by the RADIUS protocol as specified in RFC 2865 and RFC 2866.
This implementation is stateless and not thread safe, i.e. since the
user name could be changed by the current thread or any other thread,
it is difficult to ensure that the responseAttributes correlate to the
request we think we are dealing with. It is up to the user of this class
to ensure these things at this point. A future release may change this class
to a stateful, threadsafe object, but it works for now. Users of this class
must also manage building their own request attributes and submitting them with
their call to authenticate. For example a programmer using this library, wanting
to do chap authentication needs to generate the random challenge, send it to
the user, who generates the MD5 of
| Field Summary | |
|---|---|
static String |
ENCODING
|
| Constructor Summary | |
|---|---|
RadiusClient(String[] hostname,
int[] authPort,
int[] acctPort,
String sharedSecret,
int sockTimeout,
boolean logging,
InetAddress nasAddress)
Constructor allows the user to specify an alternate port for the radius server |
|
RadiusClient(String hostname,
int authPort,
int acctPort,
String sharedSecret)
Constructor allows the user to specify an alternate port for the radius server |
|
RadiusClient(String hostname,
int authPort,
int acctPort,
String sharedSecret,
int sockTimeout)
Constructor allows the user to specify an alternate port for the radius server |
|
RadiusClient(String hostname,
String sharedSecret)
Constructor - uses the default port 1812 for authentication and 1813 for accounting |
|
| Method Summary | |
|---|---|
RadiusPacket |
account(RadiusPacket requestPacket)
This method performs the job of sending accounting information for the current user to the radius accounting server. |
RadiusPacket |
authenticate(RadiusPacket accessRequest)
This method performs the job of authenticating the given RadiusPacket against
the radius server. |
RadiusPacket |
authenticate(RadiusPacket accessRequest,
int retries)
This method performs the job of authenticating the given RadiusPacket against
the radius server. |
protected void |
closeSocket()
closes the socket |
boolean |
equals(Object object)
Compares the specified Object with this RadiusClient
for equality. |
void |
finalize()
overrides finalize to close socket and then normal finalize on super class |
int[] |
getAcctPort()
This method returns the current port to be used for accounting |
int[] |
getAuthPort()
This method returns the current port to be used for authentication |
InetAddress[] |
getHostname()
Get the host names |
protected byte[] |
getSharedSecret()
This method returns the current secret value that the Radius Client shares with the RADIUS Server. |
int |
getTimeout()
This method returns the current timeout period on a recieve of a response from the RADIUS Server. |
int |
hashCode()
|
String |
toString()
This method returns a string representation of this RadiusClient. |
| Methods inherited from class org.openmdx.uses.net.sourceforge.jradiusclient.AbstractRadiusClient |
|---|
logDebug, logDebug, logWarning |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ENCODING
| Constructor Detail |
|---|
public RadiusClient(String hostname,
String sharedSecret)
throws RadiusException,
InvalidParameterException
hostname - java.lang.StringsharedSecret - java.lang.String
SocketException - If we could not create the necessary socket
NoSuchAlgorithmException - If we could not get an
instance of the MD5 algorithm.
InvalidParameterException - If an invalid hostname
(null or empty string), an invalid port
(port < 0 or port > 65536) or an invalid
shared secret (null, shared secret can be
empty string) is passed in.
RadiusException
public RadiusClient(String hostname,
int authPort,
int acctPort,
String sharedSecret)
throws RadiusException,
InvalidParameterException
hostname - java.lang.StringauthPort - int the port to use for authentication requestsacctPort - int the port to use for accounting requestssharedSecret - java.lang.String
SocketException - If we could not create the necessary socket
NoSuchAlgorithmException - If we could not get an
instance of the MD5 algorithm.
InvalidParameterException - If an invalid hostname
(null or empty string), an invalid
port ( port < 0 or port > 65536)
or an invalid shared secret (null, shared
secret can be empty string) is passed in.
RadiusException
public RadiusClient(String hostname,
int authPort,
int acctPort,
String sharedSecret,
int sockTimeout)
throws RadiusException,
InvalidParameterException
hostname - java.lang.StringauthPort - int the port to use for authentication requestsacctPort - int the port to use for accounting requestssharedSecret - java.lang.Stringtimeout - int the timeout to use when waiting for return packets can't be neg and shouldn't be zero
RadiusException - If we could not create the necessary socket,
If we could not get an instance of the MD5 algorithm, or the hostname did not pass validation
InvalidParameterException - If an invalid hostname
(null or empty string), an invalid
port ( port < 0 or port > 65536)
or an invalid shared secret (null, shared
secret can be empty string) is passed in.
public RadiusClient(String[] hostname,
int[] authPort,
int[] acctPort,
String sharedSecret,
int sockTimeout,
boolean logging,
InetAddress nasAddress)
throws RadiusException,
InvalidParameterException
hostname - java.lang.StringauthPort - int the port to use for authentication requestsacctPort - int the port to use for accounting requestssharedSecret - java.lang.Stringlogging - Defines whether logging is enabled or disablednasAddress - timeout - int the timeout to use when waiting for return packets can't be neg and shouldn't be zero
RadiusException - If we could not create the necessary socket,
If we could not get an instance of the MD5 algorithm, or the hostname did not pass validation
InvalidParameterException - If an invalid hostname
(null or empty string), an invalid
port ( port < 0 or port > 65536)
or an invalid shared secret (null, shared
secret can be empty string) is passed in.| Method Detail |
|---|
public RadiusPacket authenticate(RadiusPacket accessRequest)
throws RadiusException,
InvalidParameterException
RadiusPacket against
the radius server.
RadiusPacket - containing all of the RadiusAttributes for this request. This
RadiusPacket must include the USER_NAME attribute and be of type ACCEES_REQUEST.
If the USER_PASSWORD attribute is set it must contain the plaintext bytes, we will encode the
plaintext to send to the server with a REVERSIBLE algorithm. We will set the NAS_IDENTIFIER
Attribute, so even if it is set in the RadiusPacket we will overwrite it
RadiusException
InvalidParameterException
public RadiusPacket authenticate(RadiusPacket accessRequest,
int retries)
throws RadiusException,
InvalidParameterException
RadiusPacket against
the radius server.
RadiusPacket - containing all of the RadiusAttributes for this request. This
RadiusPacket must include the USER_NAME attribute and be of type ACCEES_REQUEST.
If the USER_PASSWORD attribute is set it must contain the plaintext bytes, we will encode the
plaintext to send to the server with a REVERSIBLE algorithm. We will set the NAS_IDENTIFIER
Attribute, so even if it is set in the RadiusPacket we will overwrite itint - retries must be zero or greater, if it is zero default value of 3 will be used
RadiusException
InvalidParameterException
public RadiusPacket account(RadiusPacket requestPacket)
throws InvalidParameterException,
RadiusException
requestPacket - Any request attributes to add to the accounting packet.
RadiusException
InvalidParameterExceptionpublic InetAddress[] getHostname()
public int[] getAuthPort()
public int[] getAcctPort()
protected byte[] getSharedSecret()
public int getTimeout()
public String toString()
RadiusClient.
toString in class Objectpublic boolean equals(Object object)
RadiusClient
for equality. Returns true if the given object is also a
RadiusClient and the two RadiusClient
have the same host, port, sharedSecret & username.
equals in class Objectobject - Object to be compared for equality with this
RadiusClient.
RadiusClient.public int hashCode()
hashCode in class ObjectRadiusClientprotected void closeSocket()
public void finalize()
throws Throwable
finalize in class ObjectThrowable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||