public static void setPermissionPolicy(PermissionPolicy policy) {
        JiveGlobals.setProperty(ConnectionSettings.Server.PERMISSION_SETTINGS, policy.toString());
        // Check if the connected servers can remain connected to the server
        for (String hostname : SessionManager.getInstance().getIncomingServers()) {
            if (!canAccess(hostname)) {
                for (Session session : SessionManager.getInstance().getIncomingServerSessions(hostname)) {
                    Log.debug( "Closing session for hostname '{}' as a changed permission policy is taken into effect. Affected session: {}", hostname, session );
                    session.close();
                }
            }
        }
        for (DomainPair domainPair : SessionManager.getInstance().getOutgoingDomainPairs()) {
            if (!canAccess(domainPair.getRemote())) {
                Session session = SessionManager.getInstance().getOutgoingServerSession(domainPair);
                Log.debug( "Closing session as a changed permission policy is taken into effect. Affected session: {}", session );
                session.close();
                // After the session has been close, inform all listeners as well.
                ServerSessionEventDispatcher.dispatchEvent(session, ServerSessionEventDispatcher.EventType.session_destroyed);
            }
        }
    }
Sets the permission policy being used for new XMPP entities that are trying to
connect to the server. There are two types of policies: 1) blacklist: where any entity
is allowed to connect to the server except for those listed in the black list and
2) whitelist: where only the entities listed in the white list are allowed to connect to
the server.

@param policy the new PermissionPolicy to use.
xmppserver/src/main/java/org/jivesoftware/openfire/server/RemoteServerManager.java