@Override
    public void execute(@Nonnull SessionData sessionData, Element command)
    {
        final Locale preferredLocale = SessionManager.getInstance().getLocaleForSession(sessionData.getOwner());

        Element note = command.addElement("note");

        Map<String, List<String>> data = sessionData.getData();

        boolean requestError = false;
        final List<String> listed = new ArrayList<>();
        for ( final String blacklistjid : data.get( "blacklistjids" ))
        {
            JID domain;
            try
            {
                domain = new JID( blacklistjid );
                if (domain.getResource() != null || domain.getNode() != null) {
                    note.addAttribute( "type", "error" );
                    note.setText(LocaleUtils.getLocalizedString("commands.admin.editblockedlist.note.jid-domain-required", List.of(blacklistjid), preferredLocale));
                    requestError = true;
                }

                if (XMPPServer.getInstance().isLocal(domain)) {
                    note.addAttribute( "type", "error" );
                    note.setText(LocaleUtils.getLocalizedString("commands.admin.editblockedlist.note.jid-self", List.of(blacklistjid), preferredLocale));
                    requestError = true;
                }

                listed.add(domain.getDomain());
            }
            catch ( NullPointerException npe )
            {
                note.addAttribute( "type", "error" );
                note.setText(LocaleUtils.getLocalizedString("commands.admin.editblockedlist.note.jid-required", preferredLocale));
                requestError = true;
            }
            catch (IllegalArgumentException npe)
            {
                note.addAttribute( "type", "error" );
                note.setText(LocaleUtils.getLocalizedString("commands.admin.editblockedlist.note.jid-invalid", preferredLocale));
                requestError = true;
            }
        }

        if ( requestError )
        {
            // We've collected all errors. Return without applying changes.
            return;
        }

        // No errors.
        final Collection<RemoteServerConfiguration> blockedServers = RemoteServerManager.getBlockedServers();
        for (final String domain : listed) {
            if (blockedServers.stream().noneMatch(s -> s.getDomain().equals(domain))) {
                RemoteServerManager.blockAccess(domain);
            }
        }
        for (final RemoteServerConfiguration blockedServer : blockedServers) {
            if ( !listed.contains(blockedServer.getDomain())) {
                // Unblock - no longer on the list.
                RemoteServerManager.deleteConfiguration(blockedServer.getDomain());
            }
        }

        // Answer that the operation was successful
        note.addAttribute("type", "info");
        note.setText(LocaleUtils.getLocalizedString("commands.global.operation.finished.success", preferredLocale));
    }
Edits the list of external domains that are disallowed to connect to Openfire

@author Guus der Kinderen, guus@goodbytes.nl
@see <a href="https://xmpp.org/extensions/xep-0133.html#edit-blacklist">XEP-0133 Service Administration: Edit Blacklist</a>
xmppserver/src/main/java/org/jivesoftware/openfire/commands/admin/EditBlockedList.java