class POP3BeforeSMTPHandler implements ConnectHandler<SMTPSession>, Configurable {

    @Override
    public Response onConnect(SMTPSession session) {

        // some kind of random cleanup process
        if (Math.random() > 0.99) {
            POP3BeforeSMTPHelper.removeExpiredIP(expireTime);
        }

        // Check if the ip is allowed to relay
        if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().getHostAddress())) {
            session.setRelayingAllowed(true);
        }
        return null;
    }

}