public static boolean isAllowed( Connection connection )
    {
        try
        {
            final byte[] address = connection.getAddress();

            // Blacklist takes precedence over whitelist.
            if (IpUtils.isAddressInAnyOf(address, blockedIPs)) {
                return false;
            }

            // When there's a whitelist (not empty), you must be on it to be allowed.
            return allowedIPs.isEmpty() || IpUtils.isAddressInAnyOf(address, allowedIPs);
        }
        catch ( UnknownHostException e )
        {
            return false;
        }
    }
Returns a newly created session between the server and a client. The session will
be created and returned only if correct name/prefix ('stream')
and namespace were provided by the client.

@param serverName the name of the server where the session is connecting to.
@param xpp the parser that is reading the provided XML through the connection.
@param connection the connection with the client.
@return a newly created session between the server and a client.
@throws org.xmlpull.v1.XmlPullParserException if an error occurs while parsing incoming data.
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalClientSession.java