public abstract class RadiusServer extends Object
| 构造器和说明 |
|---|
RadiusServer() |
| 限定符和类型 | 方法和说明 |
|---|---|
RadiusPacket |
accessRequestReceived(AccessRequest accessRequest,
InetSocketAddress client)
Constructs an answer for an Access-Request packet.
|
RadiusPacket |
accountingRequestReceived(AccountingRequest accountingRequest,
InetSocketAddress client)
Constructs an answer for an Accounting-Request packet.
|
protected void |
copyProxyState(RadiusPacket request,
RadiusPacket answer)
Copies all Proxy-State attributes from the request
packet to the response packet.
|
int |
getAcctPort()
Returns the acct port the server will listen on.
|
protected DatagramSocket |
getAcctSocket()
Returns a socket bound to the acct port.
|
int |
getAuthPort()
Returns the auth port the server will listen on.
|
protected DatagramSocket |
getAuthSocket()
Returns a socket bound to the auth port.
|
long |
getDuplicateInterval()
Returns the duplicate interval in ms.
|
InetAddress |
getListenAddress()
Returns the IP address the server listens on.
|
abstract String |
getSharedSecret(InetSocketAddress client)
Returns the shared secret used to communicate with the client with the
passed IP address or null if the client is not allowed at this server.
|
int |
getSocketTimeout()
Returns the socket timeout (ms).
|
abstract String |
getUserPassword(String userName)
Returns the password of the passed user.
|
protected RadiusPacket |
handlePacket(InetSocketAddress localAddress,
InetSocketAddress remoteAddress,
RadiusPacket request,
String sharedSecret)
Handles the received Radius packet and constructs a response.
|
protected boolean |
isPacketDuplicate(RadiusPacket packet,
InetSocketAddress address)
Checks whether the passed packet is a duplicate.
|
protected void |
listen(DatagramSocket s)
Listens on the passed socket, blocks until stop() is called.
|
protected void |
listenAcct()
Listens on the acct port (blocks the current thread).
|
protected void |
listenAuth()
Listens on the auth port (blocks the current thread).
|
protected DatagramPacket |
makeDatagramPacket(RadiusPacket packet,
String secret,
InetAddress address,
int port,
RadiusPacket request)
Creates a Radius response datagram packet from a RadiusPacket to be send.
|
protected RadiusPacket |
makeRadiusPacket(DatagramPacket packet,
String sharedSecret)
Creates a RadiusPacket for a Radius request from a received
datagram packet.
|
void |
setAcctPort(int acctPort)
Sets the acct port the server will listen on.
|
void |
setAuthPort(int authPort)
Sets the auth port the server will listen on.
|
void |
setDuplicateInterval(long duplicateInterval)
Sets the duplicate interval in ms.
|
void |
setListenAddress(InetAddress listenAddress)
Sets the address the server listens on.
|
void |
setSocketTimeout(int socketTimeout)
Sets the socket timeout.
|
void |
start(boolean listenAuth,
boolean listenAcct)
Starts the Radius server.
|
void |
stop()
Stops the server and closes the sockets.
|
public abstract String getSharedSecret(InetSocketAddress client)
client - IP address and port number of clientpublic abstract String getUserPassword(String userName)
userName - user namepublic RadiusPacket accessRequestReceived(AccessRequest accessRequest, InetSocketAddress client) throws RadiusException
accessRequest - Radius request packetclient - address of Radius clientRadiusException - malformed request packet; if this
exception is thrown, no answer will be sentpublic RadiusPacket accountingRequestReceived(AccountingRequest accountingRequest, InetSocketAddress client) throws RadiusException
accountingRequest - Radius request packetclient - address of Radius clientRadiusException - malformed request packet; if this
exception is thrown, no answer will be sentpublic void start(boolean listenAuth,
boolean listenAcct)
listenAuth - open auth port?listenAcct - open acct port?public void stop()
public int getAuthPort()
public void setAuthPort(int authPort)
authPort - auth port, 1-65535public int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
throws SocketException
socketTimeout - socket timeout, >0 msSocketExceptionpublic void setAcctPort(int acctPort)
acctPort - acct port 1-65535public int getAcctPort()
public long getDuplicateInterval()
public void setDuplicateInterval(long duplicateInterval)
duplicateInterval - duplicate interval (ms), >0public InetAddress getListenAddress()
public void setListenAddress(InetAddress listenAddress)
listenAddress - listen address or nullprotected void copyProxyState(RadiusPacket request, RadiusPacket answer)
request - request packetanswer - response packetprotected void listenAuth()
throws SocketException
protected void listenAcct()
throws SocketException
protected void listen(DatagramSocket s)
s - socket to listen onprotected RadiusPacket handlePacket(InetSocketAddress localAddress, InetSocketAddress remoteAddress, RadiusPacket request, String sharedSecret) throws RadiusException, IOException
localAddress - local address the packet was received onremoteAddress - remote address the packet was sent byrequest - the packetRadiusExceptionIOExceptionprotected DatagramSocket getAuthSocket() throws SocketException
SocketExceptionprotected DatagramSocket getAcctSocket() throws SocketException
SocketExceptionprotected DatagramPacket makeDatagramPacket(RadiusPacket packet, String secret, InetAddress address, int port, RadiusPacket request) throws IOException
packet - RadiusPacketsecret - shared secret to encode packetaddress - where to send the packetport - destination portrequest - request packetIOExceptionprotected RadiusPacket makeRadiusPacket(DatagramPacket packet, String sharedSecret) throws IOException, RadiusException
packet - received datagramRadiusException - malformed packetIOException - communication error (after getRetryCount()
retries)protected boolean isPacketDuplicate(RadiusPacket packet, InetSocketAddress address)
packet - packet in questionaddress - client addressCopyright © 2016. All rights reserved.