|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.tinyradius.util.RadiusClient
public class RadiusClient
This object represents a simple Radius client which communicates with a specified Radius server. You can use a single instance of this object to authenticate or account different users with the same Radius server as long as you authenticate/account one user after the other. This object is thread safe, but only opens a single socket so operations using this socket are synchronized to avoid confusion with the mapping of request and result packets.
Constructor Summary | |
---|---|
RadiusClient(RadiusEndpoint client)
Constructs a Radius client for the given Radius endpoint. |
|
RadiusClient(java.lang.String hostName,
java.lang.String sharedSecret)
Creates a new Radius client object for a special Radius server. |
Method Summary | |
---|---|
RadiusPacket |
account(AccountingRequest request)
Sends an Accounting-Request packet and receives a response packet. |
RadiusPacket |
authenticate(AccessRequest request)
Sends an Access-Request packet and receives a response packet. |
boolean |
authenticate(java.lang.String userName,
java.lang.String password)
Authenticates a user. |
void |
close()
Closes the socket of this client. |
static RadiusPacket |
communicate(RadiusEndpoint remoteServer,
RadiusPacket request)
Sends the specified packet to the specified Radius server endpoint. |
RadiusPacket |
communicate(RadiusPacket request,
int port)
Sends a Radius packet to the server and awaits an answer. |
int |
getAcctPort()
Returns the Radius server accounting port. |
int |
getAuthPort()
Returns the Radius server auth port. |
java.lang.String |
getHostName()
Returns the host name of the Radius server. |
int |
getRetryCount()
Returns the retry count for failed transmissions. |
java.lang.String |
getSharedSecret()
Returns the secret shared between server and client. |
protected java.net.DatagramSocket |
getSocket()
Returns the socket used for the server communication. |
int |
getSocketTimeout()
Returns the socket timeout. |
protected java.net.DatagramPacket |
makeDatagramPacket(RadiusPacket packet,
int port)
Creates a datagram packet from a RadiusPacket to be send. |
protected RadiusPacket |
makeRadiusPacket(java.net.DatagramPacket packet,
RadiusPacket request)
Creates a RadiusPacket from a received datagram packet. |
void |
setAcctPort(int acctPort)
Sets the Radius server accounting port. |
void |
setAuthPort(int authPort)
Sets the auth port of the Radius server. |
void |
setHostName(java.lang.String hostName)
Sets the host name of the Radius server. |
void |
setRetryCount(int retryCount)
Sets the retry count for failed transmissions. |
void |
setSharedSecret(java.lang.String sharedSecret)
Sets the secret shared between server and client. |
void |
setSocketTimeout(int socketTimeout)
Sets the socket timeout |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RadiusClient(java.lang.String hostName, java.lang.String sharedSecret)
hostName
- host name of the Radius serversharedSecret
- shared secret used to secure the communicationpublic RadiusClient(RadiusEndpoint client)
client
- Radius endpointMethod Detail |
---|
public boolean authenticate(java.lang.String userName, java.lang.String password) throws java.io.IOException, RadiusException
userName
- user namepassword
- password
RadiusException
- malformed packet
java.io.IOException
- communication error (after getRetryCount()
retries)public RadiusPacket authenticate(AccessRequest request) throws java.io.IOException, RadiusException
request
- request packet
RadiusException
- malformed packet
java.io.IOException
- communication error (after getRetryCount()
retries)public RadiusPacket account(AccountingRequest request) throws java.io.IOException, RadiusException
request
- request packet
RadiusException
- malformed packet
java.io.IOException
- communication error (after getRetryCount()
retries)public void close()
public int getAuthPort()
public void setAuthPort(int authPort)
authPort
- auth port, 1-65535public java.lang.String getHostName()
public void setHostName(java.lang.String hostName)
hostName
- host namepublic int getRetryCount()
public void setRetryCount(int retryCount)
retryCount
- retry count, >0public java.lang.String getSharedSecret()
public void setSharedSecret(java.lang.String sharedSecret)
sharedSecret
- shared secretpublic int getSocketTimeout()
public void setSocketTimeout(int socketTimeout) throws java.net.SocketException
socketTimeout
- timeout, ms, >0
java.net.SocketException
public void setAcctPort(int acctPort)
acctPort
- acct port, 1-65535public int getAcctPort()
public RadiusPacket communicate(RadiusPacket request, int port) throws java.io.IOException, RadiusException
request
- packet to be sentport
- server port number
RadiusException
- malformed packet
java.io.IOException
- communication error (after getRetryCount()
retries)public static RadiusPacket communicate(RadiusEndpoint remoteServer, RadiusPacket request) throws RadiusException, java.io.IOException
remoteServer
- Radius endpoint consisting of server address,
port number and shared secretrequest
- Radius packet to be sent
RadiusException
- malformed packet
java.io.IOException
- error while communicationprotected java.net.DatagramSocket getSocket() throws java.net.SocketException
java.net.SocketException
protected java.net.DatagramPacket makeDatagramPacket(RadiusPacket packet, int port) throws java.io.IOException
packet
- RadiusPacketport
- destination port number
java.io.IOException
protected RadiusPacket makeRadiusPacket(java.net.DatagramPacket packet, RadiusPacket request) throws java.io.IOException, RadiusException
packet
- received datagramrequest
- Radius request packet
java.io.IOException
RadiusException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |