|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.tinyradius.util.RadiusServer
public abstract class RadiusServer
Implements a simple Radius server. This class must be subclassed to provide an implementation for getSharedSecret() and getUserPassword(). If the server supports accounting, it must override accountingRequestReceived().
Constructor Summary | |
---|---|
RadiusServer()
|
Method Summary | |
---|---|
RadiusPacket |
accessRequestReceived(AccessRequest accessRequest,
java.net.InetSocketAddress client)
Constructs an answer for an Access-Request packet. |
RadiusPacket |
accountingRequestReceived(AccountingRequest accountingRequest,
java.net.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 java.net.DatagramSocket |
getAcctSocket()
Returns a socket bound to the acct port. |
int |
getAuthPort()
Returns the auth port the server will listen on. |
protected java.net.DatagramSocket |
getAuthSocket()
Returns a socket bound to the auth port. |
long |
getDuplicateInterval()
Returns the duplicate interval in ms. |
java.net.InetAddress |
getListenAddress()
Returns the IP address the server listens on. |
abstract java.lang.String |
getSharedSecret(java.net.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 java.lang.String |
getUserPassword(java.lang.String userName)
Returns the password of the passed user. |
protected RadiusPacket |
handlePacket(java.net.InetSocketAddress localAddress,
java.net.InetSocketAddress remoteAddress,
RadiusPacket request,
java.lang.String sharedSecret)
Handles the received Radius packet and constructs a response. |
protected boolean |
isPacketDuplicate(RadiusPacket packet,
java.net.InetSocketAddress address)
Checks whether the passed packet is a duplicate. |
protected void |
listen(java.net.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 java.net.DatagramPacket |
makeDatagramPacket(RadiusPacket packet,
java.lang.String secret,
java.net.InetAddress address,
int port,
RadiusPacket request)
Creates a Radius response datagram packet from a RadiusPacket to be send. |
protected RadiusPacket |
makeRadiusPacket(java.net.DatagramPacket packet,
java.lang.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(java.net.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RadiusServer()
Method Detail |
---|
public abstract java.lang.String getSharedSecret(java.net.InetSocketAddress client)
client
- IP address and port number of client
public abstract java.lang.String getUserPassword(java.lang.String userName)
userName
- user name
public RadiusPacket accessRequestReceived(AccessRequest accessRequest, java.net.InetSocketAddress client) throws RadiusException
accessRequest
- Radius request packetclient
- address of Radius client
RadiusException
- malformed request packet; if this
exception is thrown, no answer will be sentpublic RadiusPacket accountingRequestReceived(AccountingRequest accountingRequest, java.net.InetSocketAddress client) throws RadiusException
accountingRequest
- Radius request packetclient
- address of Radius client
RadiusException
- 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 java.net.SocketException
socketTimeout
- socket timeout, >0 ms
java.net.SocketException
public void setAcctPort(int acctPort)
acctPort
- acct port 1-65535public int getAcctPort()
public long getDuplicateInterval()
public void setDuplicateInterval(long duplicateInterval)
duplicateInterval
- duplicate interval (ms), >0public java.net.InetAddress getListenAddress()
public void setListenAddress(java.net.InetAddress listenAddress)
listenAddress
- listen address or nullprotected void copyProxyState(RadiusPacket request, RadiusPacket answer)
request
- request packetanswer
- response packetprotected void listenAuth() throws java.net.SocketException
java.net.SocketException
java.lang.InterruptedException
protected void listenAcct() throws java.net.SocketException
java.net.SocketException
java.lang.InterruptedException
protected void listen(java.net.DatagramSocket s)
s
- socket to listen onprotected RadiusPacket handlePacket(java.net.InetSocketAddress localAddress, java.net.InetSocketAddress remoteAddress, RadiusPacket request, java.lang.String sharedSecret) throws RadiusException, java.io.IOException
localAddress
- local address the packet was received onremoteAddress
- remote address the packet was sent byrequest
- the packet
RadiusException
java.io.IOException
protected java.net.DatagramSocket getAuthSocket() throws java.net.SocketException
java.net.SocketException
protected java.net.DatagramSocket getAcctSocket() throws java.net.SocketException
java.net.SocketException
protected java.net.DatagramPacket makeDatagramPacket(RadiusPacket packet, java.lang.String secret, java.net.InetAddress address, int port, RadiusPacket request) throws java.io.IOException
packet
- RadiusPacketsecret
- shared secret to encode packetaddress
- where to send the packetport
- destination portrequest
- request packet
java.io.IOException
protected RadiusPacket makeRadiusPacket(java.net.DatagramPacket packet, java.lang.String sharedSecret) throws java.io.IOException, RadiusException
packet
- received datagram
RadiusException
- malformed packet
java.io.IOException
- communication error (after getRetryCount()
retries)protected boolean isPacketDuplicate(RadiusPacket packet, java.net.InetSocketAddress address)
packet
- packet in questionaddress
- client address
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |