public class RadiusClient extends Object
| 构造器和说明 |
|---|
RadiusClient(RadiusEndpoint client)
Constructs a Radius client for the given Radius endpoint.
|
RadiusClient(String hostName,
String sharedSecret)
Creates a new Radius client object for a special Radius server.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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(String userName,
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.
|
String |
getHostName()
Returns the host name of the Radius server.
|
int |
getRetryCount()
Returns the retry count for failed transmissions.
|
String |
getSharedSecret()
Returns the secret shared between server and client.
|
protected DatagramSocket |
getSocket()
Returns the socket used for the server communication.
|
int |
getSocketTimeout()
Returns the socket timeout.
|
protected DatagramPacket |
makeDatagramPacket(RadiusPacket packet,
int port)
Creates a datagram packet from a RadiusPacket to be send.
|
protected RadiusPacket |
makeRadiusPacket(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(String hostName)
Sets the host name of the Radius server.
|
void |
setRetryCount(int retryCount)
Sets the retry count for failed transmissions.
|
void |
setSharedSecret(String sharedSecret)
Sets the secret shared between server and client.
|
void |
setSocketTimeout(int socketTimeout)
Sets the socket timeout
|
public RadiusClient(String hostName, String sharedSecret)
hostName - host name of the Radius serversharedSecret - shared secret used to secure the communicationpublic RadiusClient(RadiusEndpoint client)
client - Radius endpointpublic boolean authenticate(String userName, String password) throws IOException, RadiusException
userName - user namepassword - passwordRadiusException - malformed packetIOException - communication error (after getRetryCount()
retries)public RadiusPacket authenticate(AccessRequest request) throws IOException, RadiusException
request - request packetRadiusException - malformed packetIOException - communication error (after getRetryCount()
retries)public RadiusPacket account(AccountingRequest request) throws IOException, RadiusException
request - request packetRadiusException - malformed packetIOException - communication error (after getRetryCount()
retries)public void close()
public int getAuthPort()
public void setAuthPort(int authPort)
authPort - auth port, 1-65535public String getHostName()
public void setHostName(String hostName)
hostName - host namepublic int getRetryCount()
public void setRetryCount(int retryCount)
retryCount - retry count, >0public String getSharedSecret()
public void setSharedSecret(String sharedSecret)
sharedSecret - shared secretpublic int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
throws SocketException
socketTimeout - timeout, ms, >0SocketExceptionpublic void setAcctPort(int acctPort)
acctPort - acct port, 1-65535public int getAcctPort()
public RadiusPacket communicate(RadiusPacket request, int port) throws IOException, RadiusException
request - packet to be sentport - server port numberRadiusException - malformed packetIOException - communication error (after getRetryCount()
retries)public static RadiusPacket communicate(RadiusEndpoint remoteServer, RadiusPacket request) throws RadiusException, IOException
remoteServer - Radius endpoint consisting of server address,
port number and shared secretrequest - Radius packet to be sentRadiusException - malformed packetIOException - error while communicationprotected DatagramSocket getSocket() throws SocketException
SocketExceptionprotected DatagramPacket makeDatagramPacket(RadiusPacket packet, int port) throws IOException
packet - RadiusPacketport - destination port numberIOExceptionprotected RadiusPacket makeRadiusPacket(DatagramPacket packet, RadiusPacket request) throws IOException, RadiusException
packet - received datagramrequest - Radius request packetIOExceptionRadiusExceptionCopyright © 2016. All rights reserved.