src/main/java/org/tinyradius/util/RadiusServer.java
protected boolean isPacketDuplicate(RadiusPacket packet, InetSocketAddress address) {
        long now = System.currentTimeMillis();
        long intervalStart = now - getDuplicateInterval();

        byte[] authenticator = packet.getAuthenticator();

        synchronized (receivedPackets) {
            for (Iterator<ReceivedPacket> i = receivedPackets.iterator(); i.hasNext(); ) {
                ReceivedPacket p = i.next();
                if (p.receiveTime < intervalStart) {
                    // packet is older than duplicate interval
                    i.remove();
                }
                else {
                    if (p.address.equals(address) && p.packetIdentifier == packet.getPacketIdentifier()) {
                        if (authenticator != null && p.authenticator != null) {
                            // packet is duplicate if stored authenticator is equal
                            // to the packet authenticator
                            return Arrays.equals(p.authenticator, authenticator);
                        }
                        else {
                            // should not happen, packet is duplicate
                            return true;
                        }
                    }
                }
            }

            // add packet to receive list
            ReceivedPacket rp = new ReceivedPacket();
            rp.address = address;
            rp.packetIdentifier = packet.getPacketIdentifier();
            rp.receiveTime = now;
            rp.authenticator = authenticator;
            receivedPackets.add(rp);
        }

        return false;
    }
/**
     * Checks whether the passed packet is a duplicate.
     * A packet is duplicate if another packet with the same identifier
     * has been sent from the same host in the last time.
     *
     * @param packet  packet in question
     * @param address client address
     * @return true if it is duplicate
     */
Checks whether the passed packet is a duplicate.
A packet is duplicate if another packet with the same identifier
has been sent from the same host in the last time.

@param packet  packet in question
@param address client address
@return true if it is duplicate
Checks whether the passed packet is a duplicate . A packet is duplicate if another packet with the same identifier has been sent from the same host in the last time . @param packet packet in question @param address client address @return true if it is duplicate
protected boolean isPacketDuplicate(RadiusPacket packet, InetSocketAddress address) {
        long now = System.currentTimeMillis();
        long intervalStart = now - getDuplicateInterval();
        byte[] authenticator = packet.getAuthenticator();
        synchronized (receivedPackets) {
            for (Iterator<ReceivedPacket> i = receivedPackets.iterator(); i.hasNext(); ) {
                ReceivedPacket p = i.next();
                if (p.receiveTime < intervalStart) {
                    i.remove();
                }
                else {
                    if (p.address.equals(address) && p.packetIdentifier == packet.getPacketIdentifier()) {
                        if (authenticator != null && p.authenticator != null) {
                            return Arrays.equals(p.authenticator, authenticator);
                        }
                        else {
                            return true;
                        }
                    }
                }
            }
            ReceivedPacket rp = new ReceivedPacket();
            rp.address = address;
            rp.packetIdentifier = packet.getPacketIdentifier();
            rp.receiveTime = now;
            rp.authenticator = authenticator;
            receivedPackets.add(rp);
        }
        return false;
    }
protected boolean isPacketDuplicate ( RadiusPacket packet , InetSocketAddress address ) { long now = System . currentTimeMillis ( ) ; long intervalStart = now - getDuplicateInterval ( ) ; byte [ ] authenticator = packet . getAuthenticator ( ) ; synchronized ( receivedPackets ) { for ( Iterator < ReceivedPacket > i = receivedPackets . iterator ( ) ; i . hasNext ( ) ; ) { ReceivedPacket p = i . next ( ) ; if ( p . receiveTime < intervalStart ) { i . remove ( ) ; } else { if ( p . address . equals ( address ) && p . packetIdentifier == packet . getPacketIdentifier ( ) ) { if ( authenticator != null && p . authenticator != null ) { return Arrays . equals ( p . authenticator , authenticator ) ; } else { return true ; } } } } ReceivedPacket rp = new ReceivedPacket ( ) ; rp . address = address ; rp . packetIdentifier = packet . getPacketIdentifier ( ) ; rp . receiveTime = now ; rp . authenticator = authenticator ; receivedPackets . add ( rp ) ; } return false ; }
Checks whether the passed packet is a duplicate.
Checks whether the passed packet is a duplicate .
// packet is older than duplicate interval
 // packet is duplicate if stored authenticator is equal
 // to the packet authenticator
 // should not happen, packet is duplicate
 // add packet to receive list
