src/main/java/org/tinyradius/proxy/RadiusProxy.java
protected void proxyPacketReceived(RadiusPacket packet, InetSocketAddress remote)
        throws IOException, RadiusException {
        // retrieve my Proxy-State attribute (the last)
        List<RadiusAttribute> proxyStates = packet.getAttributes(33);
        if (proxyStates == null || proxyStates.size() == 0) {
            throw new RadiusException("proxy packet without Proxy-State attribute");
        }
        RadiusAttribute proxyState = proxyStates.get(proxyStates.size() - 1);

        // retrieve proxy connection from cache
        String state = new String(proxyState.getAttributeData());
        RadiusProxyConnection proxyConnection = proxyConnections.remove(state);
        if (proxyConnection == null) {
            logger.warn("received packet on proxy port without saved proxy connection - duplicate?");
            return;
        }

        // retrieve client
        RadiusEndpoint client = proxyConnection.getRadiusClient();
        if (logger.isInfoEnabled()) {
            logger.info("received proxy packet: {}", packet);
            logger.info("forward packet to {} with secret {}", client.getEndpointAddress(), client.getSharedSecret());
        }

        // remove only own Proxy-State (last attribute)
        packet.removeLastAttribute(33);

        // re-encode answer packet with authenticator of the original packet
        RadiusPacket answer = new RadiusPacket(packet.getPacketType(), packet.getPacketIdentifier(), packet.getAttributes());
        DatagramPacket datagram = makeDatagramPacket(answer, client.getSharedSecret(), client.getEndpointAddress().getAddress(), client.getEndpointAddress().getPort(), proxyConnection.getPacket());

        // send back using correct socket
        DatagramSocket socket;
        if (proxyConnection.getPort() == getAuthPort()) {
            socket = getAuthSocket();
        }
        else {
            socket = getAcctSocket();
        }
        socket.send(datagram);
    }
/**
     * Sends an answer to a proxied packet back to the original host.
     * Retrieves the RadiusProxyConnection object from the cache employing
     * the Proxy-State attribute.
     *
     * @param packet packet to be sent back
     * @param remote the server the packet arrived from
     * @throws IOException
     */
Sends an answer to a proxied packet back to the original host.
Retrieves the RadiusProxyConnection object from the cache employing
the Proxy-State attribute.

@param packet packet to be sent back
@param remote the server the packet arrived from
@throws IOException
Sends an answer to a proxied packet back to the original host . Retrieves the RadiusProxyConnection object from the cache employing the Proxy - State attribute . @param packet packet to be sent back @param remote the server the packet arrived from @throws IOException
protected void proxyPacketReceived(RadiusPacket packet, InetSocketAddress remote)
        throws IOException, RadiusException {
        List<RadiusAttribute> proxyStates = packet.getAttributes(33);
        if (proxyStates == null || proxyStates.size() == 0) {
            throw new RadiusException("proxy packet without Proxy-State attribute");
        }
        RadiusAttribute proxyState = proxyStates.get(proxyStates.size() - 1);
        String state = new String(proxyState.getAttributeData());
        RadiusProxyConnection proxyConnection = proxyConnections.remove(state);
        if (proxyConnection == null) {
            logger.warn("received packet on proxy port without saved proxy connection - duplicate?");
            return;
        }
        RadiusEndpoint client = proxyConnection.getRadiusClient();
        if (logger.isInfoEnabled()) {
            logger.info("received proxy packet: {}", packet);
            logger.info("forward packet to {} with secret {}", client.getEndpointAddress(), client.getSharedSecret());
        }
        packet.removeLastAttribute(33);
        RadiusPacket answer = new RadiusPacket(packet.getPacketType(), packet.getPacketIdentifier(), packet.getAttributes());
        DatagramPacket datagram = makeDatagramPacket(answer, client.getSharedSecret(), client.getEndpointAddress().getAddress(), client.getEndpointAddress().getPort(), proxyConnection.getPacket());
        DatagramSocket socket;
        if (proxyConnection.getPort() == getAuthPort()) {
            socket = getAuthSocket();
        }
        else {
            socket = getAcctSocket();
        }
        socket.send(datagram);
    }
protected void proxyPacketReceived ( RadiusPacket packet , InetSocketAddress remote ) throws IOException , RadiusException { List < RadiusAttribute > proxyStates = packet . getAttributes ( 33 ) ; if ( proxyStates == null || proxyStates . size ( ) == 0 ) { throw new RadiusException ( "proxy packet without Proxy-State attribute" ) ; } RadiusAttribute proxyState = proxyStates . get ( proxyStates . size ( ) - 1 ) ; String state = new String ( proxyState . getAttributeData ( ) ) ; RadiusProxyConnection proxyConnection = proxyConnections . remove ( state ) ; if ( proxyConnection == null ) { logger . warn ( "received packet on proxy port without saved proxy connection - duplicate?" ) ; return ; } RadiusEndpoint client = proxyConnection . getRadiusClient ( ) ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "received proxy packet: {}" , packet ) ; logger . info ( "forward packet to {} with secret {}" , client . getEndpointAddress ( ) , client . getSharedSecret ( ) ) ; } packet . removeLastAttribute ( 33 ) ; RadiusPacket answer = new RadiusPacket ( packet . getPacketType ( ) , packet . getPacketIdentifier ( ) , packet . getAttributes ( ) ) ; DatagramPacket datagram = makeDatagramPacket ( answer , client . getSharedSecret ( ) , client . getEndpointAddress ( ) . getAddress ( ) , client . getEndpointAddress ( ) . getPort ( ) , proxyConnection . getPacket ( ) ) ; DatagramSocket socket ; if ( proxyConnection . getPort ( ) == getAuthPort ( ) ) { socket = getAuthSocket ( ) ; } else { socket = getAcctSocket ( ) ; } socket . send ( datagram ) ; }
Sends an answer to a proxied packet back to the original host.
Sends an answer to a proxied packet back to the original host .
// retrieve my Proxy-State attribute (the last)
 // retrieve proxy connection from cache
 // retrieve client
 // remove only own Proxy-State (last attribute)
 // re-encode answer packet with authenticator of the original packet
 // send back using correct socket
