Package org.tinyradius.server.handler
Class ProxyRequestHandler
- java.lang.Object
-
- org.tinyradius.server.handler.ProxyRequestHandler
-
- All Implemented Interfaces:
RequestHandler<RadiusPacket,SecretProvider>
public abstract class ProxyRequestHandler extends java.lang.Object implements RequestHandler<RadiusPacket,SecretProvider>
RadiusServer handler that proxies packets to destination.Depends on RadiusClient to proxy packets.
RadiusClient port should be set to proxy port, which will be used to communicate with upstream servers. RadiusClient should also use a variant of
ProxyStateClientHandler
which matches requests/responses by adding a custom Proxy-State attribute.This implementation expects
getProxyServer(RadiusPacket, RadiusEndpoint)
to lookup endpoint to forward requests to.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProxyRequestHandler(RadiusClient radiusClient)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract RadiusEndpoint
getProxyServer(RadiusPacket packet, RadiusEndpoint client)
This method must be implemented to return a RadiusEndpoint if the given packet is to be proxied.io.netty.util.concurrent.Promise<RadiusPacket>
handlePacket(io.netty.channel.Channel channel, RadiusPacket request, java.net.InetSocketAddress remoteAddress, SecretProvider secretProvider)
Proxies the given packet to the server given in the proxy connection.protected RadiusPacket
handleServerResponse(Dictionary dictionary, RadiusPacket packet)
Sends an answer to a proxied packet back to the original host.
-
-
-
Constructor Detail
-
ProxyRequestHandler
protected ProxyRequestHandler(RadiusClient radiusClient)
-
-
Method Detail
-
getProxyServer
public abstract RadiusEndpoint getProxyServer(RadiusPacket packet, RadiusEndpoint client)
This method must be implemented to return a RadiusEndpoint if the given packet is to be proxied. The endpoint represents the Radius server the packet should be proxied to.- Parameters:
packet
- the packet in questionclient
- the client endpoint the packet originated from (containing the address, port number and shared secret)- Returns:
- a RadiusEndpoint or null if the packet should not be proxied
-
handlePacket
public io.netty.util.concurrent.Promise<RadiusPacket> handlePacket(io.netty.channel.Channel channel, RadiusPacket request, java.net.InetSocketAddress remoteAddress, SecretProvider secretProvider)
Proxies the given packet to the server given in the proxy connection. Stores the proxy connection object in the cache with a key that is added to the packet in the "Proxy-State" attribute.- Specified by:
handlePacket
in interfaceRequestHandler<RadiusPacket,SecretProvider>
- Parameters:
channel
- socket which received packetrequest
- incoming packet, can be RadiusPacket or subclassremoteAddress
- remote address the packet was sent bysecretProvider
- shared secret associated with remoteAddress- Returns:
- Promise of RadiusPacket or null for no response. Uses Promise instead Future, so requests to be timed out or cancelled by the caller
-
handleServerResponse
protected RadiusPacket handleServerResponse(Dictionary dictionary, RadiusPacket packet)
Sends an answer to a proxied packet back to the original host. Retrieves the RadiusProxyConnection object from the cache employing the Proxy-State attribute.- Parameters:
dictionary
- dictionary for new packet to usepacket
- response received from server- Returns:
- packet to send back to client
-
-