public static void setPermissionPolicy(PermissionPolicy policy) throws ModificationNotAllowedException {
        // Alert listeners about this event
        for (ExternalComponentManagerListener listener : listeners) {
            try {
                listener.permissionPolicyChanged(policy);
            } catch (Exception e) {
                Log.warn("An exception occurred while dispatching a 'permissionPolicyChanged' event!", e);
            }
        }
        JiveGlobals.setProperty("xmpp.component.permission", policy.toString());
        // Check if connected components can remain connected to the server
        for (ComponentSession session : SessionManager.getInstance().getComponentSessions()) {
            for (String domain : session.getExternalComponent().getSubdomains()) {
                if (!canAccess(domain)) {
                    Log.debug( "Closing session for external component '{}' as a changed permission policy is taken into effect. Affected session: {}", domain, session );
                    session.close();
                    break;
                }
            }
        }
    }
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.
@throws ModificationNotAllowedException if the operation was denied.
xmppserver/src/main/java/org/jivesoftware/openfire/component/ExternalComponentManager.java